Commit Graph

4887 Commits

Author SHA1 Message Date
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
Felipe Lalanne
5d93f358aa
Create replicating test
This adds a test to check the case where a service image changes along
with networks being removed.
2024-06-24 15:54:19 -04:00
flowzone-app[bot]
1c3e24ec29
v16.3.16 2024-06-17 01:56:14 +00:00
balena-renovate[bot]
1fe754ca34
Merge pull request #2346 from balena-os/renovate/balena-io-deploy-to-balena-action-2.0.x
Update balena-io/deploy-to-balena-action action to v2.0.72
2024-06-17 01:55:12 +00:00
Self-hosted Renovate Bot
170733422a Update balena-io/deploy-to-balena-action action to v2.0.72
Update balena-io/deploy-to-balena-action from 2.0.71 to 2.0.72

Change-type: patch
2024-06-17 01:36:59 +00:00
flowzone-app[bot]
20fa8fd0c3
v16.3.15 2024-06-10 01:57:08 +00:00
balena-renovate[bot]
17e0e08b97
Merge pull request #2344 from balena-os/renovate/balena-io-deploy-to-balena-action-2.0.x
Update balena-io/deploy-to-balena-action action to v2.0.71
2024-06-10 01:56:08 +00:00
Self-hosted Renovate Bot
552f77cef5 Update balena-io/deploy-to-balena-action action to v2.0.71
Update balena-io/deploy-to-balena-action from 2.0.70 to 2.0.71

Change-type: patch
2024-06-10 01:36:51 +00:00
flowzone-app[bot]
0a3ce26116
v16.3.14 2024-06-09 13:30:01 +00:00
balena-renovate[bot]
a22c2049d6
Merge pull request #2343 from balena-os/renovate/got
Update got to v14.4.1
2024-06-09 13:29:01 +00:00
Self-hosted Renovate Bot
11628cda16 Update got to v14.4.1
Update got from 14.3.0 to 14.4.1

Change-type: patch
2024-06-09 13:09:09 +00:00
flowzone-app[bot]
2b8227dd0a
v16.3.13 2024-06-05 20:43:15 +00:00
flowzone-app[bot]
89baf8dec3
Merge pull request #2340 from balena-os/refactor-device-state
Refactor device state module
2024-06-05 20:42:13 +00:00
Felipe Lalanne
45d1f1f964
Split target state set/get into separate module
This removes the circular dependency between device state index and
preloading and cleans up the device state module code

Change-type: patch
2024-06-03 11:40:47 -04:00
Felipe Lalanne
fedeb518e5
Move device-state.ts into the device-state/index.ts
Change-type: patch
2024-06-03 11:40:47 -04:00
Felipe Lalanne
9497eed380
Move device-state/target state to api-binder/poll
This goes in the direction of grouping modules by responsibility. The
api-binder module is the middleware between the device and the backend,
thus the target state polling code makes more sense there.

Change-type: patch
2024-06-03 11:40:46 -04:00
flowzone-app[bot]
af1ef086fe
v16.3.12 2024-06-03 01:56:03 +00:00
balena-renovate[bot]
77db5c89cf
Merge pull request #2341 from balena-os/renovate/balena-io-deploy-to-balena-action-2.0.x
Update balena-io/deploy-to-balena-action action to v2.0.70
2024-06-03 01:55:11 +00:00
Self-hosted Renovate Bot
d7a325b80a Update balena-io/deploy-to-balena-action action to v2.0.70
Update balena-io/deploy-to-balena-action from 2.0.69 to 2.0.70

Change-type: patch
2024-06-03 01:36:04 +00:00
flowzone-app[bot]
1a303c4bb4
v16.3.11 2024-05-27 20:04:29 +00:00
flowzone-app[bot]
1264012fad
Merge pull request #2334 from balena-os/circular-dependencies
Refactor code to reduce circular dependencies between modules
2024-05-27 20:03:42 +00:00
Felipe Lalanne
027c2575b1 Move OS variant retrieval to config module
This also deprecates the `getOSVariant` function of the `os-release`
module, as the OS variant are no longer defined in `/etc/os-release`.

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
59689b2789 Do not export balenaApi on api-binder
Instead, add `getBalenaApi` function to api-helper so other modules can
access a balena API instance.

Further reduces circular dependencies to 5

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
ac2db38742 Move api-keys module to src/lib
This removes circular dependencies between the device-api module and
the compose module, reducing total circular dependencies to 15

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
48f75e61b8 Do not re-export ContractObject on lib/contracts
Further reduce circular dependencies to 10

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
bef5e78440 Move Compose(Network|Volume)Config to top level types
This reduces dependencies from 80 to 47

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
234e0de075 Move composition types to compose/types
This reduces circular dependencies from 250 to 80 by ensuring that
modules that only require types do not import the full module with all
its dependencies.

Change-type: patch
2024-05-27 14:36:03 -04:00
Felipe Lalanne
94de4006a0 Split compose types into interface and implementation
This splits `App`, `Network`, `Service` and `Volume` which used to be
defined as classes into an interface and a class implementation that is
not exported. This will allow to work with just the types in some cases
and prevent circular dependencies when importing.

Change-type: patch
2024-05-27 14:36:03 -04:00
flowzone-app[bot]
435a363716
v16.3.10 2024-05-27 02:41:53 +00:00
balena-renovate[bot]
13f1ce8863
Merge pull request #2337 from balena-os/renovate/got
Update got to v14.3.0
2024-05-27 02:40:46 +00:00