Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsreds/add device is pined on release 3 #1698

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/balena-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ CREATE INDEX IF NOT EXISTS "device_device_type_idx"
ON "device" ("is of-device type");
CREATE INDEX IF NOT EXISTS "device_is_running_release_idx"
ON "device" ("is running-release");
-- Also optimizes should be running successful release rule
-- TODO: remove device_should_be_running_release_application_idx as soon as the is_pinned_on_release migration is ended
CREATE INDEX IF NOT EXISTS "device_should_be_running_release_application_idx"
ON "device" ("should be running-release", "belongs to-application");
-- Also optimizes is pinned on successful release rule
CREATE INDEX IF NOT EXISTS "device_is_pinned_on_release_application_idx"
ON "device" ("is pinned on-release", "belongs to-application");
Expand Down
7 changes: 0 additions & 7 deletions src/balena-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,6 @@ export interface Device {
| [ServiceInstance['Read']]
| []
| null;
should_be_running__release:
| { __id: Release['Read']['id'] }
| [Release['Read']]
| []
| null;
is_pinned_on__release:
| { __id: Release['Read']['id'] }
| [Release['Read']]
Expand Down Expand Up @@ -811,7 +806,6 @@ export interface Device {
api_port: Types['Integer']['Write'] | null;
api_secret: Types['Short Text']['Write'] | null;
is_managed_by__service_instance: ServiceInstance['Write']['id'] | null;
should_be_running__release: Release['Write']['id'] | null;
is_pinned_on__release: Release['Write']['id'] | null;
should_be_operated_by__release: Release['Write']['id'] | null;
should_be_managed_by__release: Release['Write']['id'] | null;
Expand Down Expand Up @@ -1019,7 +1013,6 @@ export interface Release {
release_image?: Array<ImageIsPartOfRelease['Read']>;
contains__image?: Array<ImageIsPartOfRelease['Read']>;
should_be_running_on__application?: Array<Application['Read']>;
should_be_running_on__device?: Array<Device['Read']>;
is_running_on__device?: Array<Device['Read']>;
is_pinned_to__device?: Array<Device['Read']>;
should_operate__device?: Array<Device['Read']>;
Expand Down
3 changes: 0 additions & 3 deletions src/balena.sbvr
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,6 @@ Fact type: device has api secret
Fact type: device is managed by service instance
Synonymous Form: service instance manages device
Necessity: each device is managed by at most one service instance
Fact type: device should be running release
Synonymous Form: release should be running on device
Necessity: each device should be running at most one release
Fact type: device is pinned on release
Synonymous Form: release is pinned to device
Necessity: each device is pinned on at most one release
Expand Down
20 changes: 0 additions & 20 deletions src/features/devices/hooks/defaults-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
};

hooks.addPureHook('POST', 'resin', 'device', {
POSTPARSE: async ({ request }) => {

Check warning on line 11 in src/features/devices/hooks/defaults-validation.ts

View workflow job for this annotation

GitHub Actions / Flowzone / Test npm (22.x)

Async method 'POSTPARSE' has no 'await' expression
// Check for extra whitespace characters
if (
request.values.device_name != null &&
Expand All @@ -29,21 +29,11 @@
'Device UUID must be a 32 or 62 character long lower case hex string.',
);
}

// TODO[device management next step]: Drop this after re-migrating all data on step 2:
if (request.values.is_pinned_on__release !== undefined) {
// Add an async boundary so that value updates,
// and doesn't remove the properties that we add.
// eslint-disable-next-line @typescript-eslint/await-thenable
await null;
request.values.should_be_running__release =
request.values.is_pinned_on__release;
}
},
});

hooks.addPureHook('PATCH', 'resin', 'device', {
POSTPARSE: async ({ request }) => {

Check warning on line 36 in src/features/devices/hooks/defaults-validation.ts

View workflow job for this annotation

GitHub Actions / Flowzone / Test npm (22.x)

Async method 'POSTPARSE' has no 'await' expression
// Check for extra whitespace characters
if (
request.values.device_name != null &&
Expand Down Expand Up @@ -83,15 +73,5 @@
if (request.values.is_online != null) {
request.values.last_connectivity_event = new Date();
}

// TODO[device management next step]: Drop this after re-migrating all data on step 2:
if (request.values.is_pinned_on__release !== undefined) {
// Add an async boundary so that value updates,
// and doesn't remove the properties that we add.
// eslint-disable-next-line @typescript-eslint/await-thenable
await null;
request.values.should_be_running__release =
request.values.is_pinned_on__release;
}
},
});
Loading