@firestartr/cli 1.53.0 → 1.53.1-release-candidate

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
@@ -367720,12 +367720,19 @@ function updateConditionByType(conditionList, type, newCondition) {
367720
367720
  return conditionList;
367721
367721
  }
367722
367722
 
367723
+ ;// CONCATENATED MODULE: ../operator/src/utils/operationErrorMessages.ts
367724
+ const APPLY_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform apply operation.';
367725
+ const DESTROY_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform destroy operation.';
367726
+ const PLAN_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform plan operation.';
367727
+ const SYNC_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Sync operation.';
367728
+
367723
367729
  ;// CONCATENATED MODULE: ../operator/src/syncCtl.ts
367724
367730
  // Machinery for syncing
367725
367731
 
367726
367732
 
367727
367733
 
367728
367734
 
367735
+
367729
367736
  const DEFAULT_REVISION_TIME = '1m';
367730
367737
  async function createWatcherForItem(itemPath, itemCR) {
367731
367738
  const item = itemCR ?? (await getItemByItemPath(itemPath));
@@ -367788,7 +367795,7 @@ async function getSyncStatus(itemPath, itemCR) {
367788
367795
  : (await getSyncSpecs(itemPath, item)).schedule
367789
367796
  ? 'Scheduled'
367790
367797
  : 'Period';
367791
- return {
367798
+ const syncStatus = {
367792
367799
  itemPath,
367793
367800
  syncMode: mode,
367794
367801
  conditions: [syncCondition],
@@ -367796,6 +367803,11 @@ async function getSyncStatus(itemPath, itemCR) {
367796
367803
  nextTimeoutInMS: isLapsed ? -1 : nextSyncDate.getTime() - Date.now(),
367797
367804
  intervalLapsed: isLapsed,
367798
367805
  };
367806
+ if (syncCondition) {
367807
+ syncStatus.hasSyncFailed =
367808
+ syncCondition.message === SYNC_DEFAULT_ERROR_MESSAGE;
367809
+ }
367810
+ return syncStatus;
367799
367811
  }
367800
367812
  }
367801
367813
  async function setSyncStatus(itemPath, reason, status, message) {
@@ -368444,6 +368456,15 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
368444
368456
  yield transition;
368445
368457
  }
368446
368458
  if (needsUpdateSyncConditions) {
368459
+ if (operation === OperationType.SYNC) {
368460
+ // let's check if the process has not failed
368461
+ const syncStatus = await getSyncStatus(workItem.handler.itemPath());
368462
+ if (syncStatus.hasSyncFailed) {
368463
+ // we do not update sync because we are not going to trigger
368464
+ // a RETRY operation if the sync has failed
368465
+ return;
368466
+ }
368467
+ }
368447
368468
  await setSyncStatus(workItem.handler.itemPath(), operation, operation === OperationType.SYNC ? 'True' : 'False', 'Sync process finished');
368448
368469
  void syncCtl.updateItem(informer_itemPath(pluralKind, item));
368449
368470
  }
@@ -369464,9 +369485,7 @@ function provisionFeatureFiles(scope, feature) {
369464
369485
  ? { ignoreChanges: ['content'] }
369465
369486
  : {};
369466
369487
  const repoConfig = {
369467
- branch: file.targetBranch.length === 0
369468
- ? defaultBranchName
369469
- : file.targetBranch,
369488
+ branch: file.targetBranch || defaultBranchName,
369470
369489
  commitMessage: `feat: ${feature.spec.type} ${feature.spec.version}`,
369471
369490
  content: cdktf_lib.Fn.base64decode(file.content),
369472
369491
  file: file.path,
@@ -371164,11 +371183,6 @@ function helperCreateCheckRunName(cmd, item) {
371164
371183
  return `${item.kind} - ${cmd}`;
371165
371184
  }
371166
371185
 
371167
- ;// CONCATENATED MODULE: ../operator/src/utils/operationErrorMessages.ts
371168
- const APPLY_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform apply operation.';
371169
- const DESTROY_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform destroy operation.';
371170
- const PLAN_DEFAULT_ERROR_MESSAGE = 'An error occurred while executing the Terraform plan operation.';
371171
-
371172
371186
  ;// CONCATENATED MODULE: ../operator/cdktf.ts
371173
371187
 
371174
371188
 
@@ -372609,7 +372623,7 @@ async function* process_operation_observe(item, op, handler) {
372609
372623
  yield transition;
372610
372624
  }
372611
372625
  }
372612
- async function* doPlanJSONFormat(item, op, handler) {
372626
+ async function* doPlanJSONFormat(item, op, handler, setResult = function (_r) { }) {
372613
372627
  let error = false;
372614
372628
  try {
372615
372629
  yield {
@@ -372710,34 +372724,83 @@ async function* doPlanJSONFormat(item, op, handler) {
372710
372724
  }
372711
372725
  finally {
372712
372726
  if (error) {
372713
- yield {
372714
- item,
372715
- reason: op,
372716
- type: 'PROVISIONED',
372717
- status: 'False',
372718
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372719
- };
372720
- yield {
372721
- item,
372722
- reason: op,
372723
- type: 'PLANNING',
372724
- status: 'False',
372725
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372726
- };
372727
- yield {
372728
- item,
372729
- reason: op,
372730
- type: 'OUT_OF_SYNC',
372731
- status: 'False',
372732
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372733
- };
372734
- yield {
372735
- item,
372736
- reason: op,
372737
- type: 'ERROR',
372738
- status: 'True',
372739
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372740
- };
372727
+ if (op === OperationType.SYNC) {
372728
+ // if there is an error on a sync we never put the state on error
372729
+ // it would be problematic because the RETRY op kicks in
372730
+ if (error) {
372731
+ yield {
372732
+ item,
372733
+ reason: op,
372734
+ type: 'SYNCHRONIZED',
372735
+ status: 'True',
372736
+ message: SYNC_DEFAULT_ERROR_MESSAGE,
372737
+ };
372738
+ yield {
372739
+ item,
372740
+ reason: op,
372741
+ type: 'PROVISIONED',
372742
+ status: 'True',
372743
+ message: 'doPlanJSONFormat',
372744
+ };
372745
+ yield {
372746
+ item,
372747
+ reason: op,
372748
+ type: 'PLANNING',
372749
+ status: 'False',
372750
+ message: 'doPlanJSONFormat',
372751
+ };
372752
+ yield {
372753
+ item,
372754
+ reason: op,
372755
+ type: 'OUT_OF_SYNC',
372756
+ status: 'False',
372757
+ message: 'doPlanJSONFormat',
372758
+ };
372759
+ yield {
372760
+ item,
372761
+ reason: op,
372762
+ type: 'ERROR',
372763
+ status: 'False',
372764
+ message: 'doPlanJSONFormat',
372765
+ };
372766
+ }
372767
+ setResult('SYNC_ERROR_PLAN');
372768
+ }
372769
+ else {
372770
+ yield {
372771
+ item,
372772
+ reason: op,
372773
+ type: 'PROVISIONED',
372774
+ status: 'False',
372775
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372776
+ };
372777
+ yield {
372778
+ item,
372779
+ reason: op,
372780
+ type: 'PLANNING',
372781
+ status: 'False',
372782
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372783
+ };
372784
+ yield {
372785
+ item,
372786
+ reason: op,
372787
+ type: 'OUT_OF_SYNC',
372788
+ status: 'False',
372789
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372790
+ };
372791
+ yield {
372792
+ item,
372793
+ reason: op,
372794
+ type: 'ERROR',
372795
+ status: 'True',
372796
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372797
+ };
372798
+ }
372799
+ }
372800
+ else {
372801
+ if (op === OperationType.SYNC) {
372802
+ setResult('SYNC_SUCCESS');
372803
+ }
372741
372804
  }
372742
372805
  }
372743
372806
  }
@@ -372780,6 +372843,7 @@ function isDestroyRetry(item) {
372780
372843
  return false;
372781
372844
  }
372782
372845
  async function* process_operation_sync(item, op, handler, syncPolicy, generalPolicy) {
372846
+ let doResult = '';
372783
372847
  if (!syncPolicy) {
372784
372848
  operator_src_logger.debug(`The Terraform processor is only observing item '${item.kind}/${item.metadata.name}' because no sync policy was found for operation '${op}'.`);
372785
372849
  yield* doPlanJSONFormat(item, op, handler);
@@ -372796,23 +372860,30 @@ async function* process_operation_sync(item, op, handler, syncPolicy, generalPol
372796
372860
  break;
372797
372861
  }
372798
372862
  case 'observe': {
372799
- yield* doPlanJSONFormat(item, op, handler);
372863
+ yield* doPlanJSONFormat(item, op, handler, (result) => {
372864
+ doResult = result;
372865
+ });
372800
372866
  break;
372801
372867
  }
372802
372868
  default: {
372803
372869
  operator_src_logger.debug(`The Terraform processor detected a sync policy '${syncPolicy}' for item '${item.kind}/${item.metadata.name}' that is not supported.`);
372804
- yield* doPlanJSONFormat(item, op, handler);
372870
+ yield* doPlanJSONFormat(item, op, handler, (result) => {
372871
+ doResult = result;
372872
+ });
372805
372873
  break;
372806
372874
  }
372807
372875
  }
372808
372876
  }
372809
- yield {
372810
- item,
372811
- reason: op,
372812
- type: 'SYNCHRONIZED',
372813
- status: 'True',
372814
- message: 'Sync process finished',
372815
- };
372877
+ operator_src_logger.debug(`doResult is ${doResult}`);
372878
+ if (doResult === 'SYNC_SUCCESS') {
372879
+ yield {
372880
+ item,
372881
+ reason: op,
372882
+ type: 'SYNCHRONIZED',
372883
+ status: 'True',
372884
+ message: 'Sync process finished',
372885
+ };
372886
+ }
372816
372887
  }
372817
372888
  async function* process_operation_markedToDeletion(item, op, handler) {
372818
372889
  let error = false;
@@ -374149,6 +374220,7 @@ var sdk_metrics_build_src = __nccwpck_require__(84016);
374149
374220
 
374150
374221
 
374151
374222
 
374223
+
374152
374224
  const INTERVAL_IN_SEGS = 60;
374153
374225
  class CRStateMetrics {
374154
374226
  constructor(kind, namespace, meter) {
@@ -374171,6 +374243,9 @@ class CRStateMetrics {
374171
374243
  this.deletedGauge = meter.createGauge('firestartr_deleted_total', {
374172
374244
  description: 'Total number of CRs in DELETED state',
374173
374245
  });
374246
+ this.errorOnSyncGauge = meter.createGauge('firestartr_error_on_sync_total', {
374247
+ description: 'Total number of CRs with failed SYNCs',
374248
+ });
374174
374249
  this.namespace = namespace;
374175
374250
  }
374176
374251
  async start() {
@@ -374199,10 +374274,18 @@ class CRStateMetrics {
374199
374274
  let errorCount = 0;
374200
374275
  let planningCount = 0;
374201
374276
  let deletedCount = 0;
374277
+ let errorOnSyncCount = 0;
374202
374278
  for (const item of items) {
374203
374279
  const status = item.status?.conditions.find((condition) => condition.type !== 'SYNCHRONIZED' && condition.status === 'True');
374204
374280
  if (!status)
374205
374281
  continue;
374282
+ const syncCondition = item.status.conditions.find((condition) => {
374283
+ return condition.type === 'SYNCHRONIZED';
374284
+ });
374285
+ if (syncCondition &&
374286
+ syncCondition.message === SYNC_DEFAULT_ERROR_MESSAGE) {
374287
+ errorOnSyncCount++;
374288
+ }
374206
374289
  switch (status.type) {
374207
374290
  case 'PROVISIONED':
374208
374291
  provisionedCount++;
@@ -374248,6 +374331,10 @@ class CRStateMetrics {
374248
374331
  namespace: this.namespace,
374249
374332
  kind: this.kind,
374250
374333
  });
374334
+ this.errorOnSyncGauge.record(errorOnSyncCount, {
374335
+ namespace: this.namespace,
374336
+ kind: this.kind,
374337
+ });
374251
374338
  }
374252
374339
  catch (err) {
374253
374340
  console.log(`CRStateMetrics: update ${err}`);
@@ -8,6 +8,7 @@ export default class CRStateMetrics {
8
8
  planningGauge: any;
9
9
  deletedGauge: any;
10
10
  errorGauge: any;
11
+ errorOnSyncGauge: any;
11
12
  onUpdate: boolean;
12
13
  namespace: string;
13
14
  kc: any;
@@ -14,6 +14,7 @@ export type SyncStatus = {
14
14
  syncStatusPresent?: boolean;
15
15
  intervalLapsed?: boolean;
16
16
  syncMode?: SyncMode;
17
+ hasSyncFailed?: boolean;
17
18
  };
18
19
  export type SyncWatcher = {
19
20
  itemPath: string;
@@ -1,3 +1,4 @@
1
1
  export declare const APPLY_DEFAULT_ERROR_MESSAGE = "An error occurred while executing the Terraform apply operation.";
2
2
  export declare const DESTROY_DEFAULT_ERROR_MESSAGE = "An error occurred while executing the Terraform destroy operation.";
3
3
  export declare const PLAN_DEFAULT_ERROR_MESSAGE = "An error occurred while executing the Terraform plan operation.";
4
+ export declare const SYNC_DEFAULT_ERROR_MESSAGE = "An error occurred while executing the Sync operation.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.53.0",
3
+ "version": "1.53.1-release-candidate",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",