@oisincoveney/pipeline 3.24.0 → 3.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/argo-submit.js +71 -52
  2. package/package.json +1 -1
@@ -137,22 +137,22 @@ function submitRunnerArgoWorkflowEffect(rawOptions, dependencies) {
137
137
  });
138
138
  return Effect.gen(function* () {
139
139
  const graph = yield* graphEffect;
140
- const createdConfigMapNames = yield* createRunConfigMaps({
141
- configMaps: staticRunConfigMaps({
142
- labels,
140
+ return yield* submitWorkflowWithRunConfigMaps({
141
+ configMapNames: yield* createRunConfigMaps({
142
+ configMaps: staticRunConfigMaps({
143
+ labels,
144
+ namespace: options.namespace,
145
+ payloadConfigMapName,
146
+ payloadJson,
147
+ scheduleConfigMapName: scheduleArtifactConfigMapName,
148
+ scheduleYaml: options.scheduleYaml,
149
+ taskDescriptorConfigMapName,
150
+ tasks: graph.tasks
151
+ }),
152
+ dependencies,
143
153
  namespace: options.namespace,
144
- payloadConfigMapName,
145
- payloadJson,
146
- scheduleConfigMapName: scheduleArtifactConfigMapName,
147
- scheduleYaml: options.scheduleYaml,
148
- taskDescriptorConfigMapName,
149
- tasks: graph.tasks
154
+ options
150
155
  }),
151
- dependencies,
152
- namespace: options.namespace,
153
- options
154
- });
155
- return yield* submitWorkflowManifest({
156
156
  dependencies,
157
157
  namespace: options.namespace,
158
158
  options,
@@ -163,19 +163,7 @@ function submitRunnerArgoWorkflowEffect(rawOptions, dependencies) {
163
163
  },
164
164
  workflow,
165
165
  workflowFieldOverrides: { podGC: options.podGC }
166
- }).pipe(Effect.flatMap((result) => ownRunConfigMaps({
167
- configMapNames: createdConfigMapNames,
168
- dependencies,
169
- namespace: options.namespace,
170
- options,
171
- result
172
- })), Effect.catch((error) => cleanupRunConfigMapsOnFailure({
173
- configMapNames: createdConfigMapNames,
174
- dependencies,
175
- error,
176
- namespace: options.namespace,
177
- options
178
- })));
166
+ });
179
167
  });
180
168
  }
181
169
  function submitDynamicRunnerArgoWorkflowEffect(rawOptions, dependencies) {
@@ -222,37 +210,25 @@ function submitDynamicRunnerArgoWorkflowEffect(rawOptions, dependencies) {
222
210
  workflowId: options.workflowId
223
211
  });
224
212
  return Effect.gen(function* () {
225
- const createdConfigMapNames = yield* createRunConfigMaps({
226
- configMaps: dynamicRunConfigMaps({
227
- labels,
213
+ return yield* submitWorkflowWithRunConfigMaps({
214
+ configMapNames: yield* createRunConfigMaps({
215
+ configMaps: dynamicRunConfigMaps({
216
+ labels,
217
+ namespace: options.namespace,
218
+ payloadConfigMapName,
219
+ payloadJson
220
+ }),
221
+ dependencies,
228
222
  namespace: options.namespace,
229
- payloadConfigMapName,
230
- payloadJson
223
+ options
231
224
  }),
232
- dependencies,
233
- namespace: options.namespace,
234
- options
235
- });
236
- return yield* submitWorkflowManifest({
237
225
  dependencies,
238
226
  namespace: options.namespace,
239
227
  options,
240
228
  resultExtras: { payloadConfigMapName },
241
229
  workflow,
242
230
  workflowFieldOverrides: { podGC: options.podGC }
243
- }).pipe(Effect.flatMap((result) => ownRunConfigMaps({
244
- configMapNames: createdConfigMapNames,
245
- dependencies,
246
- namespace: options.namespace,
247
- options,
248
- result
249
- })), Effect.catch((error) => cleanupRunConfigMapsOnFailure({
250
- configMapNames: createdConfigMapNames,
251
- dependencies,
252
- error,
253
- namespace: options.namespace,
254
- options
255
- })));
231
+ });
256
232
  });
257
233
  }
258
234
  function staticRunConfigMaps(input) {
@@ -322,14 +298,32 @@ function createRunConfigMaps(input) {
322
298
  })));
323
299
  }
324
300
  function ownRunConfigMaps(input) {
301
+ const ownerReference = workflowOwnerReference(input.result);
302
+ if (ownerReference === void 0) return warnRunConfigMapOwnershipSkipped({
303
+ error: new Error(missingWorkflowUidMessage(input.result)),
304
+ result: input.result
305
+ }).pipe(Effect.as(input.result));
325
306
  return patchRunConfigMapOwnerReferences({
326
- body: configMapOwnerReferencesPatch(workflowOwnerReference(input.result)),
307
+ body: configMapOwnerReferencesPatch(ownerReference),
327
308
  configMapNames: input.configMapNames,
328
309
  dependencies: input.dependencies,
329
310
  namespace: input.namespace,
330
311
  options: input.options
331
312
  }).pipe(Effect.as(input.result));
332
313
  }
314
+ function ownRunConfigMapsBestEffort(input) {
315
+ return ownRunConfigMaps(input).pipe(Effect.catch((error) => warnRunConfigMapOwnershipSkipped({
316
+ error,
317
+ result: input.result
318
+ }).pipe(Effect.as(input.result))));
319
+ }
320
+ function warnRunConfigMapOwnershipSkipped(input) {
321
+ return Effect.sync(() => {
322
+ const reason = errorMessage(input.error);
323
+ const message = `moka submit: failed to set Workflow ownerReference for ConfigMaps after Argo Workflow '${input.result.workflowName}' was created; leaving ConfigMaps for TTL/sweeper cleanup: ${reason}\n`;
324
+ process.stderr.write(message);
325
+ });
326
+ }
333
327
  function cleanupRunConfigMapsOnFailure(input) {
334
328
  return deleteRunConfigMaps({
335
329
  configMapNames: input.configMapNames,
@@ -362,7 +356,7 @@ function deleteRunConfigMaps(input) {
362
356
  });
363
357
  }
364
358
  function workflowOwnerReference(result) {
365
- if (result.workflowUid === void 0) throw new Error(`Created Argo Workflow '${result.workflowName}' did not include metadata.uid; cannot own ConfigMaps`);
359
+ if (result.workflowUid === void 0) return;
366
360
  return workflowOwnerReferenceSchema.parse({
367
361
  apiVersion: "argoproj.io/v1alpha1",
368
362
  kind: "Workflow",
@@ -370,6 +364,9 @@ function workflowOwnerReference(result) {
370
364
  uid: result.workflowUid
371
365
  });
372
366
  }
367
+ function missingWorkflowUidMessage(result) {
368
+ return `Created Argo Workflow '${result.workflowName}' did not include metadata.uid; cannot own ConfigMaps`;
369
+ }
373
370
  function configMapOwnerReferencesPatch(ownerReference) {
374
371
  return configMapOwnerReferencesPatchSchema.parse({ metadata: { ownerReferences: [ownerReference] } });
375
372
  }
@@ -391,6 +388,28 @@ function submitWorkflowManifest(input) {
391
388
  });
392
389
  });
393
390
  }
391
+ function submitWorkflowWithRunConfigMaps(input) {
392
+ return submitWorkflowManifest({
393
+ dependencies: input.dependencies,
394
+ namespace: input.namespace,
395
+ options: input.options,
396
+ resultExtras: input.resultExtras,
397
+ workflow: input.workflow,
398
+ workflowFieldOverrides: input.workflowFieldOverrides
399
+ }).pipe(Effect.catch((error) => cleanupRunConfigMapsOnFailure({
400
+ configMapNames: input.configMapNames,
401
+ dependencies: input.dependencies,
402
+ error,
403
+ namespace: input.namespace,
404
+ options: input.options
405
+ })), Effect.flatMap((result) => ownRunConfigMapsBestEffort({
406
+ configMapNames: input.configMapNames,
407
+ dependencies: input.dependencies,
408
+ namespace: input.namespace,
409
+ options: input.options,
410
+ result
411
+ })));
412
+ }
394
413
  function applyWorkflowFieldOverrides(workflow, overrides) {
395
414
  if (overrides?.podGC === void 0) return workflow;
396
415
  return runnerArgoWorkflowManifestSchema.parse({
package/package.json CHANGED
@@ -146,7 +146,7 @@
146
146
  "prepack": "nub run build:cli"
147
147
  },
148
148
  "type": "module",
149
- "version": "3.24.0",
149
+ "version": "3.24.1",
150
150
  "description": "Config-driven multi-agent pipeline runner for repository work",
151
151
  "main": "./dist/index.js",
152
152
  "types": "./dist/index.d.ts",