Commit Graph

93 Commits

Author SHA1 Message Date
Cameron Diver
286ba58069
Add tests for Volume
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
Roman Mazur
aad1129f26
Fix tests run removing .only
The issue was introduced with one of the recent changes related to local mode cleanup.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-27 14:56:54 +03: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
Roman Mazur
3f5239b07f
Remove mochainon dependnecy
Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
2019-06-19 23:31:58 +03: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
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
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
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
9e05bc2b71
misc: Fix spurious test errors
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-04-25 13:48:27 +01:00
Cameron Diver
0fa47f635b
fix: Correctly handle multiple hosts ports pointing to a container port
When assigning multiple host ports to a single container port before
this change, the supervisor would incorrectly take only the first host
port into consideration. This change makes it so that every host port
per container port is considered.

Closes: #986
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-04-25 13:48:04 +01:00
Cameron Diver
e148ce0529
Report all logs from a container's runtime
We add a database table, which holds information about the last
timestamp of a log successfully reported to a backend (local or remote).
We then use this value to calculate from which point in time to start
reporting logs from the container. If this is the first time we've seen
a container, we get all logs, and for every log reported we save the
timestamp. If it is not the first time we've seen a container, we
request all logs since the last reported time, ensuring no interruption
of service.

Change-type: minor
Closes: #937
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-04-05 10:06:27 +01:00
Pablo Carranza Velez
3d0e35f2a2 Fix test for deviceConfig.getDefaults with the addition of SUPERVISOR_INSTANT_UPDATE_TRIGGER
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2019-04-03 09:15:50 -07:00
Pablo Carranza Velez
8f07bf62de Add a random jitter to target state polls, and a config var to ignore update notifications and not poll immediately after startup
This commit does two related things:

* We make the poll interval a random time between 0.5 and 1.5 times the configured interval.
* We introduce the BALENA_SUPERVISOR_INSTANT_UPDATE_TRIGGER configuration variable, that defaults to true. If this variable is set
to false, then calls to /v1/update are ignored, and on startup the supervisor waits for a poll interval before getting the target state.

This will help especially on cases where there's a large number of devices on a single network. By disabling instant updates and setting a large
poll interval, we can now achieve a sitation where not all devices apply an update at the same time, which can help avoid
overwhelming the network.

Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2019-04-03 09:15:49 -07:00
Pablo Carranza Velez
ea6ebf8223 test: Add a test case for deviceConfig.getDefaults
This would help avoid bugs like the one fixed in 9.11.1.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2019-03-28 16:01:00 -07:00
Cameron Diver
b3192679c7
fix: Correctly compare and generate network membership aliases
Before this change, service name resolution would only occur in the
default network. This was because we were not explicitly adding aliases
of the service names to the aliases fields.

We also fix the comparison, which would do funny things based on
container IDs, which was correct but unnecessary.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-03-28 10:27:21 +00:00
Cameron Diver
84356b82b8
state-engine: Return a noop when waiting for a dependency
We run the risk of the state engine exiting early when a dependency is
not ready, especially in local mode. This changes forces a noop to be
returned when we are waiting on another service, which is the process
used elsewhere in the state engine.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-03-13 10:34:15 +00:00
Cameron Diver
911ee7f009
Run iptables rules synchronous to avoid locking errors
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-19 17:43:04 +00:00
Cameron Diver
5f82f6fd3f
Apply iptables rules to ipv6
Change-type: patch
Closes: #867
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-13 20:57:05 +00:00
Cameron Diver
49dbaaba12
Allow newlines to be part of environment variables
We were not allowing newlines previously by virtue of the regex not
allowing them. The docker daemon and supervisor handling code both
support them, so we allow them in the parsing code too.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-12 11:19:55 +00:00
Cameron Diver
6bf008cc85
Remove environment variable whitespace trimming
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-11 17:13:35 +00:00
Cameron Diver
88f19b4147
Set default delta apply timeout of 0
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-11 10:21:04 +00:00
Cameron Diver
f3264862ca
fix: Normalize ports from compose file on instantiation
Adjacent ports are always grouped together by docker when reporting the
container state (from an inspect), so adjacent ports defined in the
compose file would not match as they would not have been normalized.

We make sure to always normalize the input port configuration, so that
it will match the docker output (if it should).

We also don't sort in the fromComposePorts function anymore as that is
handled by the normalize function.

Closes: #897
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-08 15:14:07 +00:00
Cameron Diver
2e09ed071c
Ensure the balena-fin always has it's overlay assigned
Change-type: patch
Closes: #884
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-02-05 16:19:42 +00:00
Cameron Diver
db74e748a1
refactor: Fully type and validate config module set and get
We define the type for each config value, and validate the data when
retrieving and setting it.

Change-type: minor
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-01-11 10:37:25 +00:00
Cameron Diver
01ed7bb103
refactor: Convert ApiBinder module to typescript
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-01-08 11:59:56 +00:00
Cameron Diver
3a130f4f9c
refactor: Change config modules export type to new-style
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-01-02 18:12:22 +00:00
Cameron Diver
dc34025545
refactor: Generate and normalise PortMaps from compose ports in-class
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-01-02 12:19:30 +00:00
Cameron Diver
e82749e63a
tests: Add test case for ascending ports issue
Signed-off-by: Cameron Diver <cameron@balena.io>
2019-01-02 11:31:25 +00:00
Cameron Diver
b32fba43e1
refactor: Convert DeviceConfig module to typescript
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-12-21 17:18:35 +00:00
Cameron Diver
de5157c04c
refactor: Change export style of db to named
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-12-21 17:18:33 +00:00
Cameron Diver
96b614ad6a
Replace offline -> unmanaged in logs and tests
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-12-17 10:53:24 +00:00
Cameron Diver
82602abf8d
config: Replace supervisorOfflineMode and offlineMode with unmanaged
Change-type: major
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-12-14 15:01:41 +00:00
Cameron Diver
19f8b75766
Revert "localMode: Remove local mode from device-config"
This reverts commit eda477ff86.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-12-14 11:05:57 +00:00
Cameron Diver
64a8c03eba
unmanged: Don't require a device name when setting a target state
Also set a default device name of 'local', to avoid an undefined value.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-29 11:35:08 +00:00
Cameron Diver
eda477ff86
localMode: Remove local mode from device-config
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-29 11:35:07 +00:00
Cameron Diver
5c04df2cb8
compose: Fix network option field names and update dockerode types
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-28 17:43:31 +00:00
Cameron Diver
b37ce5e3d9
config: Set default apiKey of empty string to avoid undefined keys
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-28 14:53:09 +00:00
Cameron Diver
f48e85095b
events: Correctly proxy mixpanel events
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-21 13:09:06 +00:00
Cameron Diver
0ff52751d8
tests: Increase timeout for test suites
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-06 15:27:58 +00:00
Cameron Diver
e270652122
Remove ts-node from test process
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2018-11-06 12:05:35 +00:00
Pagan Gazzard
d6e9283a15 Fix coffee-script lint failures 2018-11-02 14:50:12 +00:00
Pablo Carranza Velez
8298487a88 Rename most of the documentation and variable names from resin to balena
Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-11-01 17:00:13 -07:00
Akis Kesoglou
b71c59c002 api-binder: Use API v5
Change-type: major
2018-11-01 13:17:30 +02:00
Pablo Carranza Velez
1e47d0c434 test: Use longer delays in logger tests
We've seen at least one case where the 10ms delay
wasn't enough, causing the tests to fail where they shouldn't.

(Ideally we should find a better way to detect when the streams
have finished propagating, but this will avoid failures in the meantime).

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-10-25 16:48:06 -07: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