Commit Graph

4678 Commits

Author SHA1 Message Date
Balena CI
d3be730c8e
v14.10.7 2023-04-21 23:04:21 +00:00
flowzone-app[bot]
48951d0333
Merge pull request #2153 from balena-os/local-mode
Refactor state engine to be able to use current state as target
2023-04-21 23:03:37 +00:00
Felipe Lalanne
6c031299d6 Remove safeStateClone function
This function is no longer needed with the latest changes to
getCurrentState

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
36311ef7a1 Get rid of targetVolatile in app manager
Target volatile doesn't make sense now that we can use the
current state as a target. It wasn't actually being used for anything
anymore apparently

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
1e0dd381f5 Make pausingApply a private member of device-state
This simplifies this module interface and hides implementation details
from the rest of the code.

The function `applyIntermediateTarget` will now call `pausingApply`
before applying the target

API actions no longer need to call pausing apply

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
3d43f7e3b3 Simplify doRestart and doPurge actions
The actions now work by passing an intermediate state to the state
engine.

- doPurge first removes the user app from the target state and passes
  that to the state engine for purging. Since intermediate state doesn't
  remove images, this will have the effect of basically re-installing
  the app.

- doRestart modifies the target state by first removing only the
  services from the current state but keeping volumes and networks. This
  has the same effect as before where services were stopped one by one

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
43630e5267 Fix network appUuid inference in local mode
Local mode uses a numeric `appUuid` which was messing up parsing the
network name. This fixes this issue so the current state can be used
as a target state

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
b1fc4e1761 Get image name from DB when getting the app current state
The Service class in `compose/service.ts` cannot get the image name
from the image id when building the object from the container metadata.

We query the metadata in the application manager getCurrentApps method
so the current state can be used as target by API methods

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
27f0d2e655 Improve net alias comparison to prevent unwanted restarts
Network aliases are now compared checking that the target state is a
subset of the current state. This will prevent service restarts due to
additional aliases created by docker in the container.

Closes: #2134
Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
cb98133717 Exclude containerId from service network aliases
When getting the service from the docker container, remove the
containerId from the list of aliases (which gets added by docker). This
will make it easier to use the current service state as a target.

This will help us remove the `safeStateClone` function in the API in a
future commit

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
f2ca7dbb6a Skip image delete when applying intermediate state
This replaces the previous flag `isApplyingIntermediate` on application
manager and simplifies the interface of the state engine to make temporary changes to the
general app state.

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
967cb7747f Make local mode image management work as in cloud mode
There were multiple places in the state engine that skipped some
operations while in local mode. In reality, all it's needed while in
local mode is to skip image and volume deletion.

This commit simplifies application-manager and compose app to be more
local mode agnostic and instead making the image deletion and volume
deletion configurable via function arguments.

This also has the benefit to make the treatment of local mode
applications more similar to cloud mode applications, allowing for
API endpoints to function the same way both modes.

Change-type: patch
2023-04-20 14:58:58 -04:00
Felipe Lalanne
76d5be64e5 Remove ignoreImages argument from getRequiredSteps
The argument was unused and hence unnecesary. This is just a bit of
cleanup

Change-type: patch
2023-04-20 14:58:58 -04:00
Balena CI
835bf9e49b
v14.10.6 2023-04-20 18:25:02 +00:00
flowzone-app[bot]
a9e4bee68e
Merge pull request #2162 from balena-os/host-config-hostname
Do not restart balena-hostname on rename
2023-04-20 18:24:17 +00:00
Felipe Lalanne
7b68ee4c4f Do not restart balena-hostname on rename
The OS since v2.82.6 will monitor changes to config.json and restart
the relevant services to apply the changes. There is no need to trigger
restart of the services via the supervisor. Users on older OS versions
will need to update their OS or restart the services manually as OS
loses support after 2y.

Change-type: patch
Closes: #2160
2023-04-20 11:43:35 -04:00
Balena CI
e36060aa29
v14.10.5 2023-04-13 21:01:23 +00:00
Christina Wang
31e80f8c60
Merge pull request #2158 from balena-os/remove-anon-build-volume-plus-misc-docker-test-command-changes
Remove anon build volume plus misc docker test command changes
2023-04-13 14:00:29 -07:00
Christina Ying Wang
9431ffc780 Use simpler command for docker compose test volume removal
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-04-11 13:05:44 -07:00
Christina Ying Wang
6a2ccf4007 Remove dind tmpfs in test env
It wasn't changing anything in the test process, so this was a mistake to add.

Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-04-11 13:05:20 -07:00
Christina Ying Wang
a367565189 Remove anonymous build volume from Dockerfile
We don't need this anonymous volume as /data is bind mounted into
the container from host (legacy), and will soon be mounted by the
Supervisor itself on startup.

Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-04-11 13:04:36 -07:00
Balena CI
66cbe53b03
v14.10.4 2023-04-10 18:15:44 +00:00
flowzone-app[bot]
8259dae691
Merge pull request #2154 from balena-os/log-uncaught-exceptions
Log uncaught promise exceptions on the app entry
2023-04-10 18:14:37 +00:00
Felipe Lalanne
6764641426 Log uncaught promise exceptions on the app entry
Node 15 [changed the way it treats unhandled promise rejections](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V15.md#throw-on-unhandled-rejections---33021) from a warning to a throw.
For this reason errors like a corrupt migration directory, that happens when trying to
roll back to a previous supervisor version were no longer showing a
message but dumping the full minimized code into the journal logs.

This PR adds a catchall on app.ts to log the exception and throw an exit
code of 1.

Change-type: patch
2023-04-10 11:18:35 -04:00
Balena CI
447cb0109b
v14.10.3 2023-04-10 15:18:01 +00:00
Felipe Lalanne
06f764ad77
Merge pull request #2157 from balena-os/api-integration-test-restart-timeout-fix
Fix assertion error in restart-service
2023-04-10 10:17:06 -05:00
Christina Ying Wang
b9e1464d96 Fix assertion error in restart-service
From: c0b4fafe84
Restart-service checks that both services have restarted in its test assertion, which is
incorrect as restart-service should only restart one service.

Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-04-07 14:40:15 -07:00
Balena CI
5e0509910f
v14.10.2 2023-04-07 18:35:19 +00:00
flowzone-app[bot]
e468eed4c5
Merge pull request #2155 from balena-os/add_orin_nx_custom_dtb
backends: Add Jetson Orin NX custom device-tree support
2023-04-07 18:34:37 +00:00
Alexandru Costache
6b67db98e5 backends: Add Jetson Orin NX custom device-tree support
Signed-off-by: Alexandru Costache <alexandru@balena.io>
Change-type: patch
2023-04-07 18:12:31 +03:00
Balena CI
da15bc3c63
v14.10.1 2023-04-07 00:16:01 +00:00
flowzone-app[bot]
d0d726ceb5
Merge pull request #2151 from balena-os/2150-mount-partitions-gpt-fix
Fix partition mounting for GPT partitioned disks
2023-04-07 00:15:14 +00:00
Christina Ying Wang
4ab8250c97 Use dbus-send to get current boot block device instead of fdisk
Closes: #2150
Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-04-06 12:34:00 -07:00
Balena CI
980c838e44
v14.10.0 2023-03-28 19:13:51 +00:00
Christina Wang
bd351a273e
Merge pull request #2120 from balena-os/mount-host-partitions-in-entry
Mount host partitions into container on Supervisor start
2023-03-28 12:13:03 -07:00
Christina Ying Wang
4c948c8854 Mount data and state partitions on container startup
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-03-27 12:07:01 -07:00
Christina Ying Wang
49ee1042a8 Mount boot partition into container on Supervisor start
As the Supervisor is a privileged container, it has access to host /dev, and therefore has access
to boot, data, and state balenaOS partitions. This commit sets up the framework for the following:

- Finds the /dev partition that corresponds to each partition based on partition label
- Mounts the partitions into set mountpoints in the device
- Removes reliance on env vars and mountpoints provided by host's start-balena-supervisor script
- Simplifies host path querying by centralizing these queries through methods in lib/host-utils.ts

This particular changes env vars for and mounts the boot partition.

Since the Supervisor would no longer rely on container `run` arguments provided by a host script,
this change moves Supervisor closer to being able to start itself (Supervisor-as-an-app).

Change-type: minor
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-03-27 12:07:01 -07:00
Christina Ying Wang
9522c15ecd Change constants imports to remove 'require'
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-03-27 12:07:01 -07:00
Balena CI
07b8d44545
v14.9.8 2023-03-27 08:05:46 +00:00
Christina Wang
912a2eccbd
Merge pull request #2147 from balena-os/supervisor-revert-multiarch
Revert "Use multi-arch in dockerfile"
2023-03-27 01:04:54 -07:00
Felipe Lalanne
75eeac5ed4 Revert "Use multi-arch in dockerfile"
This reverts commit 00e389e5f5.

Images generated using this dockerfile still don't have the right
architecture. More testing is needed

Change-type: patch
2023-03-24 18:27:58 -03:00
Balena CI
9304a9215d
v14.9.7 2023-03-23 21:40:33 +00:00
Christina Wang
1d8844c4a6
Merge pull request #2145 from balena-os/add-missing-log-backend-reference
Add missing log backend field assignment in logger init
2023-03-23 14:39:48 -07:00
Christina Ying Wang
37371d89dc Add missing log backend field assignment in logger init
Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-03-23 14:07:35 -07:00
Balena CI
7bc89faf12
v14.9.6 2023-03-23 20:18:33 +00:00
Felipe Lalanne
375087ee42
Merge pull request #2141 from balena-os/dockerfile-platform
Use multi-arch in dockerfile
2023-03-23 15:17:49 -05:00
Felipe Lalanne
7cde98d7f7 Update deploy-to-balena action to 0.26.2
Change-type: patch
2023-03-22 21:47:48 -03:00
Felipe Lalanne
00e389e5f5 Use multi-arch in dockerfile
This is necessary since the builder no longer passes the platform flag
to the build. This would lead to dockerfiles that are mixing multi and single
arch stages to pull the wrong architecture images, particularly when
trying to build images in emulated builds (e.g. armv7hf built on aarch64).

Moving the full build to multi-arch solves this as the docker engine is
capable of chosing the right architecture from the manifest.

Relatest-to: balena-io/balena-builder#1010
Change-type: patch
2023-03-22 19:50:31 -03:00
Balena CI
b55964e207
v14.9.5 2023-03-20 19:21:49 +00:00
Christina Wang
4c369785e7
Merge pull request #2140 from balena-os/move-log-stream-to-subdomain
Use log endpoint subdomain if it exists in config.json
2023-03-20 12:21:01 -07:00