@firestartr/cli 1.53.0-snapshot-3 → 1.53.0-snapshot-4

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.
package/build/index.js CHANGED
@@ -374174,6 +374174,8 @@ async function startCRStates(meter, kindList, namespace) {
374174
374174
  }
374175
374175
  }
374176
374176
 
374177
+ // EXTERNAL MODULE: external "util"
374178
+ var external_util_ = __nccwpck_require__(73837);
374177
374179
  ;// CONCATENATED MODULE: ../operator/src/cmd/tf_planner.ts
374178
374180
 
374179
374181
 
@@ -374181,9 +374183,10 @@ async function startCRStates(meter, kindList, namespace) {
374181
374183
 
374182
374184
 
374183
374185
 
374186
+
374184
374187
  const deploymentName = catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.operatorDeploymentName) || 'firestartr-firestartr-controller';
374185
374188
  const DEFAULT_OPERATOR_DEPLOY = (/* unused pure expression or super */ null && (deploymentName));
374186
- async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl = 300, cmd = 'plan') {
374189
+ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl = 300, cmd = 'plan', callbackApi = function (ctl) { }) {
374187
374190
  const { kc } = await getConnection();
374188
374191
  const k8sApi = kc.makeApiClient(client.AppsV1Api);
374189
374192
  const batchV1Api = kc.makeApiClient(client.BatchV1Api);
@@ -374209,6 +374212,7 @@ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl = 300, c
374209
374212
  // set activeDeadlineSeconds to force terminate jobs that exceed this time
374210
374213
  // see https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup
374211
374214
  job.spec.activeDeadlineSeconds = 3600;
374215
+ job.spec.template.spec.containers[0].env = [{ name: 'CI', value: 'True' }];
374212
374216
  job.spec.template.spec.containers[0].command = [
374213
374217
  'sh',
374214
374218
  '-c',
@@ -374220,13 +374224,39 @@ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl = 300, c
374220
374224
  }
374221
374225
  job.spec.template.spec.restartPolicy = 'Never';
374222
374226
  job.metadata = metadata;
374227
+ // we limit the number of retries
374228
+ // to 1
374229
+ job.spec.backoffLimit = 1;
374223
374230
  // we exclude logs to be sent to datadog
374224
374231
  job.spec.template.metadata.annotations = {
374225
374232
  'ad.datadoghq.com/logs_exclude': 'true',
374226
374233
  };
374234
+ callbackApi({
374235
+ ctlCleanUp: () => cleanUp(namespace, metadata.name),
374236
+ });
374227
374237
  await batchV1Api.createNamespacedJob(namespace, job);
374228
374238
  await copyClaimAndGetLogs(namespace, job.metadata.name, claimFilePath);
374229
374239
  }
374240
+ async function cleanUp(namespace, jobName) {
374241
+ try {
374242
+ console.log('Cleaning up the job');
374243
+ const { kc } = await getConnection();
374244
+ const batchV1Api = kc.makeApiClient(client.BatchV1Api);
374245
+ console.log('Deleting job and its associated pods');
374246
+ await batchV1Api.deleteNamespacedJob(jobName, namespace, undefined, // pretty output
374247
+ undefined, // dryRun
374248
+ 1 * 60, // 60 segs of grace period
374249
+ undefined, 'Foreground');
374250
+ }
374251
+ catch (err) {
374252
+ const cleanError = util.inspect(err, {
374253
+ showHidden: false,
374254
+ depth: 1,
374255
+ colors: false,
374256
+ });
374257
+ console.error(cleanError);
374258
+ }
374259
+ }
374230
374260
  async function copyClaimAndGetLogs(namespace, jobName, sourcePath) {
374231
374261
  const { kc } = await getConnection();
374232
374262
  const k8sApi = kc.makeApiClient(client.CoreV1Api);
@@ -374275,11 +374305,12 @@ async function copyClaimAndGetLogs(namespace, jobName, sourcePath) {
374275
374305
  timestamps: false,
374276
374306
  });
374277
374307
  let podFinished = false;
374278
- setInterval(async () => {
374308
+ const interval = setInterval(async () => {
374279
374309
  await awaitPodStatus((phase) => {
374280
374310
  if (phase !== 'Running') {
374281
374311
  podFinished = true;
374282
374312
  req.abort();
374313
+ clearInterval(interval);
374283
374314
  return true;
374284
374315
  }
374285
374316
  else {
@@ -374293,7 +374324,12 @@ async function copyClaimAndGetLogs(namespace, jobName, sourcePath) {
374293
374324
  }
374294
374325
  }
374295
374326
  catch (err) {
374296
- console.error(err);
374327
+ const cleanError = util.inspect(err, {
374328
+ showHidden: false,
374329
+ depth: 1,
374330
+ colors: false,
374331
+ });
374332
+ console.error(cleanError);
374297
374333
  return;
374298
374334
  }
374299
374335
  }
@@ -1,2 +1,2 @@
1
- export declare function tfPlanner(claimFilePath: string, claim: any, namespace: string, debug: boolean, jobTtl?: number, cmd?: string): Promise<void>;
1
+ export declare function tfPlanner(claimFilePath: string, claim: any, namespace: string, debug: boolean, jobTtl?: number, cmd?: string, callbackApi?: (ctl: any) => void): Promise<void>;
2
2
  export declare function kubectlCp(sourcePath: string, namespace: string, podName: string, podFilePath?: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.53.0-snapshot-3",
3
+ "version": "1.53.0-snapshot-4",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",