Commit Graph

725 Commits

Author SHA1 Message Date
Cameron Diver
ddbf3418de
Remove trailing slashes from working directories of services
This is to combat when a working directory is in the compose file for a
service with a trailing slash. Docker will strip this slash and that
means service comparisons will fail going forward - even if they are the
same.

Change-type: patch
Closes: #635
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-04-27 18:03:36 +01:00
Cameron Diver
cfddbf65e4
Start initial typescript conversion, and add validation debugging
Add webpack config and dependencies to have typescript built, and also
convert src/lib/validation.coffee to typescript.

In this conversion I also added a lot of debugging which should help the
upcoming local mode development.

Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-04-27 16:09:50 +01:00
Pablo Carranza Velez
6c4eaff02f On startup, only attach to logs for running containers, and remove any containers marked as dead
Closes #611
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-04-19 15:04:04 -07:00
Akis Kesoglou
1cde9dd16d Properly propagate delta failure
Change-Type: patch
Closes: #627
2018-04-18 18:34:42 +03:00
Pablo Carranza Velez
015d33f8f5 Allow services (and their images) to expose udp ports besides tcp
Closes #621
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-04-11 15:13:48 -07:00
Cameron Diver
1c27ebc354
Fix parsing of non-unit memory numbers and add tests
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-04-04 14:03:24 +01:00
Cameron Diver
7d233ea111
Fix regex for parsing memory numbers
It now allows a trailing `b`, as the docker-compose docs specify.

In addition the regex now specifies a case-insensitive flag, to catch
both upper and lower case memory numbers (the rest of the function
supported these already).

Change-type: patch
Closes: #603
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-04-04 11:25:37 +01:00
Cameron Diver
393671505c
Respond to reboot and shutdown endpoints with a success object
Change-type: patch
Closes: #607
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-03-29 13:11:02 +01:00
Pablo Carranza Velez
72a5f03b0c
Back off fetching the target state exponentially, for faster retries when there's no connectivity
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-29 10:20:52 +01:00
Cameron Diver
e458c4103c
Handle incorrectly parsed env vars from docker inspect
Change-type: patch
Closes: #604
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-03-26 16:56:06 +01:00
Pablo Carranza Velez
348ff66cee
Replace the gosuper component with a node module that handles communication with systemd, and stop using an init system in the supervisor container
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-22 15:55:15 +00:00
Pablo Carranza Velez
c8d79c3b7d Remove any leftover knex migrations locks before running migrations
Closes #598
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-21 18:20:15 -03:00
Pablo Carranza Velez
d46d6513b5 Trim whitespace from the hostname file on the host before passing it as the hostname for containers with host network
Closes #594
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-19 17:19:59 -03:00
Pablo Carranza Velez
e1e33b376e Force reboots and shutdowns if lock override is enabled
Closes #440
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-19 16:30:59 -03:00
Pablo Carranza Velez
91ac11d0e8 In /v1/apps/:appId/stop, wait for the service to exit before responding
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-16 15:13:15 -03:00
Pablo Carranza Velez
5d7e8afcee Avoid trying to clean up the supervisor image if it has several tags (even though it would never succeed)
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 22:38:52 -03:00
Pablo Carranza Velez
75ce55e932 Fix typo passing apiKey to the resin API client when exchanging apikeys
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 21:50:31 -03:00
Pablo Carranza Velez
7e342e9d80 Fix the check for whether the device is provisioned by correctly getting registered_at and deviceId from config.json into the ApiBinder
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 21:50:31 -03:00
Pablo Carranza Velez
08a98f47e4 compose: Use the hostname on the host as default hostname for services with host network mode
Otherwise if the hostname on the supervisor container differs from the hostname on the host, the current and target
services will never match.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 21:18:11 -03:00
Pablo Carranza Velez
557b6a8d07 Pass the correct working_dir to the container config, and compare containers for working dir changes
We were getting the correct working dir from the compose or image config, but not really using it.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 15:41:19 -03:00
Pablo Carranza Velez
1febdc9eb0 DeviceConfig: avoid trying to enable or disable the VPN when in offline mode
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-14 10:15:07 +02:00
Pablo Carranza Velez
0101d62ace ApplicationManager: try to match available images by imageId to avoid keeping around unused image entries in the db
This should fix an issue where, on an update that only changes container metadata, the image install for the old image
is kept around on the API.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-13 18:45:26 -03:00
Pablo Carranza Velez
4ba4736aba compose: Emit a change event when a container is renamed, so that the updated imageId and releaseId are reported
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-13 18:45:26 -03:00
Pablo Carranza Velez
de654ec60e Skip taking the lock when updating the releaseId or imageId for a service that comes from a legacy supervisor
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-13 18:00:07 -03:00
Pablo Carranza Velez
9dfb76d2c8 When migrating from legacy supervisors, mark the temporary composition as legacy
We migrate to a default composition because we need to avoid deleting existing docker images, but
we need to use the legacy-container label to avoid potentially creating a duplicated container when a target state comes in.

(Just like we do for preloaded apps)

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-13 08:17:25 -07:00
Pablo Carranza Velez
f76aacc7fb Avoid trying to send a response to API calls after we've already sent an error
In some cases we were using early `return res.status(...).send(...)` to send 400 errors
but this happened inside a promise chain that later sent another status and response.

We fix this with the correct indentation of the success response so that an early return doesn't fall there.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-09 14:48:34 -08:00
Pablo Carranza Velez
79b4d39acd Fix passing a target service to start in /v1/apps/:appId/start, and getting the containerId
We weren't passing a "target" to serviceAction, which made the start action fail.
Plus we need to get the container again after starting to get the latest containerId.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-09 14:41:19 -08:00
Pablo Carranza Velez
f009e34293 migrations: Use the correct service name for legacy apps
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-09 06:54:16 -08:00
Pablo Carranza Velez
b6631b7367 ApplicationManager: only use dockerImageId to identify images for current apps, to avoid trying to delete an image that is in use
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-09 06:54:16 -08:00
Cameron Diver
d27c529ebe
Fix bug in require for migrations for legacy preload
Change-type: patch
Connects-to: #573
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-03-09 14:10:11 +00:00
Petros Angelatos
4ba020a784
compose: fix type error, createVolume returns a promise
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Change-type: patch
2018-03-09 00:00:44 -08:00
Petros Angelatos
7d03de51f6
lib: add missing flag to openAsync()
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Change-type: patch
2018-03-08 14:59:07 -08:00
Petros Angelatos
4b83a08512
compose: fix volume migration code
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Change-type: patch
2018-03-08 14:15:50 -08:00
Cameron Diver
a150dbf329
Convert object to array when normalising legacy target apps
Change-type: patch
Connects-to: #567
Signed-off-by: Cameron Diver <cameron@resin.io>
2018-03-08 15:48:03 +00:00
Petros Angelatos
cda561f997 Introduce workaround for IPv6 DNS resolution until nodejs becomes RFC 3484 compliant
Change-Type: patch
2018-03-07 07:01:43 -08:00
Pablo Carranza Velez
1b043230a5 Send logs to the resin API by default
Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 21:10:04 -08:00
Pablo Carranza Velez
15da221382 Implement a new logger that sends logs to the resin API, that can be used optionally instead of PubNub
Change-Type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 21:09:06 -08:00
Pablo Carranza Velez
16f12920c1 Fix the way commands and entrypoints in string form are parsed
Turns out shell-quote's parse function also replaces environment variables, which we don't want in this case. So we escape dollar signs
before calling shell-quote's parse function.

Also shell-quote takes some characters like `>` and globs and returns an object - so we return those objects to string form.

This should still be simpler/better than writing our own shlex.split, I hope...

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
dc62418db4 Some fixes in current state reporting, error handling for "container not found", plus more style improvements
Also, ensure the properties argument to eventTracker.track is an object

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
bb57bcc37c Fix default volume name in migrations, and do not use the legacy-container flag on containers from older supervisors (they'll be restarted anyways)
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
58fede2976 Only report initial config variables when they're different from the default
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
58b167b43d Various bugfixes and sytlistic improvements
* Use the correct defaults for the delta config variables that have them

* Only mount /lib/firmware and /lib/modules if they exist on the host

* hardcode-migrations.js: Nicer line separation

* APIBinder: switch to using a header for authentication, and keep credentials saved in the API clients

* Fix hrtime measurements in milliseconds

* Do not uses classes for routers

* compose: properly initialize networkMode to the first entry in networks if there is one

* Fix some details regarding defaults in validation and service

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
ec22bfcb29 Support for several compose features
Plus a few bugfixes.

* Add support for cgroup_parent

* Add support for specifying a single value in tmpfs

* Fix support for extra_hosts

* Add support for group_add

* Add support for pid mode (only host and empty value are supported for now)

* Add support for pids_limit

* Add support for security_opt

* Add support for storage_opt

* Add support for userns_mode

* Add support for ipc (except for another container's)

* Add support for mac_address

* Add support for oom_kill_disable

* Add support for 'user' compose option

* Add support for working_dir and fix support for user when image specifies it

* Add support for bind-mounting the balena socket using a label

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
38c3a8bdf3 Avoid starting services that exit repeatedly
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
ba829412e1 Various bugfixes
* Get imageId when normalising a dep. app from the DB

* Fix the appId in migrations when updating the supervisor

* Use the update lock to update a service's metadata

* Restart clears volatile target state

* Fix function definition for updateMetadata

* Improve backwards compatibility of /v1/apps/:appId endpoint

* Fix multicontainer deltas to work with resumable-request 2.0

* Fix dependent target normalisation logic

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Lucian Buzzo
da2359e224 Fix API payload when provisioning a dependent device 2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
7ed27ea203 Some fixes on migrations, dependent devices and deltas
* Switch default dependent device type to generic

* Reduce noise in logs

* Limit to 3 simultaneous delta downloads

* Better check for deltaSource

* When checking volume dependencies, do not compare regular (non-named) volumes

* Store imageId for dependent apps, and don't report dependent images with invalid imageIds

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
e43c9052dd Improve backwards-compatible response of GET /v1/device
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
3fd52bb0c7 Simplify the update logic by making fetch and kill (the only long-running actions) happen in the background, and always waiting for all actions before continuing
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:29 -08:00
Pablo Carranza Velez
c0ac2c21a4 Do not override stop_grace_period
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-03-06 10:32:28 -08:00