Commit Graph

3881 Commits

Author SHA1 Message Date
Felipe Lalanne
8bf8792583 Only uninstall 'fleet' apps when localMode is set
Local mode is still a device level config. Eventually it will become a
property of an app, but for now, we don't want the supervisor trying to
uninstall supervisor or host app when local mode is set
2022-03-22 19:28:43 -03:00
Felipe Lalanne
f1cd3d367c Cleanup unused methods and dependencies on db ids 2022-03-22 19:28:43 -03:00
Felipe Lalanne
381abeadb9 Refactor current state report to patch v3 state
This change makes the `api-binder/report` module more agnostic
to internal device state implementation details, moving necessary
healthchecks and data filtering to getCurrentForReport in device-state.

This also adds generic functions to perform comparison between current
state reports.
2022-03-22 19:28:36 -03:00
Felipe Lalanne
25e9ab4786 Refactor api-binder as a directory
The role of the api-binder module is to be the intermediary
between the cloud API and the device-state. For this reason it makes sense to
isolate target state retrieval and current state reporting into this
module. This change just moves current state reporting to the directory.
2022-03-22 19:08:03 -03:00
Felipe Lalanne
97f3b2a51e Update types and create methods for reporting v3 state 2022-03-22 19:08:03 -03:00
Felipe Lalanne
e9af9d8e83 Allow application manager to match apps between environments
If an app with the same app uuid exists between environments, the
supervisor will match the apps by uuid to prevent stopping the running
app
2022-03-22 19:08:03 -03:00
Felipe Lalanne
5c5483dd3d Rename networks to <appUuid>_<networkName>
This is required as we are phasing out app ids and we need to be able to
get app uuid from the current state of the network. The app-id now
exists as a container in new networks

This commit will restart containers as it needs to recreate the network.
2022-03-22 19:08:03 -03:00
Felipe Lalanne
0835b29874 Add app uuid as metadata to new volumes
We cannot modify older volumes but newly created volumes will contain
app uuid as metadata so they can be migrated at some point in the
future.
2022-03-22 19:08:03 -03:00
Felipe Lalanne
0b19dee511 Cleanup current state reporting methods
Removed redundant `getCurrentAppsForReport` and `getCurrentForComparison` since
the behavior of these methods is already handled by `getCurrentApps` and
`getCurrentState`.
2022-03-22 19:08:03 -03:00
Felipe Lalanne
063bd400a4 Convert target state in local endpoints
Convert target state from to v3 in `/v2/local/target-state`. Add tests
for target state conversion
2022-03-22 19:08:03 -03:00
Felipe Lalanne
1edd060143 Clean up migration from legacy target state format
Creates `lib/legacy.ts` and `device-state/legacy.ts` to deal with
migration from legacy target states (single container and v2) for all
apps and for apps.json respectively
2022-03-22 19:08:03 -03:00
Felipe Lalanne
7425d1110b Add support for GET v3 target state
This change updates types and database format in order to allow
receiving the new format of the target state from the cloud and allow
applications to keep working.

This change also updates metadata in the containers, meaning services
will need to be restarted on supervisor update

Change-type: major
2022-03-22 19:08:02 -03:00
Felipe Lalanne
ccae1f7cb8 Rename aplication manager getStatus as getLegacyState
With the move to v3 target state and the move forward to remove
database ids from the supervisor, we want to ensure the ids are only
used for legacy support (such as within the API). This change renames
the method and sets it as deprecated
2022-03-22 19:08:02 -03:00
Balena CI
474fc4e890 v12.11.43 2022-03-22 01:57:31 +02:00
bulldozer-balena[bot]
50d6fd4452
Merge pull request #1908 from balena-os/status-missing
Always add status to image download report
2022-03-21 23:55:28 +00:00
Felipe Lalanne
21c1c006f7 Always add status to image download report
It seems that in some cases the supervisor can report
an image without a `status` field leading to a cloud side 401 response.
See #1905 for more details.

Change-type: patch
2022-03-21 14:39:29 -03:00
Balena CI
37a82e2dd6 v12.11.42 2022-03-19 00:35:28 +02:00
bulldozer-balena[bot]
aabd361e2b
Merge pull request #1903 from balena-os/test-cleanup
Moved test setup into file included for all tests
2022-03-18 22:32:25 +00:00
20k-ultra
b068c209b0 Moved test setup into file included for all tests
Change-type: patch
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-18 18:19:21 -04:00
Balena CI
aa023051f6 v12.11.41 2022-03-16 23:13:15 +02:00
bulldozer-balena[bot]
6ee6b25ed4
Merge pull request #1899 from balena-os/add-pr-template
Added PR template doc
2022-03-16 21:09:36 +00:00
Balena CI
260737a570 v12.11.40 2022-03-16 21:14:58 +02:00
bulldozer-balena[bot]
05fafae0b0
Merge pull request #1901 from balena-os/report-errors
Only count report connectivity errors for healthcheck
2022-03-16 19:12:43 +00:00
bulldozer-balena[bot]
a66c02b484
Merge pull request #1900 from balena-os/update-pkgs
update packages for vulnerabilities
2022-03-16 18:30:29 +00:00
Felipe Lalanne
e217ff9027 Only count report connectivity errors for healthcheck
Change-type: patch
2022-03-16 17:34:07 +00:00
20k-ultra
b5a2b8b751 update packages for vulnerabilities
Change-type: patch
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-16 00:10:22 -04:00
Balena CI
702efb2d14 v12.11.39 2022-03-16 05:19:57 +02:00
bulldozer-balena[bot]
a5d13902ec
Merge pull request #1888 from balena-os/lift-report-throttle
Move report throttle out of reporting logic
2022-03-16 03:17:11 +00:00
20k-ultra
2fdb83839c Move report throttle out of reporting logic
Change-type: patch
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-15 22:53:34 -04:00
20k-ultra
5e5f1fb305 Update npm dep sinon to v11.1.2
Change-type: patch
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-15 22:53:34 -04:00
20k-ultra
edcbb622d8 Added PR template doc
Change-type: patch
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-15 17:43:45 +00:00
Balena CI
710d214dbb v12.11.38 2022-03-15 01:08:28 +02:00
bulldozer-balena[bot]
2977d22b92
Merge pull request #1897 from balena-os/patch-trigger-apply
Apply target state if loaded from file (apps.json)
2022-03-14 23:06:52 +00:00
20k-ultra
b069d6b9d5 Apply target state if loaded from file (apps.json)
Closes: #1895
Change-type: patch
See: https://www.flowdock.com/app/rulemotion/r-supervisor/threads/tSN9BgLxkgJKapbQHQJr-R9yLPM
Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
2022-03-14 18:49:29 -04:00
Balena CI
ba395b2dbd v12.11.37 2022-02-28 23:24:15 +02:00
bulldozer-balena[bot]
bc571699ce
Merge pull request #1892 from balena-os/404-supervisor0
Fix check for supervisor0 network
2022-02-28 21:21:34 +00:00
Felipe Lalanne
d1956b69cc Fix check for supervisor0 network
The check for the docker network supervisor0 assumed that if the
interface supervisor0 existed, then the network would exist too. However this is not
true on the case of docker directory corruption, which would lead to a
loop with `Error: (HTTP code 404) no such network - network supervisor0 not found`.

Change-type: patch
Closes: #1806
2022-02-25 19:46:59 -03:00
Balena CI
2615c25fc4 v12.11.36 2022-02-24 15:32:47 +02:00
bulldozer-balena[bot]
cb68a067b3
Merge pull request #1891 from balena-os/sec-opt
Ignore selinux security opts when comparing services
2022-02-24 13:31:01 +00:00
Felipe Lalanne
1b54ce8bfd Ignore selinux security opts when comparing services
The moby engine v20.x.y adds some selinux [security configurations](https://docs.docker.com/engine/reference/run/#security-configuration)
depending on the [container configuration](https://github.com/moby/moby/blob/master/daemon/create.go#L214).
This would cause the supervisor to enter a service restart loop as the
current and target service configurations will never match. The
supervisor now ignores selinux specific security options since those are
not supported by balenaOS.

Closes: #1890
Change-type: patch
2022-02-23 18:12:27 -03:00
Balena CI
2df5b2f388 v12.11.35 2022-02-16 23:01:18 +02:00
bulldozer-balena[bot]
aee9117871
Merge pull request #1863 from balena-os/troubleshoot-dbus-macos
Add troubleshooting notice for macOS
2022-02-16 20:58:55 +00:00
Balena CI
b677972576 v12.11.34 2022-02-16 15:31:02 +02:00
bulldozer-balena[bot]
1c82097d1d
Merge pull request #1883 from balena-os/reduce-config-json-writes
Make the supervisor more resistant to restarts during config changes
2022-02-16 13:28:30 +00:00
Felipe Lalanne
e7ec42fadc Use a breadcrumb to mark that a reboot is required
As changes to config.json may restart the supervisor before it can
trigger the reboot (or something can kill the supervisor before it can run that step),
the supervisor needs a persistent signal that a reboot is required
(instead of the current transient signal).

With this commit, the supervisor will now create a breadcrumb in the
host `/tmp` folder, that will be checked as the last step of the
configuration changes.
2022-02-15 12:52:48 -03:00
Felipe Lalanne
a2d6db1e1d Update signature of fsUtils.getPathOnHost
The function now returns either a string array if it receives multiple
arguments or a single string if it receives a single argument.
2022-02-15 12:52:46 -03:00
Felipe Lalanne
2917f03452 Perform config.json sequentially to other config changes
As config.json changes may restart the engine (and hence the supervisor)
in newer OS versions, this ensures that the supervisor does not get
interrupted while writing to backends.
2022-02-15 12:49:03 -03:00
Felipe Lalanne
63cb985c53 Split device-config step calculation into separate functions 2022-02-15 12:49:03 -03:00
Felipe Lalanne
118875e12e Fix apiUpdatePollInterval default to line up with API 2022-02-15 12:49:03 -03:00
Felipe Lalanne
a4d91d381a Create touch and getBootTime utility functions
Change-type: patch
2022-02-15 12:49:03 -03:00