Commit Graph

1059 Commits

Author SHA1 Message Date
Cameron Diver
4f31b18670
Extract composition step work out to typescript compose module
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-19 17:00:39 +01:00
Cameron Diver
bd022df8bd
Add default exports for Volume and Network modules
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-19 17:00:38 +01:00
Cameron Diver
55ee5a468f
Remove unused local mode parameter from images.getAvailable
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-19 17:00:38 +01:00
Cameron Diver
76de276b92
Only consider certain array fields without order
Various fields returned from the docker daemon don't retain order (for
example the volumes field). We now only select certain array values to
compare taking order into account.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-19 14:55:06 +01:00
Cameron Diver
86e8a85640
Take order into account when comparing service config arrays
Change-type: patch
Closes: #1060
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-15 17:07:22 +01:00
Cameron Diver
43cbf7dbba
Add an endpoint and module for reading journald logs
Change-type: minor
Closes: #1003
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-08-09 11:08:29 +01:00
Cameron Diver
c62f4afe8d
api: Avoid cloneDeep when copying target state.
This can cause issues where the stack is exhausted
on large applications.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
Signed-off-by: Heds Simons <heds@balena.io>
2019-07-25 15:23:18 +01:00
Roman Mazur
4688524e45
Filter both null and omitted values
The docker daemon can sometimes return null for various fields,
or omit the field altogether. The best thing to do with using
the docker api is to always use == null to cover both instances.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-07-25 13:03:04 +03:00
Roman Mazur
4b56022d93
Use typed error to report inspection problems
This will throw a typed error in case when supervisor cannot inspect
its own container.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-07-25 13:03:03 +03:00
Roman Mazur
4846acb25e
Prevent supervisor from deleting itself
With recent changes to local mode behavior, supervisor removes all engine objects
that were not present before entering local mode.
With this change, supervisor also detects its own resources and does not delete them
if it was updated during local mode operations.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-07-25 13:02:57 +03:00
Rich Bayliss
f9aa4681fa
api: Perform network checks if device is unmanaged
Without these checks the API GET /v1/device doesn't return a
value for `ip_address`.

Change-type: patch
Signed-off-by: Rich Bayliss <rich@balena.io>
2019-07-24 15:40:53 +01:00
Cameron Diver
c109a24874 Support network_modes of service:<servicename>
That way that this is performed is by first adding a depends_on entry
for the target service if it appears in a network mode. Then when we
generate the docker container for this service, we use the containerId
of the target container and replace the network_mode with
`container:<id>`.

When comparing state, we check that the containerId still points to the
contianerId of the target container, and in this way we ensure that
when a network mode target container changes, we change the dependent
container too.

Change-type: minor
Closes: #851
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-23 13:41:19 +01:00
Cameron Diver
e91fa6e7b3
fix: Always reboot when applying boot config
Change-type: patch
Closes: #1037
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-22 16:07:39 +01:00
Cameron Diver
cbb079e8dc
fix: Don't consider volume supervised labels when comparing
Change-type: patch
Closes: #1039
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-19 12:17:38 +01:00
Matthew McGinn
2cb6ecc150
device-api: fix up small typos
Change-type: patch
Signed-off-by: Matthew McGinn <matthew@balena.io>
2019-07-18 13:07:53 +01:00
Cameron Diver
a796777967 Don't attempt to cleanup any target state referenced volumes
The code before this change could potentially remove a volume which
should not be removed if a container was deleted before the call that
references said volume.

To avoid this, we additionally filter the list of volumes to cleanup by
any that are referenced in the target state. This means that cleanup
will never remove it, as long as it's still supposed to be there,
regardless of if a container references it or not.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-11 16:35:29 +01:00
Cameron Diver
e076622fe6 Don't remove volumes when switching into local mode
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-10 14:25:47 +01:00
Cameron Diver
3304825216 Add a supervisor endpoint to cleanup orphaned volumes
Change-type: minor
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-10 14:25:44 +01:00
Cameron Diver
5357d4729d Only remove volumes when we're moving between applications
Change-type: major
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-10 14:25:22 +01:00
Cameron Diver
bb549a445b Dont try to set the commit if it's undefined
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-10 14:25:21 +01:00
Cameron Diver
37945b4aa5 Don't attempt to setup a log stream to the cloud before provision
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-09 13:21:05 +01:00
Cameron Diver
20a83e8e0a Add more typescript conversions and export utilities from existing
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-09 13:21:05 +01:00
Michel Wohlert
39c9810bbc Merge remote-tracking branch 'balena/master' into instantly-apply-update-on-api-request 2019-07-09 13:10:15 +02:00
Michel Wohlert
7a42b6719a Apply targetState immediately after update request
Cancel delayed promise if exists and schedule a new one without delay, when /v1/update is called

Change-type: patch
2019-07-06 00:06:42 +02:00
Cameron Diver
89807c21fa
Fix network composition parsing, and correctly report compose config
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-04 11:47:39 +01:00
Cameron Diver
e5d7379b74
Keep the network and volume models consistent across usage
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-03 10:42:42 +01:00
Cameron Diver
eaff3a2ee5
Pass around instantiated Network objects when comparing state
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-03 10:36:38 +01:00
Cameron Diver
23e564389d
Seperate volume handling into manager and object classes
This change also makes sure that in the application-manager workflow we
pass around instances of the Volume class, rather than just the config.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-07-03 10:36:37 +01:00
Pablo Carranza Velez
743c8406c9 fix: When reporting initial config, avoid creating a "VPN enabled" unnecessary override
Since we were comparing the VPN's value before adding the explicit "true", there were cases
were the VPN is off, and therefore "value" didn't match the default, so the supervisor would
create a device specific SUPERVISOR_VPN_CONTROL = true, which is unnecessary and causes issues if
users don't expect this and move the device to an app that has VPN disabled. The correct behavior
is to compare "varValue" and only create a device config var if this value differs from the default.

(This was the behavior before the TS conversion in 01ed7bb103 )

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2019-07-01 12:28:46 -07:00
Roman Mazur
645bc6c185
Ensure we get input on parsing errors
We wrap JSON and date parsing code to ensure input data is logged in case of an error.

Change-type: minor
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-26 17:40:02 +03:00
Roman Mazur
7c4d8d7653
Ensure local mode switch runs before target state
This change makes DeviceState to wait until local mode switch is definitely
completed before actually applying the state, which avoids races in state cleanup.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-26 17:40:02 +03:00
Roman Mazur
4974c9200c
Clean up local mode engine objects using snapshots
Snapshot is collected to compare with engine state when local mode is turned off.

Change-type: minor
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-26 17:40:01 +03:00
Roman Mazur
024b9c45f4
Report device state in local mode
In local mode, we now update device status on the backend,
but omit applications info in our updates.

Closes: #959
Change-type: minor
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-20 15:38:33 +03:00
Cameron Diver
8c69ae7645 Don't drop failed api patch data
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-20 12:56:10 +01:00
Cameron Diver
65019bb5bc
Fix typo in image selection
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-11 13:10:44 +01:00
Cameron Diver
b1e4e8399b
Re-parallelise current image retrieval code
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-11 07:50:38 +01:00
Cameron Diver
9c486275c9
Revert "Add a controlling variable for mixpanel reporting"
This reverts commit 1a7ed0f95b.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-10 20:53:33 +01:00
Cameron Diver
ea64f0b0b3 Upgrade typescript and fix warnings
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-10 15:35:43 +01:00
Cameron Diver
2276dd54e1 Standardise all supervisor output logging
Also use the supervisor's own container logging monitoring code when
running livepush on the supervisor container.

Change-type: minor
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-06-10 11:38:45 +01:00
Cameron Diver
1a7ed0f95b
Add a controlling variable for mixpanel reporting
Change-type: patch
Closes: #990
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-29 11:53:47 +01:00
Cameron Diver
8279678052
Add wrapper around container logs saving, to reduce db load
Changes are collected together and exist in memory, for querying and
saving. Once every 10 mins, every changed timestamp is flushed to the
database.

Change-type: patch
Closes: #987
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-28 15:56:11 +01:00
Cameron Diver
2a27b1d51f Move to resin-lint 3 and fix lint errors
This is a massive commit, but nothing related to runtime has actually
changed, only the lint errors have changed.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-26 18:54:09 +01:00
Cameron Diver
1155d757e4 Make delta application logs easier to parse for multicontainer
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 12:41:27 +01:00
Cameron Diver
4e783fcd86 Allow system messages to not be tracked
Also don't track update lock events

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 10:19:15 +01:00
Cameron Diver
50fdee4290 Format update lock logs with pretty-ms
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 10:19:14 +01:00
Cameron Diver
27b68b5845 Display update lock notification in dashboard logs
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 10:18:48 +01:00
Cameron Diver
5894a9baf3 Show better logs for UpdatesLockedError
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 10:18:47 +01:00
Cameron Diver
5ace459ad2 Clear backoff counter on new target state
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-15 10:18:47 +01:00
Cameron Diver
932a6f2997
Fix supervisor tests for node v10.12.0 and above
Changes in the node engine related to streams would cause the gzip
streams flush function to be called at the wrong times. The sinon fake
timers were also interacting with this.

We use setImmediate to call the flush function, and remove sinon timers
for the logging tests.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-10 12:36:46 +01:00
Cameron Diver
51703621a5
Cache delta auth token request results for 10 minutes
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-05-10 11:17:48 +01:00