diff --git a/src/commands/apply.ts b/src/commands/apply.ts index 6b1b242..1f54638 100644 --- a/src/commands/apply.ts +++ b/src/commands/apply.ts @@ -243,7 +243,7 @@ async function printLogs(parsedFiles: Observable) { const kind = manifest.manifest.kind; const name = manifest.manifest.metadata.name; const fileName = manifest.file.file.fileName; - successTree.insert(`${kind} ${name} created (${fileName})`, subTree); + successTree.insert(`${kind} ${name} applied (${fileName})`, subTree); if (manifest.state === ManifestState.UNKNOWN_SUCCESS_RESPONSE) { subTree.insert(chalk.yellow('Unknown server response')); } @@ -255,7 +255,7 @@ async function printLogs(parsedFiles: Observable) { tap((count) => { if (count === 0) return; cli.log(''); - cli.log(chalk.green('Created resources')); + cli.log(chalk.green('Applied resources')); successTree.display(); }) ) diff --git a/src/commands/import.ts b/src/commands/import.ts index 0ed5e59..a6d9980 100644 --- a/src/commands/import.ts +++ b/src/commands/import.ts @@ -123,9 +123,9 @@ export default class Apply extends Command { try { try { for (const group of importGroups) { - const manifestOfGroup = group.getManifests(); + const manifestsOfGroup = group.getManifests(); await applyManifests( - manifestOfGroup, + manifestsOfGroup, { orgId, projectId, envId }, { start: `Applying ${group.resourceTypes.description}`, @@ -262,7 +262,7 @@ async function printLogs(groups: ManifestImportGroup[]) { const subTree = cli.tree(); const kind = manifest.manifest.kind; const name = manifest.manifest.metadata.name; - successTree.insert(`${kind} ${name} created`, subTree); + successTree.insert(`${kind} ${name} applied`, subTree); if (manifest.state === ManifestState.UNKNOWN_SUCCESS_RESPONSE) { subTree.insert(chalk.yellow('Unknown server response')); } @@ -274,7 +274,7 @@ async function printLogs(groups: ManifestImportGroup[]) { tap((count) => { if (count === 0) return; cli.log(''); - cli.log(chalk.green('Created resources')); + cli.log(chalk.green('Applied resources')); successTree.display(); }) ) diff --git a/src/modules/gitops/manifest-group.ts b/src/modules/gitops/manifest-group.ts index 0528095..e4c640d 100644 --- a/src/modules/gitops/manifest-group.ts +++ b/src/modules/gitops/manifest-group.ts @@ -1,11 +1,11 @@ -import { defer, EMPTY, Observable, of } from 'rxjs'; +import { defer, EMPTY, Observable, of, timer } from 'rxjs'; import { catchError, filter, map, mergeAll, mergeMap, - retry, + retryWhen, shareReplay, takeUntil, tap, @@ -99,7 +99,17 @@ function fetchResourcesOfType(query: ResourceQuery, r: ResourceType) { throw new YamlFectchFailure(r, query, cause); } }).pipe( - retry(2), + retryWhen((errors) => + errors.pipe( + mergeMap((v, i) => { + // error msg available, no need to retry + if (v instanceof YamlFectchFailure && v.cause) throw v; + // allow 2 retries, retry in 1s + if (i > 1) throw v; + return timer(1000); + }) + ) + ), catchError(async (err) => { if (err instanceof YamlFectchFailure) return err; return EMPTY; diff --git a/src/modules/gitops/manifest-import-types.ts b/src/modules/gitops/manifest-import-types.ts index aca78dd..1d61fa1 100644 --- a/src/modules/gitops/manifest-import-types.ts +++ b/src/modules/gitops/manifest-import-types.ts @@ -32,8 +32,8 @@ const importTypes: Array = [ { kind: 'Deployment', apiVersion: 'extensions/v1beta1' }, { kind: 'StatefulSet', apiVersion: 'apps/v1' }, { kind: 'DaemonSet', apiVersion: 'apps/v1' }, - { kind: 'Job', apiVersion: 'batch/v1' }, { kind: 'CronJob', apiVersion: 'batch/v1' }, + { kind: 'CronJob', apiVersion: 'batch/v1beta1' }, ], }, { diff --git a/src/modules/gitops/manifest-object.ts b/src/modules/gitops/manifest-object.ts index b3b82bb..08e89a8 100644 --- a/src/modules/gitops/manifest-object.ts +++ b/src/modules/gitops/manifest-object.ts @@ -91,7 +91,8 @@ export class ManifestObject { this.errorMsg = (error as Error).message; s.error(ManifestState.ERROR); } - throw error; + // return without throwing error, to allow other manifests to be applied + return; } s.next(ManifestState.WRITING_TO_FILE); try {