You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -157,9 +157,26 @@ See if we can make the build log sort before the step logs in `ListLogsForBuild`
157
157
158
158
Sqlite sorts with `NULLS FIRST` by default, and Postgres sorts with `NULLS LAST` (see: [How Are NULLs Sorted by Default?](https://learnsql.com/blog/how-to-order-rows-with-nulls/)).
159
159
So this query is inconsistent between databases. And, the service logs returned by this query are not sorted. It would be nice to have this method return the logs sorted in a consistent manner.
160
-
I would like to see the Build Log, then Step Logs sorted by step_id, then Service Logs sorted by service_id. Any suggestions on how to do that with gorm?
160
+
I would like to see the Build Log, then Step Logs sorted by step_id, then Service Logs sorted by service_id. GORM supports multiple [order](https://gorm.io/docs/query.html#Order) statements, so something like this should be possible:
161
161
162
-
We might need some kind of index or constraint on the `Log` table so that rows with NULL step_id and NULL service_id must have a unique build_id. But, I'm not sure how to create such an index/constraint.
162
+
```go
163
+
err = e.client.
164
+
Table(constants.TableLog).
165
+
Where("build_id = ?", b.GetID()).
166
+
Order("(step_id IS NULL AND service_id IS NULL) DESC"). // the build init log
167
+
Order("step_id ASC NULLS LAST").
168
+
Order("service_id ASC").
169
+
```
170
+
171
+
We might need some kind of index or constraint on the `Log` table so that rows with NULL step_id and NULL service_id must have a unique build_id. A partial unique index seems like the simplest way to do this:
172
+
173
+
```sql
174
+
CREATE UNIQUE INDEX
175
+
IF NOT EXISTS
176
+
logs_build_init_log
177
+
ON logs (build_id)
178
+
WHERE step_id IS NULL AND service_id IS NULL;
179
+
```
163
180
164
181
#### Server - API
165
182
@@ -186,9 +203,7 @@ The compiler needs to deprecate and stop adding the `InitStage` and `InitStep`.
186
203
- remove the `Init*()` calls from `compiler/native/compile.go`, and
187
204
- remove the magic `"init"` string special-casing in `compiler/native/validate.go`.
188
205
189
-
Backwards compatibility is a concern with the compiler. Referencing old builds/pipelines should work just fine as it includes the "init" step and stage, thus preserving references to the underlying log. But, recompiling the pipeline will create a slightly different pipeline--one without the injected "init" stage and/or step. The worker will no longer handle the old pipeline with the injected "init" step, so any re-runs MUST re-compile the pipeline.
190
-
191
-
Does re-running a build ALWAYS re-compile the pipeline?
206
+
Backwards compatibility is a concern with the compiler. Referencing old builds/pipelines should work just fine as it includes the "init" step and stage, thus preserving references to the underlying log. But, recompiling the pipeline will create a slightly different pipeline--one without the injected "init" stage and/or step. The worker will no longer handle the old pipeline with the injected "init" step, so any re-runs MUST re-compile the pipeline. Luckily re-runs always re-compile the pipeline.
192
207
193
208
#### Server - Queue
194
209
@@ -198,24 +213,24 @@ Also, when upgrading, we need to ensure that:
198
213
- the queue is empty, or
199
214
- all queued builds get re-compiled (or more particularly `item.Pipeline` which is a `types.pipeline.Build` and includes the injected init step) before execution in the worker starts.
200
215
201
-
To make the worker backwards compatible, could we trigger the rebuild in `server.queue.redis.Pop()` after the item is created?
202
-
Or perhaps we'll just need to include queued build migrations in the migration script.
216
+
We need to gracefully handle any stale queued items in the queue after upgrading server and worker. Items are stale if they were queued with a previous version of Vela.
203
217
204
218
### Worker
205
219
206
220
Save init logs to the Build `Log` instead of the magic init step.
207
221
Nothing in the worker should check for these magic strings any more: `"init"`, `"#init"`
208
222
209
-
We might need something that rejects an old build when popped off the queue if it is an older version that includes the injected "init" `Step`.
223
+
Hopefully we can do this in one release, documenting any required queue flushing or similar. To make this work well, the queue item will need some kind of version number (TODO: create community issue for this).
224
+
Then the worker should fail a build popped from the queue if that item was created by an earlier version of Vela.
210
225
211
-
We might need to spread this change over a couple of versions.
226
+
If needed, we can also spread this change over a couple of versions:
212
227
- In one version, we start logging to the Build `Log` and deprecate support for the magic "init" step.
213
228
- In the next (or a future) version, we remove support for the magic string checking.
214
229
215
230
In my previous [`InitStep` proposal](https://github.com/go-vela/community/pull/771), I suggested logging to both places for at least one version while waiting for the UI to catch up.
216
-
However, the primary objection to that proposal was increased database storage costs. So, this proposal recommends a hard breakthe worker will only create the init logs in one place.
217
-
The backwards compatibility is achieved by continuing to ignore Stages/Steps with the magic "init" or "#init" strings. Even if those strings are present, the worker will still send
218
-
the build init logs to the server via the new build init logs endpoints.
231
+
However, the primary objection to that proposal was increased database storage costs. So, this proposal recommends a hard break--the worker will only create the init logs in one place.
232
+
If we do spread this over two releases, then the worker will continue to ignore Stages/Steps with the magic "init" or "#init" strings. Even if those strings are present, the worker will
233
+
still send the build init logs to the server via the new build init logs endpoints.
219
234
220
235
### SDK
221
236
@@ -228,20 +243,18 @@ initstep logs without change by virue of re-using the `Log` types for this.
228
243
229
244
We also need a new command to retrieve the "init" logs for a Build.
230
245
231
-
One way to provide this would be an `--init` flag to specify we only want the build's init log, not all of the logs for the build:
246
+
We will provide this with an `--init` flag to specify we only want the build's init log, not all of the logs for the build:
I have not used the vela CLI much, so I'm not sure which option would be more ergonomic, or if we need something else entirely.
244
-
245
258
### UI
246
259
247
260
The UI needs to stream the build init log just like it does for steps and services. This can be shown as a step that comes before any stages or steps.
@@ -266,7 +279,7 @@ NOTE: If there are no current plans for implementation, please leave this sectio
266
279
267
280
Yes for the go code in Types, Server, Worker, sdk-go, and CLI.
268
281
269
-
The UI, however, is beyond me at this point. I need someone familiar eith elm to handle the UI.
282
+
@plyr4 will help out with the UI, beginning with mocking out some ideas on how to separate init logs in a backwards-compatible way (ie supporting builds with the magic init step).
270
283
271
284
2. What's the estimated time to completion?
272
285
@@ -284,9 +297,4 @@ TBD
284
297
285
298
<!-- Answer here -->
286
299
287
-
This is a summary of the questions listed above:
288
-
- How can we add an index or constraint to the database so that each build can only have one init Log? (see "Server" > "Server - Database" above)
289
-
- Does re-running a build ALWAYS re-compile the pipeline? (see "Server" > "Server - Compiler" above)
290
-
- Do we need to trigger a re-compile for old builds on the queue when the worker Pops them off the queue? (see "Server" > "Server - Queue" above)
291
-
- Do we need to migrate / re-compile any builds on the queue in an upgrade migration script? (see "Server" > "Server - Queue" above)
292
-
- Does anyone have bandwidth to help with the UI piece? (see "UI" above)
0 commit comments