Commit Graph

4816 Commits

Author SHA1 Message Date
flowzone-app[bot]
901176952d
v16.5.3 2024-08-08 16:40:43 +00:00
flowzone-app[bot]
6eafde9f59
Merge pull request #2361 from balena-os/host-config-noproxy
Do not write `noProxy` to redsocks.conf
2024-08-08 16:39:55 +00:00
Felipe Lalanne
b088b78a3e
Do not write noProxy to redsocks.conf
This fixes a regression introduced by the refactor in #2329 where
`noProxy` was being included in the data added to redsocks.conf.

Change-type: patch
2024-08-08 11:59:20 -04:00
flowzone-app[bot]
338fdfdfb5
v16.5.2 2024-08-07 21:59:17 +00:00
flowzone-app[bot]
0fc969d247
Merge pull request #2362 from balena-os/blinking-errors
Verify that LED_FILE exists on blinking setup
2024-08-07 21:58:09 +00:00
Felipe Lalanne
a255001c2e
Verify that LED_FILE exists on blinking setup
Before v1, the blinking module would not throw when the passed led file
does not exist. This change checks for file existence and defaults to
`/dev/null` otherwise

Change-type: patch
2024-08-07 15:33:07 -04:00
flowzone-app[bot]
8f5131c680
v16.5.1 2024-08-05 19:17:37 +00:00
flowzone-app[bot]
b31cbf0db8
Merge pull request #2360 from balena-os/memory-improvements
Memory usage improvements
2024-08-05 19:16:24 +00:00
Felipe Lalanne
0d2e2e5e52
Update blinking to v1
This module would use promise recursion for the blinking pattern, which
it would slowly increase memory usage of the supervisor.
2024-08-02 12:19:40 -04:00
Felipe Lalanne
d789e5bb77
Avoid leaking memory on deep promise recursions
The following pattern
```ts
async function longRunning() {
   // do something
   await setTimeout(delay);
   await longRunning();
}
```

Is regularly used for long running operations on the supervisor (e.g.
polling target state). We have
recently discovered that this pattern can slowly leak memory as it
essentially creates an infinite promise chain. Using `void longRunning()` breaks
the chain and avoids the issue.

This commit fixes all those instances where the pattern was used.

Change-type: patch
2024-07-31 18:39:29 -04:00
flowzone-app[bot]
0124952962
v16.5.0 2024-07-30 18:48:26 +00:00
flowzone-app[bot]
dac9a24c10
Merge pull request #2351 from balena-os/knex-error
Logs processing improvements
2024-07-30 18:47:39 +00:00
Felipe Lalanne
8bc08750e9
Use promises for setup/writing for logging backend
The balena logging backend now uses async functions to setup the
connection and write messages to the request stream. This adds some
backpressure on `log` calls by by the log monitor module, to prevent a
very agressive container causing the supervisor to waste CPU cycles just
dropping messages.

Change-type: patch
2024-07-30 10:51:19 -04:00
Felipe Lalanne
f3fcb0db7a
Improve the LogBackend interface
This make the LogBackend `log` method into an async method in
preparation for upcoming changes that will use backpressure from the
connection to delay logging coming from containers.

This also removes unnecessary imageId from the LogMessage type

Change-type: patch
2024-07-30 10:51:19 -04:00
Felipe Lalanne
5af948483a
Use stream pipeline instead of pipe
This also removes the use of JSONStream from the monitor module

Change-type: patch
2024-07-30 10:51:19 -04:00
Felipe Lalanne
dbacca977a
Do not use DB to store container logs info
This removes the dependence of the supervisor on the containerLogs
database for remembering the last sent timestamp. This commit instead
uses the supervisor startup time as the initial time for log retrieval.
This might result in some logs missing for services that may start
before the supervisor after a boot, or if the supervisor restarts.
However this seems like an acceptable trade-off as the current
implementation seems to make things worst in resource contrained
environments.

We'll move storing the last sent timestamp to a better storage medium in
a future commit.

Change-type: minor
2024-07-30 10:51:18 -04:00
flowzone-app[bot]
4a8bf14196
v16.4.6 2024-07-30 14:43:25 +00:00
balena-renovate[bot]
df5558edf6
Merge pull request #2359 from balena-os/renovate/patch-semver
Update semver to v7.6.3
2024-07-30 14:42:31 +00:00
Self-hosted Renovate Bot
340e69d0c2 Update semver to v7.6.3
Update semver from 7.6.2 to 7.6.3

Change-type: patch
2024-07-25 15:09:28 +00:00
flowzone-app[bot]
c399792cba
v16.4.5 2024-07-25 14:31:20 +00:00
balena-renovate[bot]
0f1abcbd0f
Merge pull request #2358 from balena-os/renovate/balena-io-deploy-to-balena-action-2.0.x
Update balena-io/deploy-to-balena-action action to v2.0.74
2024-07-25 14:30:19 +00:00
Self-hosted Renovate Bot
92be067b0d Update balena-io/deploy-to-balena-action action to v2.0.74
Update balena-io/deploy-to-balena-action from 2.0.72 to 2.0.74

Change-type: patch
2024-07-25 14:08:55 +00:00
flowzone-app[bot]
f2f229915d
v16.4.4 2024-07-17 14:48:54 +00:00
Page-
b7ca7fb3d2
Merge pull request #2353 from balena-os/log-message-typing
Improve log message typing
2024-07-17 15:47:53 +01:00
Pagan Gazzard
4976578a83 Improve log message typing
Change-type: patch
2024-07-17 11:14:17 +01:00
flowzone-app[bot]
ef8414bd9e
v16.4.3 2024-07-16 22:28:19 +00:00
Page-
cafd8e89e5
Merge pull request #2352 from balena-os/optimize-logs
Optimize logs
2024-07-16 23:27:30 +01:00
Pagan Gazzard
c5d0eafea9 Logs: only truncate the message if it's possible it will need it
Change-type: patch
2024-07-16 18:09:12 -04:00
Pagan Gazzard
34cf8b6708 Logs: skip setting default values if we're dropping as an invalid log
Change-type: patch
2024-07-16 18:09:12 -04:00
Pagan Gazzard
0a817af10c Logs: only call Date.now() if a timestamp is not already present
Change-type: patch
2024-07-16 18:09:12 -04:00
flowzone-app[bot]
405ddf2c33
v16.4.2 2024-07-16 21:55:53 +00:00
flowzone-app[bot]
7710c03421
Merge pull request #2355 from balena-os/state-engine-tests
Cleanup images after state-engine tests
2024-07-16 21:55:04 +00:00
Felipe Lalanne
f38714d40f
Cleanup images after state-engine tests
Tests on GitHub started failing recently because of leftover images from
the state engine test suite. This fixes that issue to allow tests to
pass.

Change-type: patch
2024-07-16 16:33:52 -04:00
flowzone-app[bot]
c4a530c9ea
v16.4.1 2024-07-05 21:13:43 +00:00
flowzone-app[bot]
55a81aaeb2
Merge pull request #2350 from balena-os/instanceof-error
Remove custom typings for docker-delta
2024-07-05 21:12:53 +00:00
Felipe Lalanne
fbdd7ee8b9
Update docker-delta to v4.1.0
The new version now properly exports OutOfSyncError.
2024-07-05 12:28:19 -04:00
Felipe Lalanne
28706510da
Remove custom typings for docker-delta
This are no longer needed since docker-delta migrated to typescript in
v4 and the custom typings were actually masking some bugs

Change-type: patch
2024-07-04 18:41:33 -04:00
flowzone-app[bot]
7c340f9675
v16.4.0 2024-07-04 20:25:40 +00:00
flowzone-app[bot]
da807e45f6
Merge pull request #2329 from balena-os/refactor-host-config-module
Refactor host config module
2024-07-04 20:24:45 +00:00
Christina Ying Wang
f99ccb58c6 Remove unnecessary exports from host-config
This limits the host-config interface to necessary methods
only

Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:47:51 -07:00
Christina Ying Wang
53f5641ef1 Refactor host-config to be its own module
The host-config module exposes the following interfaces: get,
patch, and parse.

`get` gets host configuration such as redsocks proxy configuration
and hostname and returns it in an object of type HostConfiguration.

`patch` takes an object of type HostConfiguration or LegacyHostConfiguration
and updates the hostname and redsocks proxy configuration, optionally
forcing the patch through update locks.

`parse` takes a user input of unknown type and parses it into type
HostConfiguration or LegacyHostConfiguration for patching, erroring if
parse was unsuccessful.

LegacyHostConfiguration is a looser typing of the user input which does
not validate values of the five known proxy fields of type, ip, port,
username, and password. We should stop supporting it in the next
major Supervisor API release.

Change-type: minor
Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:47:51 -07:00
Christina Ying Wang
be986a62a5 Add HostConfig.parse method
Parses input from PATCH /v1/device/host-config into either
type HostConfiguration, or if LegacyHostConfiguration if
input is of an acceptable shape (for backwards compatibility).

Once input has been determined to be of type HostConfiguration,
we can easily extract ProxyConfig from the object for patching,
stringifying, and writing to redsocks.conf.

Change-type: minor
Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:47:51 -07:00
Christina Ying Wang
f17f7efe60 Add HostConfig.patchProxy method
Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:47:49 -07:00
Christina Ying Wang
9c6681bb23 Add RedsocksConf.stringify method
`stringify` takes a RedsocksConfig, an internal object
representation of the redsocks.conf file, and transforms
it into a valid string that can be written to redsocks.conf.

Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:45:52 -07:00
Christina Ying Wang
1e224be0cd Add RedsocksConf.parse method
This is part of the host-config refactor which
enables easier encoding to / decoding from `redsocks.conf`.

Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-07-03 16:45:06 -07:00
Christina Ying Wang
725d7790fb Move noProxy handling to separate module
Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-06-28 11:34:27 -07:00
Christina Ying Wang
0cf5a4bf18 Move hostname get/set to separate "module" (directory)
Signed-off-by: Christina Ying Wang <christina@balena.io>
2024-06-28 11:34:21 -07:00
flowzone-app[bot]
1c81eafd7c
v16.3.17 2024-06-25 01:03:32 +00:00
flowzone-app[bot]
88db2962a8
Merge pull request #2349 from balena-os/network-remove
Fix engine deadlock on network+service change
2024-06-25 01:02:22 +00:00
Felipe Lalanne
ede27b63ce
Fix engine deadlock on network+service change
This fixes a regression on the supervisor state engine computation
(added on v16.2.0) when
the target state removes a network at the same time that a service
referencing that network is changed. Example going from

```
services:
   one:
      image: alpine: 3.18
      networks: ['balena']

networks:
   balena:
```

to

```
services:
   one:
      image: alpine: latest
```

Would never reach the target state as killing the service in order to
remove the network is prioritized, but one of the invariants in the target state calculation is
to not kill any services until all images have been downloaded. These
two instructions were in contradiction leading to a deadlock.

The fix involves only adding removal steps for services depending on a
changing network or volume if the service container is not being removed
already.

Change-type: patch
2024-06-24 18:12:12 -04:00