Commit Graph

4226 Commits

Author SHA1 Message Date
Christina Ying Wang
250684d651 Use actions & write tests for GET /v1/device
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-11 15:48:13 -08:00
Christina Ying Wang
72c683d5ff Use actions & write tests for GET /v1/apps/:appId
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-11 15:48:13 -08:00
Christina Ying Wang
198d9ad638 Write update action and tests, remove isReadyForUpdate check
See: #1924
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-11 15:48:13 -08:00
Christina Ying Wang
85392f2a85 Move reboot/shutdown to actions and related tests to integration
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-11 15:48:13 -08:00
Christina Ying Wang
c6cf6a0136 Use executeServiceAction for v1/v2 service action endpoints
This includes:
- /v1/apps/:appId/(stop|start)
- /v2/applications/:appId/(restart|stop|start)-service

Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 18:20:24 -08:00
Christina Ying Wang
fcd28591c6 Add tests for doPurge action and v1/v2 app purge routes
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 16:25:27 -08:00
Christina Ying Wang
a24d5acf7f Add tests for doRestart action and v1/v2 app restart routes
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 16:25:27 -08:00
Christina Ying Wang
d6298b2643 Use regenerateKey action for POST /v1/regenerate-api-key
This also adds a 500 response with the old key if the API key
refresh was unsuccessful. Previously, if the key refresh was
unsuccessful, this would result in an UnhandledPromiseRejection.
This is a new interface.

Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 16:25:27 -08:00
Christina Ying Wang
c7db3189ad Use identify action for POST /v1/blink
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 16:01:43 -08:00
Christina Ying Wang
e351ed9803 Use runHealthchecks action for GET /v1/healthy
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-09 16:01:43 -08:00
Balena CI
62840c6bec
v14.4.10 2023-01-04 20:25:56 +00:00
Balena CI
0c2135355a
Merge pull request #2086 from balena-os/docs-nobody-lockfile-uid-for-supervisor-locks
Docs: clarify that Supervisor creates lockfiles as nobody UID
2023-01-04 22:24:15 +02:00
Christina Ying Wang
3a824448fa Docs: clarify that Supervisor creates lockfiles as nobody UID
Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2023-01-04 11:24:20 -08:00
Balena CI
e0005c8307
v14.4.9 2022-12-19 14:26:00 +00:00
Page-
7438d30eba
Merge pull request #2068 from balena-os/got
Use `got` for fetching the target state in order to have brotli support
2022-12-19 14:24:33 +00:00
Balena CI
062078ab60
v14.4.8 2022-12-15 22:29:20 +00:00
Balena CI
f155672540
Merge pull request #2081 from balena-os/journalctl-persistent-logs
Fix journalctl to work with persistent logs
2022-12-15 17:27:42 -05:00
Felipe Lalanne
55594274f7 Fix journalctl to work with persistent logs
v14.4.5 introduced a new way to retrieve the host logs by symlinking the
log directories into the host /run/log/journal and using a local copy of
the journalctl binary instead of chrooting into the host. This failed to
account for the location of persistent logs when that option is turned
on (/var/log/journal instead of /run/log/journal). This fixes the checks
consider this case and also makes sure to remove the original symlink to
avoid having nested links `/run/log/journal/journal/journal`, which was a
bug in the previous implementation.

Change-type: patch
2022-12-15 19:01:44 -03:00
Pagan Gazzard
fd135214fe Use got for fetching the target state in order to have brotli support
Change-type: patch
2022-12-15 21:15:11 +00:00
Balena CI
ac3812aa9f
v14.4.7 2022-12-15 20:39:49 +00:00
Balena CI
a9d920c4c7
Merge pull request #2079 from balena-os/clarify-api-docs-for-api-key-regenerate-endpoint
patch: Update API.md
2022-12-15 15:38:03 -05:00
Christina Wang
24e5996b56 Update API.md
Clarify that only containers on a single device will be restarted following API key refresh,
not the whole fleet. Each device has its own distinct API key.

Change-type: patch
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-12-13 19:18:33 -08:00
Balena CI
a482174aa0
v14.4.6 2022-12-08 18:39:59 +00:00
Christina Wang
577fec7ef6
Merge pull request #2073 from balena-os/host-config
Make readFromBoot behave more like Node readFile
2022-12-08 10:38:27 -08:00
Balena CI
cb72b8337b
v14.4.5 2022-12-07 19:29:25 +00:00
Felipe Lalanne
5c9b896c82
Merge pull request #2069 from balena-os/local-journalctl
Stop using host journalctl
2022-12-07 16:28:02 -03:00
Felipe Lalanne
77cd15f131 Sanitize output when writing to redsocks.conf
Properties with values including quotes (`"`) would not get sanitized
and written verbatim on the config file, causing redsocks to fail.

Closes: #2072
2022-12-07 18:36:25 +00:00
Felipe Lalanne
0605e996c9 Make readFromBoot behave more like Node readFile
The `readFromBoot` function replaced calls to readFile in the codebase
when the target location is under `/mnt/boot` in order to use `fatrw`
to check for corruption. Unfortunately this function behaved a little
differently with regards to errors. While `readFile` returns a code `ENOENT`
when the file is not found, `readFromBoot` would just throw an exception
with whatever code was given by fatrw. This would cause confusion for
some calls that were behaving differently with a `ENOENT`, causing some
issues.

Closes: #2071
Change-type: patch
2022-12-07 18:30:34 +00:00
Felipe Lalanne
91b119cbae Stop using host journalctl
The supervisor had to chroot into the host root in order to read the
journal logs. This won't be possible anymore once the supervisor becomes
an app. This commit copies the journalctl binary and necessary libraries
from a debian image into the supervisor image in order to be able to use
the tool on runtime.

Change-type: patch
2022-12-05 17:09:20 -03:00
Balena CI
3e1b1b0be1
v14.4.4 2022-11-22 15:22:26 +00:00
bulldozer-balena[bot]
d2cc2e4b38
Merge pull request #2067 from balena-os/module-resolution
Enable node16 module resolution in tsconfig to ease the ESM transition
2022-11-22 15:20:51 +00:00
Pagan Gazzard
836f6ab754 Enable node16 module resolution in tsconfig to ease the ESM transition
This means that dynamic import statements will emit actual `import`
statements rather than being translated to `require`, the benefit being
that we can now import ES modules via dynamic imports

Change-type: patch
2022-11-22 11:01:03 -03:00
Balena CI
db1c806d33
v14.4.3 2022-11-22 02:54:22 +00:00
bulldozer-balena[bot]
cf5a668fe5
Merge pull request #2060 from balena-os/timers-promises
Use timers/promises for promisified setTimeout
2022-11-22 02:52:59 +00:00
Christina Ying Wang
e0f77b660d Fix config test typo
Signed-off-by: Christina Ying Wang <christina@balena.io>
2022-11-21 18:18:15 -05:00
Pagan Gazzard
b8891ebb08 Use timers/promises for promisified setTimeout
Change-type: patch
2022-11-21 18:17:34 -05:00
Balena CI
80f52b796a
v14.4.2 2022-11-21 20:02:28 +00:00
bulldozer-balena[bot]
13ca0ebb25
Merge pull request #2061 from balena-os/unnecessary-reduce
Remove some unnecessary usage of `.reduce`
2022-11-21 20:00:39 +00:00
Pagan Gazzard
3dea88c74e Remove some unnecessary usage of .reduce
Change-type: patch
2022-11-18 17:10:36 +00:00
Balena CI
e64166a583
v14.4.1 2022-11-18 16:08:16 +00:00
bulldozer-balena[bot]
40d19520e5
Merge pull request #2049 from balena-os/decrease_metrics_frequency
Limit metrics reporting maximum frequency to 5 minutes
2022-11-18 16:06:54 +00:00
Ken Bannister
599b5cf811 Improve determination of when a state change may need to be reported
Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-11-18 09:23:20 -05:00
Ken Bannister
b1d4aa5159 Report must include a state change if sooner than metrics frequency
Export list of metrics properties from device state module for this
determination.

Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-11-18 09:12:10 -05:00
Ken Bannister
d1dd53b5b6 Remove report frequency management from current state reporting function
Report frequency now managed completely by callers.

Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-11-17 07:41:08 -05:00
Ken Bannister
c67429f3e1 Move definition of maxReportFrequency to the reporting file
Narrows scope to where it is used, like the new maxMetricsFrequency value.

Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-11-17 07:41:08 -05:00
Ken Bannister
45d71fa60d Report metrics in target-state PATCH based on a max frequency
Adds maxMetricsFrequency, separate from maxReportFrequency.
Also ensures most recent state change event is reported.

Change-type: patch
Signed-off-by: Ken Bannister <kb2ma@runbox.com>
2022-11-17 07:41:08 -05:00
Balena CI
48fca82a79
v14.4.0 2022-11-17 01:37:54 +00:00
bulldozer-balena[bot]
e4e59c656d
Merge pull request #1971 from balena-os/fatrw
Use fatrw for writes to /mnt/boot
2022-11-17 01:35:46 +00:00
Felipe Lalanne
dade598737 Use fatrw utility for writes to boot partition
This PR changes the way the supervisor reads and writes files from /mnt/boot. Reads will
now use the [fatrw utility](https://github.com/balena-os/fatrw/) as a way to minimize corruption of
files in the boot partition, and thus preventing possible bricking of the device.

Since this basically changes the way a lot of configurations are read, this work was being blocked because of
the way tests were being done. While there still remain a couple of legacy tests to be migrated, this PR disables
test:legacy tests when running npm run test, as the work on refactoring those tests is in progress (see #2048) and
fatrw integration is of higher priority.

Change-type: minor
2022-11-16 21:21:23 -03:00
Balena CI
d14cca8e5d
v14.3.5 2022-11-16 22:29:58 +00:00