Commit Graph

851 Commits

Author SHA1 Message Date
Pablo Carranza Velez
d5094d8d3b fix: Properly check for the balena-api label to inject the API key env vars
Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-31 13:13:09 -07:00
Pablo Carranza Velez
d6ee60100d fix: When setting target state, delete old apps from the same source
In commit 19cd310da3 this line was deleted,
probably to avoid deleting local mode apps when setting the API target and
viceversa but we need to delete old apps to avoid problems when moving
the device between apps.

We now filter by source to avoid the problem with local mode too.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-31 11:20:42 -07:00
Pablo Carranza Velez
1c5891ec09 ApplicationManager: when comparing images to save metadata, take docker image ids into account
Otherwise we may skip saving a target image to the db when updating from legacy supervisors,
which in turn prevents from deleting the legacy image entry (with imageId = 1), leaving the
supervisor in a state where it can't report its current state to the API.

While we're at it, we also remove an unused variable in _getStatus.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-23 15:43:59 -07:00
Cameron Diver
64de3d2f63
fix: Use fat arrow for cleanup method
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-23 19:13:34 +01:00
Cameron Diver
1879c76b00
fix: Run checkTruthy on config values before using them
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-23 18:32:38 +01:00
Pablo Carranza Velez
f5b005bcb2 fix: Properly get the config from target state before comparing during initial config reporting
Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-22 13:18:53 -07:00
Pablo Carranza Velez
0eaae3d670 fix: When checking for legacy containers, properly get the labels from config
Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-20 19:08:53 +02:00
Pablo Carranza Velez
922597e582 fix: Avoid trying to report duplicated values in initial config
We do this by formatting the keys from the target state before comparing them
with the ones from the current state (that are already formatted to strip the namespace
prefix).

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-20 18:58:13 +02:00
Pablo Carranza Velez
b3860b2b70 fix: Store and retrieve device config without namespaces
This avoids issues on provisioning where the current state
(esp. config.txt) that we want to save is retrieved without
a RESIN_ or BALENA_ prefix, causing those values to be lost.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-20 04:40:55 +02:00
Pablo Carranza Velez
32d5e58ead Keep defaulting tty to true to avoid accidental breakage
Otherwise old releases (where applications expected tty to be true)
would break.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-19 17:54:13 +02:00
Pablo Carranza Velez
6fb0147d3c Fix preloading in flasher images by reading apps.json if target hasn't been set
i.e. if we're not provisioned or if the target state is empty (of apps), then we
read apps.json to preload. We then mark that the target state has been set to avoid
trying to preload again if we ever get an empty target state from the API.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-19 14:42:29 +02:00
Pablo Carranza Velez
583ce34c01 apiBinder: Keep prepending RESIN_ to reported config variables
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 17:20:53 +02:00
Pablo Carranza Velez
24cbfbb860 deviceConfig: allow BALENA_ config variables
They will take precedence over any existing RESIN_ variables. We strip both namespaces now
whenever we get the target values.

This also fixes preloading with a legacy config (the interface to get the config keys from
the legacy apps.json was broken).

Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 17:20:53 +02:00
Cameron Diver
e04de0a170
fix: Add typescript cast to fix type error
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-18 15:14:12 +01:00
Cameron Diver
d939b2b9e6
fix: Remove debugging console logs
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-18 15:04:04 +01:00
Cameron Diver
6ad3a7981d
fix: Redact environment variable values in debug output
Chnage-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-18 15:04:04 +01:00
Cameron Diver
2a94a7b730
fix: Apply default config options when they're falsy
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-18 15:04:04 +01:00
Cameron Diver
5569e2bc84
fix: Always set the container name when generating creation options
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-18 15:04:04 +01:00
Pablo Carranza Velez
e17bb59844 config: Allow atomic config.json writes on balenaOS
Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 15:01:49 +02:00
Pablo Carranza Velez
0a4eefa9c6 network: Ignore resin-redsocks and balena-redsocks when reporting IP addresses
Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 15:01:49 +02:00
Pablo Carranza Velez
31e730600d Use the DOCKER_SOCKET env var for the user container's balena socket mount
Instead of hardcoding balena.sock we use this variable since the path changes
with the balena -> balenaEngine rename.

We keep also mounting into balena.sock for backwards compatibility (even though
most tools should transparently use the DOCKER_HOST env var).

Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 15:01:49 +02:00
Pablo Carranza Velez
220f4b5810 service: Fix device name env vars by injecting and filtering in the interface with docker
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 14:49:00 +02:00
Pablo Carranza Velez
88b3682d51 ServiceManager: add BALENA_DEVICE_NAME_AT_INIT to injected env vars
Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 13:21:31 +02:00
Pablo Carranza Velez
ed3f5522ae Replace io.resin labels (and their env vars) with io.balena equivalents
But we keep backwards compatibility by normalizing existing io.resin labels
into io.balena ones, and adding both RESIN_ and BALENA_ env vars for these features.

Change-Type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-18 13:21:31 +02:00
Pablo Carranza Velez
83b4d5878e service-manager: Delete the correct handover complete file
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-17 17:38:49 +02:00
Pablo Carranza Velez
047ca2ae68 service: Fix typo and type errors
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-17 11:34:13 +02:00
Pablo Carranza Velez
87a8d8f8f4 Env var changes in API docs, new private env vars, remove unused vars
We update the supervisor API docs to reflect the new `BALENA_` injected env vars.
We also add the new sensitive env vars to the list of vars not sent by the API.

And we remove the unused RESIN_DATA_PATH and RESIN_PROXYVISOR_HOOK_RECEIVER from the
vars the supervisor parses from its own environment.

Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-16 15:12:05 +02:00
Pablo Carranza Velez
802025c01f Make handover-complete an alternative to the resin-kill-me file
Also fixes the handover wait (since the service interface for it was missing).
We add some logging to this process too.

Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-10-16 15:12:04 +02:00
Pablo Carranza Velez
8003f25c3d Add /tmp/balena lock and handover paths and BALENA_ env vars
We change the lockfile to /tmp/balena/updates.lock, and the resin-kill-me file to /tmp/balena/handover-complete.
In the host, we change to use /tmp/balena-supervisor instead of /tmp/resin-supervisor.

We add BALENA_ env vars in addition to the RESIN_ env vars.

We keep backwards compatibility by using both paths for the lockfile and handover, and keeping the RESIN_ env vars.

Changelog-entry: Move the handover and lock files to /tmp/balena, rename them, and add BALENA_ env vars
Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-10-16 15:12:04 +02:00
Pagan Gazzard
660d9ff6f3 Disable express' x-powered-by header
Change-type: patch
Signed-off-by: Pagan Gazzard <page@resin.io>
2018-10-16 13:26:21 +02:00
Cameron Diver
b1434e44ae
fix: overlay compose fields on image for healthcheck
This commit changes a bug where the compose healthcheck would always
overwrite the healthcheck set by the image - even if no compose
healthcheck exists.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-16 10:34:37 +01:00
Cameron Diver
16e7522a1f
fix: Remove support for broken storageOpt option
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-16 08:22:19 +01:00
Zubair Lutfullah Kakakhel
73b9895bdf
backend: Remove a few blacklisted config.txt options
These options were discussed in an arch call and the conclusion was
that they don't need to be in the blacklist.

Change-type: patch
Changelog-entry: Remove a few blacklisted config.txt options
Signed-off-by: Zubair Lutfullah Kakakhel <zubair@resin.io>
2018-10-15 11:41:22 +01:00
Cameron Diver
a143a07aaa
fix: Return void from config setter
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-15 11:12:47 +01:00
Cameron Diver
d7edd3eb63
fix: Don't assume config is defined for legacy images in logger
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-15 10:53:11 +01:00
Cameron Diver
ed73946af5
device-api: Add supervisor version endpoint
Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-13 20:24:25 +01:00
Cameron Diver
479e0a8bb8
state: Don't consider local mode when storing state
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-13 20:20:05 +01:00
Cameron Diver
5906e1427c
local mode: Add local mode manager module to handle cleanup
Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-13 20:20:05 +01:00
Cameron Diver
3e665c0f4a
logger: Enforce timestamp value to avoid logging server 400 errors
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-13 20:20:04 +01:00
Cameron Diver
6156825293
Add logging endpoint to supervisor
Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-13 20:19:38 +01:00
Cameron Diver
6e2801380b
Support local logging via standard logging interface
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-10 13:02:40 +01:00
Cameron Diver
19cd310da3
Support setting target state in local mode from supervisor API
Change-type: minor
Closes: #689
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-10 13:02:40 +01:00
Cameron Diver
e0237e826e
Add several local mode enabling endpoints
Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-10 13:02:08 +01:00
Cameron Diver
524d185c4c
Correctly type service-manager logger and event tracker fields
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-10 13:02:08 +01:00
Cameron Diver
5c0c880a10
Don't set empty target state in local mode
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-10 13:02:06 +01:00
Cameron Diver
5537ae4e2e
fix: Correctly handle array based network definitions for service
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-08 11:29:32 +01:00
Cameron Diver
367dd876aa
fix: Only join the default network when creating the container
We were joining every network on container creation, which is currently
bugged in Docker. We were also joining networks afterwards, so the
non-default networks are joined post-creation, and only the networkMode
container is joined on creation.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-10-08 11:29:23 +01:00
Cameron Diver
06bbf9751a
compose: Support changing the tty option for compose services
This enables the switch to be added to the compose, and the handling of
docker messages has been changed to ensure that the multiplexed logs
which result are handled properly.

Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-09-24 12:04:51 +01:00
Cameron Diver
e8a5edf774
types: Remove temporary Service type in favour of actual compose class
Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-09-24 12:04:51 +01:00
Cameron Diver
892d227cc2
compose/service: Convert module to typescript and add network config
Stability improvements;
* Printing of unsupported compose fields
* Added a lot of tests
* All compose configuration has a default value, enabling better
comparison

Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-09-21 10:30:27 +01:00