@rockcarver/frodo-lib 0.18.9-0 → 0.18.9-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.
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.18.9-1] - 2023-03-27
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- rockcarver/frodo-cli#218: Frodo now allows 3 errors when polling for status during a `frodo esv apply` before aborting.
|
|
15
|
+
|
|
10
16
|
## [0.18.9-0] - 2023-03-23
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -1079,7 +1085,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1079
1085
|
- Fixed problem with adding connection profiles
|
|
1080
1086
|
- Miscellaneous bug fixes
|
|
1081
1087
|
|
|
1082
|
-
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.18.9-
|
|
1088
|
+
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.18.9-1...HEAD
|
|
1089
|
+
|
|
1090
|
+
[0.18.9-1]: https://github.com/rockcarver/frodo-lib/compare/v0.18.9-0...v0.18.9-1
|
|
1083
1091
|
|
|
1084
1092
|
[0.18.9-0]: https://github.com/rockcarver/frodo-lib/compare/v0.18.8...v0.18.9-0
|
|
1085
1093
|
|
|
@@ -60,13 +60,25 @@ function _applyUpdates() {
|
|
|
60
60
|
if (wait) {
|
|
61
61
|
var start = new Date().getTime();
|
|
62
62
|
var runtime = 0;
|
|
63
|
+
var errors = 0;
|
|
64
|
+
var maxErrors = 3;
|
|
63
65
|
while (status !== _StartupApi.RestartStatus.ready && start + timeout > new Date().getTime()) {
|
|
64
|
-
// eslint-disable-next-line no-await-in-loop, no-promise-executor-return
|
|
65
66
|
yield new Promise(resolve => setTimeout(resolve, 5000));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
try {
|
|
68
|
+
status = yield (0, _StartupApi.getStatus)();
|
|
69
|
+
|
|
70
|
+
// reset errors after successful status call
|
|
71
|
+
if (errors) errors = 0;
|
|
72
|
+
runtime = new Date().getTime() - start;
|
|
73
|
+
(0, _Console.updateProgressIndicator)("".concat(status, " (").concat(Math.round(runtime / 1000), "s)"));
|
|
74
|
+
} catch (error) {
|
|
75
|
+
errors++;
|
|
76
|
+
if (errors > maxErrors) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
runtime = new Date().getTime() - start;
|
|
80
|
+
(0, _Console.updateProgressIndicator)("".concat(error.message, " - retry ").concat(errors, "/").concat(maxErrors, " (").concat(Math.round(runtime / 1000), "s)"));
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
83
|
if (runtime < timeout) {
|
|
72
84
|
(0, _Console.stopProgressIndicator)("Updates applied in ".concat(Math.round(runtime / 1000), "s with final status: ").concat(status), 'success');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartupOps.js","names":["checkForUpdates","updates","secrets","variables","createProgressIndicator","undefined","getSecrets","result","filter","secret","loaded","getVariables","variable","error","stopProgressIndicator","response","data","code","message","updateCount","length","applyUpdates","wait","timeout","status","initiateRestart","start","Date","getTime","runtime","RestartStatus","ready","Promise","resolve","setTimeout","getStatus","updateProgressIndicator","Math","round"],"sources":["ops/cloud/StartupOps.ts"],"sourcesContent":["import {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getSecrets } from '../../api/cloud/SecretsApi';\nimport {\n getStatus,\n initiateRestart,\n RestartStatus,\n} from '../../api/cloud/StartupApi';\nimport { getVariables } from '../../api/cloud/VariablesApi';\n\n/**\n * Updates that need to be applied.\n */\nexport interface Updates {\n /**\n * Array of secrets that need applying\n */\n secrets?: unknown[];\n /**\n * Array of variables that need applying\n */\n variables?: unknown[];\n}\n\n/**\n * Check for updates that need applying\n * @returns {Promise<boolean>} true if there are updates that need to be applied, false otherwise\n */\nexport async function checkForUpdates(): Promise<Updates> {\n const updates: Updates = { secrets: [], variables: [] };\n createProgressIndicator(\n undefined,\n `Checking for updates to apply...`,\n 'indeterminate'\n );\n try {\n updates.secrets = (await getSecrets()).result.filter(\n (secret: { loaded: unknown }) => !secret.loaded\n );\n updates.variables = (await getVariables()).result.filter(\n (variable: { loaded: unknown }) => !variable.loaded\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n const updateCount = updates.secrets?.length + updates.variables?.length || 0;\n if (updateCount > 0) {\n stopProgressIndicator(\n `${updateCount} update(s) need to be applied`,\n 'success'\n );\n } else {\n stopProgressIndicator(`No updates need to be applied`, 'success');\n }\n return updates;\n}\n\n/**\n * Apply updates\n * @param {boolean} wait wait for the operation to complete or not\n * @param {number} timeout timeout in milliseconds\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function applyUpdates(wait: boolean, timeout = 10 * 60 * 1000) {\n createProgressIndicator(undefined, `Applying updates...`, 'indeterminate');\n try {\n let status = await initiateRestart();\n if (wait) {\n const start = new Date().getTime();\n let runtime = 0;\n while (\n status !== RestartStatus.ready &&\n start + timeout > new Date().getTime()\n ) {\n
|
|
1
|
+
{"version":3,"file":"StartupOps.js","names":["checkForUpdates","updates","secrets","variables","createProgressIndicator","undefined","getSecrets","result","filter","secret","loaded","getVariables","variable","error","stopProgressIndicator","response","data","code","message","updateCount","length","applyUpdates","wait","timeout","status","initiateRestart","start","Date","getTime","runtime","errors","maxErrors","RestartStatus","ready","Promise","resolve","setTimeout","getStatus","updateProgressIndicator","Math","round"],"sources":["ops/cloud/StartupOps.ts"],"sourcesContent":["import {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getSecrets } from '../../api/cloud/SecretsApi';\nimport {\n getStatus,\n initiateRestart,\n RestartStatus,\n} from '../../api/cloud/StartupApi';\nimport { getVariables } from '../../api/cloud/VariablesApi';\n\n/**\n * Updates that need to be applied.\n */\nexport interface Updates {\n /**\n * Array of secrets that need applying\n */\n secrets?: unknown[];\n /**\n * Array of variables that need applying\n */\n variables?: unknown[];\n}\n\n/**\n * Check for updates that need applying\n * @returns {Promise<boolean>} true if there are updates that need to be applied, false otherwise\n */\nexport async function checkForUpdates(): Promise<Updates> {\n const updates: Updates = { secrets: [], variables: [] };\n createProgressIndicator(\n undefined,\n `Checking for updates to apply...`,\n 'indeterminate'\n );\n try {\n updates.secrets = (await getSecrets()).result.filter(\n (secret: { loaded: unknown }) => !secret.loaded\n );\n updates.variables = (await getVariables()).result.filter(\n (variable: { loaded: unknown }) => !variable.loaded\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n const updateCount = updates.secrets?.length + updates.variables?.length || 0;\n if (updateCount > 0) {\n stopProgressIndicator(\n `${updateCount} update(s) need to be applied`,\n 'success'\n );\n } else {\n stopProgressIndicator(`No updates need to be applied`, 'success');\n }\n return updates;\n}\n\n/**\n * Apply updates\n * @param {boolean} wait wait for the operation to complete or not\n * @param {number} timeout timeout in milliseconds\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function applyUpdates(wait: boolean, timeout = 10 * 60 * 1000) {\n createProgressIndicator(undefined, `Applying updates...`, 'indeterminate');\n try {\n let status = await initiateRestart();\n if (wait) {\n const start = new Date().getTime();\n let runtime = 0;\n let errors = 0;\n const maxErrors = 3;\n while (\n status !== RestartStatus.ready &&\n start + timeout > new Date().getTime()\n ) {\n await new Promise((resolve) => setTimeout(resolve, 5000));\n try {\n status = await getStatus();\n\n // reset errors after successful status call\n if (errors) errors = 0;\n\n runtime = new Date().getTime() - start;\n updateProgressIndicator(`${status} (${Math.round(runtime / 1000)}s)`);\n } catch (error) {\n errors++;\n if (errors > maxErrors) {\n throw error;\n }\n runtime = new Date().getTime() - start;\n updateProgressIndicator(\n `${error.message} - retry ${errors}/${maxErrors} (${Math.round(\n runtime / 1000\n )}s)`\n );\n }\n }\n if (runtime < timeout) {\n stopProgressIndicator(\n `Updates applied in ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n `Updates timed out after ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'warn'\n );\n return false;\n }\n } else {\n stopProgressIndicator(\n `Updates are being applied. Changes may take up to 10 minutes to propagate, during which time you will not be able to make further updates.`,\n 'success'\n );\n return true;\n }\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response?.data?.code || error} - ${\n error.response?.data?.message\n }`,\n 'fail'\n );\n return false;\n }\n}\n"],"mappings":";;;;;;;AAAA;AAKA;AACA;AAKA;AAA4D;AAAA;AAgB5D;AACA;AACA;AACA;AAHA,SAIsBA,eAAe;EAAA;AAAA;AAgCrC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,qCAhCO,aAAmD;IAAA;IACxD,IAAMC,OAAgB,GAAG;MAAEC,OAAO,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAG,CAAC;IACvD,IAAAC,gCAAuB,EACrBC,SAAS,sCAET,eAAe,CAChB;IACD,IAAI;MACFJ,OAAO,CAACC,OAAO,GAAG,OAAO,IAAAI,sBAAU,GAAE,EAAEC,MAAM,CAACC,MAAM,CACjDC,MAA2B,IAAK,CAACA,MAAM,CAACC,MAAM,CAChD;MACDT,OAAO,CAACE,SAAS,GAAG,OAAO,IAAAQ,0BAAY,GAAE,EAAEJ,MAAM,CAACC,MAAM,CACrDI,QAA6B,IAAK,CAACA,QAAQ,CAACF,MAAM,CACpD;IACH,CAAC,CAAC,OAAOG,KAAK,EAAE;MACd,IAAAC,8BAAqB,mBACTD,KAAK,CAACE,QAAQ,CAACC,IAAI,CAACC,IAAI,gBAAMJ,KAAK,CAACE,QAAQ,CAACC,IAAI,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K,CAACX,OAAO,GAAG,IAAI,CAAC,QAAK;UACvE,CAAC,CAAC,OAAOhB,KAAK,EAAE;YACdiB,MAAM,EAAE;YACR,IAAIA,MAAM,GAAGC,SAAS,EAAE;cACtB,MAAMlB,KAAK;YACb;YACAgB,OAAO,GAAG,IAAIF,IAAI,EAAE,CAACC,OAAO,EAAE,GAAGF,KAAK;YACtC,IAAAY,gCAAuB,YAClBzB,KAAK,CAACK,OAAO,sBAAYY,MAAM,cAAIC,SAAS,eAAKQ,IAAI,CAACC,KAAK,CAC5DX,OAAO,GAAG,IAAI,CACf,QACF;UACH;QACF;QACA,IAAIA,OAAO,GAAGN,OAAO,EAAE;UACrB,IAAAT,8BAAqB,+BACGyB,IAAI,CAACC,KAAK,CAC9BX,OAAO,GAAG,IAAI,CACf,kCAAwBL,MAAM,GAC/B,SAAS,CACV;UACD,OAAO,IAAI;QACb,CAAC,MAAM;UACL,IAAAV,8BAAqB,oCACQyB,IAAI,CAACC,KAAK,CACnCX,OAAO,GAAG,IAAI,CACf,kCAAwBL,MAAM,GAC/B,MAAM,CACP;UACD,OAAO,KAAK;QACd;MACF,CAAC,MAAM;QACL,IAAAV,8BAAqB,gJAEnB,SAAS,CACV;QACD,OAAO,IAAI;MACb;IACF,CAAC,CAAC,OAAOD,KAAK,EAAE;MAAA;MACd,IAAAC,8BAAqB,mBACT,oBAAAD,KAAK,CAACE,QAAQ,4EAAd,gBAAgBC,IAAI,yDAApB,qBAAsBC,IAAI,KAAIJ,KAAK,oCAC3CA,KAAK,CAACE,QAAQ,8EAAd,iBAAgBC,IAAI,0DAApB,sBAAsBE,OAAO,GAE/B,MAAM,CACP;MACD,OAAO,KAAK;IACd;EACF,CAAC;EAAA;AAAA"}
|
|
@@ -46,13 +46,25 @@ export async function applyUpdates(wait, timeout = 10 * 60 * 1000) {
|
|
|
46
46
|
if (wait) {
|
|
47
47
|
const start = new Date().getTime();
|
|
48
48
|
let runtime = 0;
|
|
49
|
+
let errors = 0;
|
|
50
|
+
const maxErrors = 3;
|
|
49
51
|
while (status !== RestartStatus.ready && start + timeout > new Date().getTime()) {
|
|
50
|
-
// eslint-disable-next-line no-await-in-loop, no-promise-executor-return
|
|
51
52
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
try {
|
|
54
|
+
status = await getStatus();
|
|
55
|
+
|
|
56
|
+
// reset errors after successful status call
|
|
57
|
+
if (errors) errors = 0;
|
|
58
|
+
runtime = new Date().getTime() - start;
|
|
59
|
+
updateProgressIndicator(`${status} (${Math.round(runtime / 1000)}s)`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
errors++;
|
|
62
|
+
if (errors > maxErrors) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
runtime = new Date().getTime() - start;
|
|
66
|
+
updateProgressIndicator(`${error.message} - retry ${errors}/${maxErrors} (${Math.round(runtime / 1000)}s)`);
|
|
67
|
+
}
|
|
56
68
|
}
|
|
57
69
|
if (runtime < timeout) {
|
|
58
70
|
stopProgressIndicator(`Updates applied in ${Math.round(runtime / 1000)}s with final status: ${status}`, 'success');
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ops/cloud/StartupOps.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CA8BxD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,SAAiB,
|
|
1
|
+
{"version":3,"sources":["../src/ops/cloud/StartupOps.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CA8BxD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,SAAiB,oBAoEzE","file":"StartupOps.d.ts","sourcesContent":["import {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getSecrets } from '../../api/cloud/SecretsApi';\nimport {\n getStatus,\n initiateRestart,\n RestartStatus,\n} from '../../api/cloud/StartupApi';\nimport { getVariables } from '../../api/cloud/VariablesApi';\n\n/**\n * Updates that need to be applied.\n */\nexport interface Updates {\n /**\n * Array of secrets that need applying\n */\n secrets?: unknown[];\n /**\n * Array of variables that need applying\n */\n variables?: unknown[];\n}\n\n/**\n * Check for updates that need applying\n * @returns {Promise<boolean>} true if there are updates that need to be applied, false otherwise\n */\nexport async function checkForUpdates(): Promise<Updates> {\n const updates: Updates = { secrets: [], variables: [] };\n createProgressIndicator(\n undefined,\n `Checking for updates to apply...`,\n 'indeterminate'\n );\n try {\n updates.secrets = (await getSecrets()).result.filter(\n (secret: { loaded: unknown }) => !secret.loaded\n );\n updates.variables = (await getVariables()).result.filter(\n (variable: { loaded: unknown }) => !variable.loaded\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n const updateCount = updates.secrets?.length + updates.variables?.length || 0;\n if (updateCount > 0) {\n stopProgressIndicator(\n `${updateCount} update(s) need to be applied`,\n 'success'\n );\n } else {\n stopProgressIndicator(`No updates need to be applied`, 'success');\n }\n return updates;\n}\n\n/**\n * Apply updates\n * @param {boolean} wait wait for the operation to complete or not\n * @param {number} timeout timeout in milliseconds\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function applyUpdates(wait: boolean, timeout = 10 * 60 * 1000) {\n createProgressIndicator(undefined, `Applying updates...`, 'indeterminate');\n try {\n let status = await initiateRestart();\n if (wait) {\n const start = new Date().getTime();\n let runtime = 0;\n let errors = 0;\n const maxErrors = 3;\n while (\n status !== RestartStatus.ready &&\n start + timeout > new Date().getTime()\n ) {\n await new Promise((resolve) => setTimeout(resolve, 5000));\n try {\n status = await getStatus();\n\n // reset errors after successful status call\n if (errors) errors = 0;\n\n runtime = new Date().getTime() - start;\n updateProgressIndicator(`${status} (${Math.round(runtime / 1000)}s)`);\n } catch (error) {\n errors++;\n if (errors > maxErrors) {\n throw error;\n }\n runtime = new Date().getTime() - start;\n updateProgressIndicator(\n `${error.message} - retry ${errors}/${maxErrors} (${Math.round(\n runtime / 1000\n )}s)`\n );\n }\n }\n if (runtime < timeout) {\n stopProgressIndicator(\n `Updates applied in ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n `Updates timed out after ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'warn'\n );\n return false;\n }\n } else {\n stopProgressIndicator(\n `Updates are being applied. Changes may take up to 10 minutes to propagate, during which time you will not be able to make further updates.`,\n 'success'\n );\n return true;\n }\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response?.data?.code || error} - ${\n error.response?.data?.message\n }`,\n 'fail'\n );\n return false;\n }\n}\n"]}
|