From 1ee9a6828895856c446dd82481b15bf0a544c7a4 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Tue, 17 Sep 2024 08:10:02 -0400 Subject: [PATCH] Update device.overall_status comments with their respective replacements Changelog-entry: Rename `device.overall_status` values: `IDLE` to `OPERATIONAL`, `OFFLINE` to `DISCONNECTED`; add `REDUCED_FUNCTIONALITY` Change-type: major --- src/commands/device/restart.ts | 2 +- src/utils/patterns.ts | 6 ++++-- tests/commands/device/ssh.spec.ts | 2 +- tests/test-data/api-response/device-missing-app.json | 2 +- tests/test-data/api-response/device-missing-fields.json | 2 +- tests/test-data/api-response/device-status.json | 2 +- tests/test-data/api-response/device-types-GET-v1.json | 4 ++-- tests/test-data/api-response/device.json | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/commands/device/restart.ts b/src/commands/device/restart.ts index 92d1d90d..082ca041 100644 --- a/src/commands/device/restart.ts +++ b/src/commands/device/restart.ts @@ -156,7 +156,7 @@ export default class DeviceRestartCmd extends Command { async restartAllServices(balena: BalenaSDK, deviceUuid: string) { // Note: device.restartApplication throws `BalenaDeviceNotFound: Device not found` if device not online. - // Need to use device.get first to distinguish between non-existant and offline devices. + // Need to use device.get first to distinguish between non-existant and disconnected devices. // Remove this workaround when SDK issue resolved: https://github.com/balena-io/balena-sdk/issues/649 const { instanceOf, ExpectedError } = await import('../../errors'); try { diff --git a/src/utils/patterns.ts b/src/utils/patterns.ts index 6dcbc516..1ea2cafd 100644 --- a/src/utils/patterns.ts +++ b/src/utils/patterns.ts @@ -319,7 +319,7 @@ export async function awaitDeviceOsUpdate( } if (osUpdateProgress !== null) { - // Avoid resetting to 0% at end of process when device goes offline. + // Avoid resetting to 0% at end of process when device goes disconnected. progressBar.update({ percentage: osUpdateProgress }); } @@ -358,7 +358,9 @@ export async function getOnlineTargetDeviceUuid( }); if (!device.is_online) { - throw new ExpectedError(`Device with UUID ${fleetOrDevice} is offline`); + throw new ExpectedError( + `Device with UUID ${fleetOrDevice} is disconnected`, + ); } return device.uuid; diff --git a/tests/commands/device/ssh.spec.ts b/tests/commands/device/ssh.spec.ts index 94534b77..0da4caf5 100644 --- a/tests/commands/device/ssh.spec.ts +++ b/tests/commands/device/ssh.spec.ts @@ -121,7 +121,7 @@ describe('balena device ssh', function () { itSS('should fail if device not online (mocked, device UUID)', async () => { const deviceUUID = 'abc1234'; - const expectedErrLines = ['Device with UUID abc1234 is offline']; + const expectedErrLines = ['Device with UUID abc1234 is disconnected']; api.expectGetWhoAmI({ optional: true, persist: true }); api.expectGetDevice({ fullUUID: deviceUUID, isOnline: false }); mockedExitCode = 0; diff --git a/tests/test-data/api-response/device-missing-app.json b/tests/test-data/api-response/device-missing-app.json index 69bde5fd..7a2d8411 100644 --- a/tests/test-data/api-response/device-missing-app.json +++ b/tests/test-data/api-response/device-missing-app.json @@ -15,7 +15,7 @@ "os_version": "balenaOS 2.44.0+rev3", "supervisor_version": "10.3.7", "is_web_accessible": false, - "overall_status": "idle", + "overall_status": "reduced-functionality", "cpu_usage": 34, "cpu_temp": 56.2, "cpu_id": "some cpu id", diff --git a/tests/test-data/api-response/device-missing-fields.json b/tests/test-data/api-response/device-missing-fields.json index 71995cc4..ab52e340 100644 --- a/tests/test-data/api-response/device-missing-fields.json +++ b/tests/test-data/api-response/device-missing-fields.json @@ -21,7 +21,7 @@ "os_version": "balenaOS 2.44.0+rev3", "supervisor_version": "10.3.7", "is_web_accessible": false, - "overall_status": "offline", + "overall_status": "disconnected", "__metadata": { "uri": "/resin/device(@id)?@id=1747415" } diff --git a/tests/test-data/api-response/device-status.json b/tests/test-data/api-response/device-status.json index 643f64c8..4dff4953 100644 --- a/tests/test-data/api-response/device-status.json +++ b/tests/test-data/api-response/device-status.json @@ -1,7 +1,7 @@ { "d": [ { - "overall_status": "offline", + "overall_status": "disconnected", "__metadata": {} } ] diff --git a/tests/test-data/api-response/device-types-GET-v1.json b/tests/test-data/api-response/device-types-GET-v1.json index ea84e934..dd275864 100644 --- a/tests/test-data/api-response/device-types-GET-v1.json +++ b/tests/test-data/api-response/device-types-GET-v1.json @@ -4073,7 +4073,7 @@ "state": "DISCONTINUED", "stateInstructions": { "postProvisioning": [ - "The device is performing a shutdown. Please wait until the device is offline in the dashboard and disconnect the power cable.", + "The device is performing a shutdown. Please wait until the device is disconnected in the dashboard and disconnect the power cable.", "Remove the resinOS installation media.", "Set J11 (just next to the micro SD card slot) to position 1-2 (the position closest to the edge of the board).", "Remove and re-connect power to the board." @@ -4084,7 +4084,7 @@ "Insert the freshly burnt SD card into the VIA VAB 820-quad.", "Warning! This will also completely erase internal storage media, so please make a backup first.", "Set J11 (just next to the micro SD card slot) to position 2-3 (the position furthest away from the edge of the board) and then power on the board.", - "The device is performing a shutdown. Please wait until the device is offline in the dashboard and disconnect the power cable.", + "The device is performing a shutdown. Please wait until the device is disconnected in the dashboard and disconnect the power cable.", "Remove the resinOS installation media.", "Set J11 (just next to the micro SD card slot) to position 1-2 (the position closest to the edge of the board).", "Remove and re-connect power to the board." diff --git a/tests/test-data/api-response/device.json b/tests/test-data/api-response/device.json index 75de86b6..d5c508c7 100644 --- a/tests/test-data/api-response/device.json +++ b/tests/test-data/api-response/device.json @@ -27,7 +27,7 @@ "os_version": "balenaOS 2.44.0+rev3", "supervisor_version": "10.3.7", "is_web_accessible": false, - "overall_status": "offline", + "overall_status": "disconnected", "cpu_usage": 34, "cpu_temp": 56.2, "cpu_id": "some cpu id",