Commit Graph

4493 Commits

Author SHA1 Message Date
Felipe Lalanne
ba39cf539e Update table formatting on configurations.md
For better readability on text editor

Change-type: patch
2023-05-08 15:15:37 -04:00
Balena CI
6148ed6ed1
v14.10.10 2023-05-03 16:01:39 +00:00
flowzone-app[bot]
4087782e80
Merge pull request #2165 from balena-os/mtoman/detect-crypt-mounts
mount-partitions.sh: Add support for encrypted partitions
2023-05-03 16:00:51 +00:00
Michal Toman
0045928944 mount-partitions.sh: Add support for encrypted partitions
After a recent change enforcing all the partitions to be on the same
block device, encrypted partitions are no longer being detected
correctly. This is because the assumption that the parent block device
is a substring of the actually mounted block device does not work
for LUKS devices - the mount will either be /dev/mapper/luks-XXX
or /dev/dm-X while the parent device is still e.g. /dev/sda.

The usual balenaOS boot partition is also split in two - boot and efi.
The boot partition (mounted under /mnt/boot) is encrypted and the efi
partition (mounted under /mnt/efi) is not.

This patch generalizes the detection of the parent device so that
it works with both encrypted and unencrypted partitions.

Change-type: patch
Signed-off-by: Michal Toman <michalt@balena.io>
2023-05-03 16:29:16 +02:00
Balena CI
c8d7b28a7e
v14.10.9 2023-05-03 14:26:38 +00:00
flowzone-app[bot]
cf21b093a6
Merge pull request #2164 from balena-os/klutchell-patch-1
Run test supervisor under a different service name
2023-05-03 14:25:58 +00:00
Kyle Harding
33b29cfa22
Run test supervisor under a different service name
The docker compose V2 spec no longer accepts `network_mode: bridge`,
which means we can no longer override the network configuration of
the `balena-supervisor` service for tests.

For this reason we now create a separate service to run the built
supervisor `balena-supervisor-sut` and run API tests against this
service instead of the default `balena-supervisor`.

Change-type: patch
2023-05-03 09:33:22 -04:00
Balena CI
f6e0683032
v14.10.8 2023-04-26 18:49:44 +00:00
flowzone-app[bot]
bc969c8c89
Merge pull request #2161 from balena-os/network-plus-service-bug
Fix device state not applied when a network change happens during the update
2023-04-26 18:48:55 +00:00
Felipe Lalanne
5fdd689590 Fix service comparison when creating component steps
A bug in service comparison would make it that a device already running
a service from a new release with network changes would never stop the
running service so remaining services would forever get stuck in
`Downloaded` state.

This fixes the comparison so the service will get killed in this case,
particularly allowing devices to recover from #1576

Change-type: patch
2023-04-26 11:58:48 -04:00
Felipe Lalanne
7b8b187c74 Create tests with recovery from #1576
Devices affected by the bug described in 1576, are also stuck with some
services in the `Downloaded` state, because the state engine does not
detect that the running services should be killed on a network change
even if they belong to a new release. This is a bug, which can be
replicated by the tests in this commit

Change-type: patch
2023-04-26 11:58:42 -04:00
Felipe Lalanne
7aecaae8b0 Skip updateMetadata step if there are network changes
Previous behavior would make it that an `updateMetadata` step would take
precedence over a `kill` step when network changes are present. This
would lead to an inconsistent state if an update included a
network and a container change.

Closes: #1576
Change-type: patch
2023-04-25 14:47:00 -04:00
Felipe Lalanne
0a358a4463 Add replication of issue using unit tests
Change-type: patch
2023-04-25 14:47:00 -04:00
Felipe Lalanne
138aec5de4 Add integration tests for state-engine
These tests use the supervisor API to check that applying a target state
allows the device to eventually get to the desired target configuration.

This are high-level tests that work with real images and containers
using dind.

Change-type: patch
2023-04-25 14:47:00 -04:00
Felipe Lalanne
c1207cbbff Do not pass auth to images with no registry
The supervisor allows the target image to be an image without a
registry (e.g. `alpine:latest`), while this really only happens while in
local mode, we don't want to pass credentials to the default registry as
those credentials are meant for balena registry and will otherwise fail.

Change-type: patch
2023-04-25 14:47:00 -04:00
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