Commit Graph

1059 Commits

Author SHA1 Message Date
Pablo Carranza Velez
538e384442 Allow all config variables to take truthy or falsy values
Config variables now use a checkTruthy validation function,
and can be "1", "on", "true" or true to be considered true, or
"0", "off", "false" or false to be considered false.

Change-Type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-10 01:19:19 +02:00
Pablo Carranza Velez
9ae4f02bc5 Allow setting the supervisor to a "local mode" which stops apps and prevents cleanup
A RESIN_SUPERVISOR_LOCAL_MODE variable is introduced. When this variable is "1", all apps
are stopped and the update cycle stops executing changes other than deviceConfig changes
and the proxyvisor.

Change-Type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-10 01:19:19 +02:00
Pablo Carranza Velez
9d36064bdb Quick fix: unindent the definition for dockerUtils.createContainer
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-09 08:57:26 -03:00
Pablo Carranza Velez
b6206f9012 Issues #23 and #236: Use docker logs to get all logs from the container, including those before supervisor start
We've been using docker attach, which only gives us the logs since we attach. This change allows getting the
full logs from the beginning.
We also use the timestamps that come with the logs from docker, as they will be more precise and are more relevant now
that we're getting previous logs from history.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-07 17:26:38 +02:00
Pablo Carranza Velez
b64ed9568c Issues #389 and #390: Remove /host_run/dbus and /host/var/lib/connman bind mounts for non-ResinOS-1.X devices
On ResinOS 2.X the default mounts should not include the previously deprecated host_run, and there's no connman which makes the connman mount confusing.
This is a breaking change as it is not backwards-compatible on non-ResinOS instances of the supervisor.

Change-Type: major
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-07 17:26:23 +02:00
Pablo Carranza Velez
f7c702b845 Issue #386: Allow forcing updates when an update was already scheduled
The logic for updateStatus.forceNext is changed so that its value is checked when the scheduled update is run, instead
of when the update is scheduled. And when an update is already scheduled and a new request comes in,
we mark forceNext as true if the new request requires a force update.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-03-07 17:06:10 +02:00
Pablo Carranza Velez
e8fbadb8d6 Issue #381: Set target deviceConfig values from preloaded apps
Also split out deviceConfig set and get to a separate module to avoid circular dependencies.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-01-19 13:56:20 -03:00
Pablo Carranza Velez
0d870954ef Issue #382: Validate delta timeout variables
Also take validation functions into a module, and use that in all cases where
we need to check for an integer or string.

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-01-18 12:28:24 -03:00
Pablo Carranza Vélez
0e76b540ea Merge pull request #379 from resin-io/378-delta-timeout
Increase delta timeouts, and provide nicer message when the delta server times out
2017-01-17 18:49:19 -03:00
Pablo Carranza Velez
9c8ac58128 Issue #378: Increase delta timeouts (to avoid ESOCKETTIMEOUT errors), make them configurable, and provide nicer message when the delta server times out
Current delta timeouts are too limiting, so we increase the request timeout to 30 minutes which is big enough that
the server will time out first and we can provide a nice message letting the user know we'll retry; and we increase
the total timeout to 24 hours to account for really big deltas over slower connections (the rsync calls will time out anyways
if something else goes wrong, as they have a 5 minute I/O timeout).

The timeouts are now configurable with the RESIN_SUPERVISOR_DELTA_REQUEST_TIMEOUT and RESIN_SUPERVISOR_DELTA_TOTAL_TIMEOUT
configuration variables.

Change-Type: minor
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-01-17 14:21:10 -03:00
Pablo Carranza Vélez
6ab2b45104 Merge pull request #370 from resin-io/359-kmod-only-in-resinos1
[Breaking] Do not bind mount kmod if the host is not Resin OS 1.X
2017-01-16 12:51:08 -03:00
Pablo Carranza Velez
f8d3ea1a22 Add a delay between successive updates of device state to the API
We add a 1s delay between requests to the API to apply state changes,
as this will throttle it to a point that it has a reasonable rate while
preventing too many unnecessary requests to the API.

Closes #375

Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-01-12 15:57:09 -03:00
Pablo Carranza Velez
458add1759 Do not bind mount kmod if the host is not Resin OS 1.X
Resin OS 2.X removes the use of compressed modules, which was the initial
motivation for us to bind mount kmod into user containers (as Debian distros
don't include support for compressed modules).

This is a breaking change, but we still keep bind mounting on devices that are
on 1.X to ensure we don't break apps currently relying on the feature.

Implementation note: some functions in device.coffee have been refactored to
extract (DRY) a memoization procedure for Promise-returning functions.
`device.getOSVersion()` now also memoizes its result.

Change-Type: major
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-01-04 18:48:45 -03:00
Pablo Carranza Velez
c67977cbed Fix error applying device configuration because deviceConfig table is empty
If there's no entries in deviceConfig table, always create one.

Avoids problems if the supervisor is stopped while running the db initialization
(deviceConfig gets created but not populated).

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2016-12-20 03:01:55 -03:00
Pablo Carranza Velez
fefb1e6928 Fallback to DROP when iptables REJECT is not available
Using REJECT allows better feedback for legitimate users while providing the same level
of security than drop (see http://www.chiark.greenend.org.uk/~peterb/network/drop-vs-reject).

But some hosts don't have REJECT support in the kernel config, so in that case we fall back to DROP.
2016-12-01 11:18:06 -03:00
Pagan Gazzard
01cd0cbc5a Fix an error when trying to call logSystemEvent with an undefined app 2016-11-03 19:43:15 +00:00
Pablo Carranza Velez
5bcff712dc Provide a better error message when app is not found for purging 2016-11-01 12:20:51 +00:00
Pablo Carranza Velez
0e2710152b Only iterate through remote apps to set device config 2016-10-31 21:41:35 +00:00
Pablo Carranza Velez
9af4ed0397 Properly delete dependent apps and their corresponding devices 2016-10-31 03:05:45 +00:00
Pablo Carranza Vélez
fe68b27acb Merge pull request #336 from resin-io/request-timeout
Add Promise timeouts to all external requests
2016-10-30 21:47:21 -03:00
Pablo Carranza Velez
ac02d50715 Improvements in container create/start:
* Add HostConfig in container create instead of start
* Make it clear in logs when container was already running
2016-10-29 10:20:44 -03:00
Pablo Carranza Velez
c06e047fba Add Promise timeouts to all external requests 2016-10-28 15:12:08 -03:00
Pablo Carranza Velez
3325ff47d4 Stop all apps before rebooting or shutting down 2016-10-27 20:18:30 -03:00
Pablo Carranza Velez
6077f1add4 Update request-progress to v2.0.1 2016-10-25 16:29:53 -03:00
Pablo Carranza Velez
e9e1a0b277 Use multiArgs to promisify gosuper requests
With the bluebird update to v3, all requests to gosuper (most notably, getting the IP addresses) got broken as we use .spread, which requires the Promise to fulfill with an array. So we need to add multiArgs so that getAsync and postAsync return an array.
2016-10-24 16:26:00 -03:00
Pablo Carranza Velez
d3761a699b Also make it explicit in mixpanel events when it's a full image download 2016-10-24 16:11:47 -03:00
Pablo Carranza Velez
43c1b2f92c Log whether deltas are being used when downloading an app 2016-10-23 20:18:20 -03:00
Pagan Gazzard
4ed64536ec Fix multiple update loops appearing after a long period of updates failing. 2016-10-21 16:03:24 -07:00
Pablo Carranza Velez
70dc744886 Avoid restarting the app if the device name changes 2016-10-21 18:40:03 -03:00
Pablo Carranza Velez
d6aead1bad AUFS support and dependent app assets improvement:
* Use appId in dependent app assets tar path, and only create the tar if it doesn't exist
* Support AUFS by upgrading node-docker-delta to 1.0.0 and docker-toolbelt to 1.3.0
2016-10-21 16:37:57 -03:00
Pablo Carranza Velez
8361a533a1 Send the uuid as distinct_id for mixpanel events 2016-10-21 16:36:11 -03:00
Pablo Carranza Velez
7bb3931f2c Properly set device name, and set undefined arguments to setConfig as null 2016-10-13 15:13:47 -03:00
Pagan Gazzard
158ce2810c Update knex to ~0.12.3 2016-10-11 12:04:28 -07:00
Pablo Carranza Velez
72d0401403 Do not use parsed JSON to compare dep. device state 2016-10-11 12:13:14 -03:00
Pablo Carranza Velez
6feba39948 Fix docker utils getImageEnv by correctly parsing the returned array 2016-10-10 21:58:20 +00:00
Pagan Gazzard
969d714baf Update to bluebird 3 2016-10-10 12:49:54 -07:00
Pablo Carranza Velez
feb97539ef Improvements in proxyvisor:
* Better parameter handling in PUT /v1/devices/:uuid
* An update hook response of 200 will cause the proxyvisor to stop pinging the hook
* Allow deleting dependent apps and devices
* Implement delete dependent device hook
* Omit some fields when responding with a device object
2016-10-10 18:16:16 +00:00
Pablo Carranza Velez
ceb5016fc3 Add validation to dependent device provisioning 2016-10-08 20:42:50 +00:00
Petros Angelatos
04edb15819 remove resolv.conf bind mount
connects to #310

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-10-07 16:36:18 -07:00
Page-
3a2ec489b8 Merge pull request #303 from resin-io/cleanup
Remove unnecessary Promise.all
2016-10-06 14:59:29 -07:00
Pagan Gazzard
81cb59262f Remove unnecessary Promise.all 2016-10-05 18:31:29 -07:00
Pablo Carranza Velez
c4e5d7afca Improvements on config and dependent device handling:
* Store config vars when there's nothing else to update
* Do not mark an update as failed if the hook failed
* When hitting the dependent devices hook, send appId as int
2016-10-05 23:21:29 +00:00
Pagan Gazzard
5c10644df7 Update to lodash 4 2016-10-05 23:03:12 +00:00
Pablo Carranza Velez
4785437ba8 Fixes in app restart behavior:
* Compare config vars to trigger an app restart
* In delete-then-download, only delete when a download is needed
2016-10-05 19:45:18 +00:00
Pablo Carranza Velez
503e043c4c In cleanup, normalize all image tags for comparison 2016-10-04 17:48:11 -03:00
Pablo Carranza Velez
ddaa9f12db Use getRegistryAndName from docker-toolbelt 1.2.0 2016-10-04 14:43:45 -03:00
Pagan Gazzard
19db0e78e0 Switch to v2 api to be able to set is_online 2016-09-30 23:40:03 -03:00
Pablo Carranza Velez
a6f2ff074c Dependent devices, state endpoint, extra env vars and deviceConfig:
* Implement proxyvisor API with dependent device handling
* Use the state endpoint from the API to get the full device state
* Add a deviceConfig db table to store host config separately, and allow deleting config.txt entries
* Expose RESIN_APP_NAME, RESIN_APP_RELEASE, RESIN_DEVICE_NAME_AT_INIT, RESIN_DEVICE_TYPE and RESIN_HOST_OS_VERSION env vars
* Add missing error handler on a stream in docker-utils
2016-09-30 23:40:03 -03:00
Pablo Carranza Velez
e7acff0bcf On cleanup, force removal for images and containers, and remove container volumes 2016-09-29 19:34:19 -03:00
Pablo Carranza Velez
f385fe6bcc Add system logs for Shutdown, Reboot and Purge 2016-09-28 03:32:38 +00:00
Pablo Carranza Velez
4a99fd8803 Implement delete-then-download update strategy 2016-09-26 18:16:01 +00:00
Kostas Lekkas
05690a81dc typo: fix startAppError message 2016-09-20 11:35:28 +03:00
Pablo Carranza Velez
16e2ec286e DRY up calls to gosuper API, and use empty Host header 2016-09-13 16:52:25 -03:00
Praneeth Bodduluri
2cc4b0fb46 Add iptables rules to allow resin-vpn named interface to be used by VPN 2016-09-09 17:41:35 +05:30
Alexios Theodoros Brezas
12a4560518 Catch exec format error and provide friendlier message 2016-09-05 18:22:20 +00:00
Theodor Gherzan
32bf433af1 device.coffee: Remove hardcode of resin-boot partitions's mount point
Signed-off-by: Theodor Gherzan <theodor@gherzan.ro>
2016-09-02 19:55:01 +00:00
Pablo Carranza Velez
ec178f7a7f Use a more conservative message size, and properly account for URI encoding 2016-08-31 16:28:42 +00:00
Pablo Carranza Velez
78b4570b93 Allow storing several messages, will allow us to withstand log bursts better
Also, send a warning message when we start dropping logs.
2016-08-29 19:03:06 -03:00
Pablo Carranza Velez
a8dd29cd82 Change the logger to send at a specific interval and with a different message format
Log messages to PubNub are now an array instead of an object.
Each element of the array is an object with m (message), t (timestamp) and s (isSystem, optional) attributes.
Logs are sent at a specific interval (110ms, fit with some margin to PubNub's approximated 10 messages/s limit), and truncated to PubNub's 32KB limit.
2016-08-29 19:03:06 -03:00
Pablo Carranza Velez
1eb63366ee Allow using an HTTP header for auth 2016-08-16 20:39:55 +00:00
Pablo Carranza Velez
145d124410 Check if rules exist before adding them 2016-08-16 09:30:38 -03:00
Pablo Carranza Velez
c4ea2c77a0 Add iptables rules to block requests to the supervisor API from all interfaces except vpn, docker and local 2016-08-15 18:02:36 -03:00
Petros Angelatos
dd06f993ce bootstrap: if offlineMode is enabled, persist only the uuid
If we don't persist the uuid then every time the supervisor starts it
will think it's a new device. This triggers a wipe of the local state
and also a re-load of the preloaded apps. This in turn causes multiple
instances of the preloaded apps to be left running.

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-08-02 23:48:13 -07:00
Petros Angelatos
5ee15e664e utils: allow specifying links in compose files
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-07-28 17:45:16 -07:00
Petros Angelatos
b708f05476 utils: sort compose options
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-07-28 17:43:26 -07:00
Petros Angelatos
eb09713391 Merge pull request #216 from resin-io/215-improve-containers-api
Improve containers API
2016-07-26 20:52:56 -07:00
Petros Angelatos
66fe7fc30c logger: empty the publish queue if in offline mode
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-07-26 14:04:51 -07:00
Pablo Carranza Velez
98d9aca92d Allow the supervisor to work in offline mode
A supervisorOfflineMode true-ish attribute in config.json will cause that:
* If unprovisioned, the supervisor won't try to provision on Resin
* The update cycle will not start as the device won't consider itself provisioned
* Logs will not be sent to pubnub
* Mixpanel events won't be tracked
* The device state won't be updated to the Resin API

This change will also make the Supervisor API work with an unprovisioned device.
2016-07-23 14:04:24 +00:00
Pablo Carranza Velez
02e111ff62 Allow only the options that we know can be supported 2016-07-22 23:28:28 -03:00
Pablo Carranza Velez
4db78b9743 Allow purging and deleting a container from the DB with a purge option 2016-07-22 23:17:25 -03:00
Pablo Carranza Velez
0b4f50d207 Avoid creating duplicate entries in the image table 2016-07-22 23:17:25 -03:00
Pablo Carranza Velez
1d16941a2d Fix cleanup of official images, and allow passing Name in container options 2016-07-22 23:17:25 -03:00
Pablo Carranza Velez
e41ebbb52b Add validation for options when creating and starting containers 2016-07-22 23:17:25 -03:00
Pablo Carranza Velez
54288f036a Improve the docker compose API
- Validate the options in the YAML file
- Define bind mounts for each service as in Resin apps
- Keep the modified compose file inside the supervisor's /data folder
- Fix error reporting in the first stage of "up"
2016-07-22 23:17:25 -03:00
Pablo Carranza Velez
b97fe634d5 Add default binds to containers created with API, add /v1/containers/update endpoint, and add a /data bind with an internal id 2016-07-22 23:17:25 -03:00
Kostas Lekkas
761a0cbd82 Fix double-printed logs after container restart 2016-07-21 22:39:19 +03:00
Pagan Gazzard
8715534d84 Run the linting automatically as part of the jenkins build. 2016-07-19 14:37:46 -07:00
Pablo Carranza Velez
0609619863 Do not bind mount /run/dbus to /run/dbus 2016-07-19 02:13:34 +00:00
Pablo Carranza Velez
f5b0a4e7e7 Default to not bind mounting kmod if container distro can't be found 2016-07-18 16:49:45 +00:00
Pablo Carranza Velez
102eb460db Use log-timestamp to add timestamps to logs 2016-07-18 14:01:16 +00:00
Pablo Carranza Velez
5f926faa70 Bind mount kmod if the container is debian or raspbian
Use docker-toolbelt module.
The bind mount is read-only.
2016-07-15 20:46:09 +00:00
Pablo Carranza Vélez
08d74b578b Fix preloaded apps by passing appId to extendEnvVars 2016-07-06 17:56:51 -03:00
Pagan Gazzard
6cb4b090c5 Rename pullImage to pullAndProtectImage to make it a bit clearer that it isn't a simple pull 2016-06-24 21:08:47 +00:00
Pagan Gazzard
707ed7e1f6 Deduplicate compose command running logic. 2016-06-24 21:08:47 +00:00
Pagan Gazzard
a371e35d5c Deduplicate knex app fetching logic. 2016-06-24 21:08:47 +00:00
Pablo Carranza Velez
4278b6baf1 Add endpoints for docker-compose up and down 2016-06-24 21:08:46 +00:00
Kostas Lekkas
d64d413838 Remove unused vars and fix linting issues 2016-06-16 18:47:12 +03:00
Pablo Carranza Velez
164d565283 Make the data path configurable 2016-06-14 13:50:50 -03:00
Pablo Carranza Velez
a8677a4401 Add listener for container events and reattach on restart 2016-06-11 11:55:22 -03:00
Pablo Carranza Velez
6e39128f3a fix deltas by not using the supervisor as source 2016-06-10 17:22:52 -03:00
Petros Angelatos
573cf31514 fix delta error handling by listening for the 'error' event
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-06-10 19:19:23 +00:00
Alexios Theodoros Brezas
e3f480c217 Container restart policy specificiation.
Allow users to set container restart policy using environment variables.

RESIN_APP_RESTART_POLICY sets the name of the policy, and
if policy is "on-failure", optionally, RESIN_APP_RESTART_RETRIES
sets the maximum number of retries.

More information on docker docs:
https://docs.docker.com/engine/reference/run/#restart-policies-restart

One major change we introduce here is that the default policy is set
to always while we used to have the default "no".

We validate the arguments and pass retries parameter only for the case
of "on-failure" as specified in Docker API as of v1.19.
We could let docker handle the arguments directly, gaining
forwards-compatibility with any new features, but I opted
for an implementation that is as well-defined as possible.
2016-06-07 12:49:30 -03:00
Petros Angelatos
20419bee3b Switch to docker-delta library to use deltas v2
This npm library implements the new delta format and also works with
docker 1.10.

Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-06-04 01:04:34 +00:00
Pablo Carranza Velez
7104806ad1 Correctly compare container image name on cleanup
Docker 1.10 sends containerInfo.Image without the ":latest", so
the image name doesn't match the app's imageId.
This fix first splits the image name into repo and tag and then rebuilds
it to include ":latest" when appropriate. Should avoid removing containers
when using resin-sync.
2016-06-02 14:55:12 -03:00
Kostas Lekkas
383be0946e bugfix: do not mutate original env vars object 2016-06-01 00:02:53 +03:00
Kostas Lekkas
6193ebe1df Log useful supervisor info to stdout/stderr 2016-05-30 16:51:27 +03:00
Pablo Carranza Velez
ed7b936fee Use buffer-equal-constant-time to evaluate apikey 2016-05-23 23:59:45 -03:00
Pablo Carranza Velez
25be1176d2 Add changelog for alpine super and fix version reporting 2016-05-19 16:25:49 +00:00
Pablo Carranza Velez
d58517f32d Use rwlock to block when images are being pulled 2016-05-19 13:24:23 +00:00
Pablo Carranza Velez
95f4fdb97f Add /v1/images/load endpoint 2016-05-18 13:47:54 -03:00
Pablo Carranza Velez
951bd2888f Fix routing for deleting images with a slash in the name 2016-05-17 19:18:39 +00:00
Pablo Carranza Velez
7b9eaeea3a Add some protections to avoid deleting supervisor or app containers 2016-05-17 00:03:23 +00:00
Pablo Carranza Velez
3a77c2ec4b Allow passing tag when using fromImage in /v1/images/create 2016-05-13 10:35:03 -03:00
Pablo Carranza Velez
dcc3717949 Use Routers to separate endpoints with bodyParser 2016-05-13 10:35:03 -03:00
Pablo Carranza Velez
5d822b8dab Allow pulling images too 2016-05-13 10:35:03 -03:00
Pablo Carranza Velez
3d2f3ad94b Implement container management endpoints 2016-05-11 15:43:21 +00:00
Pablo Carranza Velez
8101d08433 Add endpoints to create, delete and list images, and also list containers 2016-05-11 14:44:05 +00:00
Pablo Carranza Velez
67a7271995 Add RESIN_APP_ID variable 2016-05-09 19:35:35 -03:00
Pablo Carranza Velez
7039b23ad9 Increase delta request timeout to 15 minutes 2016-05-02 17:33:21 -03:00
Kostas Lekkas
8577280dc5 Merge pull request #126 from resin-io/add-stop-start-endpoints
WIP: Add stop, start and get app endpoints
2016-04-25 13:27:08 +03:00
Kostas Lekkas
01e39825b4 Style fixes, select() app columns to return in /v1/apps 2016-04-21 09:58:36 +03:00
Kostas Lekkas
f76b38eb49 Use exclusion lists for keys/columns to be omited from the /v1/apps endpoint 2016-04-20 19:43:16 +03:00
Kostas Lekkas
e03e5ed0ae Address review comments 2016-04-20 19:08:35 +03:00
Kostas Lekkas
757e5b3244 Return container Id from the /v1/start and /v1/stop endpoints 2016-04-20 15:49:22 +03:00
Kostas Lekkas
809609dd76 Set containerId to null if container gets removed after a failed start attempt 2016-04-20 14:53:56 +03:00
Pagan Gazzard
f910ec11a8 Remove even more old terminal related stuff. 2016-04-18 18:13:23 +01:00
Kostas Lekkas
4e3106154d Require lodash 2016-04-18 19:04:06 +03:00
Pablo Carranza Velez
1c69f14e82 Refactor into /apps/:appId endpoint namespace, and add endpoint to GET the app 2016-04-16 13:52:38 -03:00
Pagan Gazzard
135365cf37 Remove the old terminal code, since it has been replaced by v2 which does not require supervisor support. 2016-04-15 23:36:28 +01:00
Pablo Carranza Velez
7161564123 Add /v1/stop and /v1/start endpoints 2016-04-08 16:51:39 -03:00
Pablo Carranza Velez
d0f748379e Fix log message for setLogToDisplay 2016-03-23 17:59:44 -03:00
Pablo Carranza Velez
adb7ef1140 Omit host config also when formatting local apps 2016-03-23 17:36:04 -03:00
Pablo Carranza Velez
9fea0a729b Use json to print boot config 2016-03-23 17:24:03 -03:00
Pablo Carranza Velez
8771307c39 Lodash 3 has no omitBy 2016-03-23 16:48:23 -03:00
Pablo Carranza Velez
c9968f7bbc Improve logging, plus some style fixes 2016-03-23 12:21:15 -03:00
Pablo Carranza Velez
eddc58ee86 Finish log to display setting. Add logging to host config. Save host config before rebooting. Allow applying boot config to RPi3. 2016-03-23 12:21:15 -03:00
Pablo Carranza Velez
2c5bc8b90a Add nodejs side of enabling/disabling log to display 2016-03-23 12:21:14 -03:00
Alexios Theodoros Brezas
3d082aaaa8 mount to /host dir 2016-03-23 04:15:02 +00:00
Alexios Theodoros Brezas
84d42ca6de Bind mount /var/lib/connman to application containers.
This allows application containers to interface with host connman.

Host /var/lib/connman is bind mounted to /host_var/lib/connman to avoid
collisions with connman installations inside the container.
2016-03-23 04:15:01 +00:00
Pablo Carranza Velez
f29bab0b9d Add RESIN_SUPERVISOR_DELTA to special list so that app is not restarted when it changes 2016-03-09 10:53:48 -03:00
Kostas Lekkas
fcaafd9033 Reduce noise in logs 2016-03-07 13:16:38 +02:00
Pablo Carranza Velez
a4b08e389e Add more update-related fields to the GET /v1/device endpoint 2016-02-18 16:53:15 +00:00
Pablo Carranza Velez
d0c76aec0f Use a closure for device state and also report in GET /v1/device whether there's a pending update 2016-02-18 16:53:15 +00:00
Pablo Carranza Velez
670f318c39 Add endpoint to get device state 2016-02-18 16:53:15 +00:00
Pablo Carranza Velez
b088612ddd Check for valid strings or ints in all config values 2016-02-18 12:52:00 -03:00
Pablo Carranza Velez
71bd742dfe Remove quotes in OS version 2016-02-15 19:03:06 +00:00
Pablo Carranza Velez
27e8e3c027 Update docker-progress and drop default port from repo tag 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
78f0df281b Replace dockersync.sh with node and dockerode stuff. Don't install docker. Add Dockerfile changes for armel. 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
676f6699fe Nicer use of spawn 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
9dd1fa2408 Catch out of sync errors falling back to scratch. Make update retries more dependent on number of failures 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
d3fea26c11 Send both source tag and Id to delta server 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
b9eb6836be Better check for source image.
Don't use config.supervisorImage, and use image Id's instead of tags.

Also, change the RESIN_DELTA var into the RESIN_SUPERVISOR_ namespace.
2016-01-28 11:08:42 -03:00
Pablo Carranza Vélez
5b48856c9a Bring back request - and show an error when talking to delta server fails 2016-01-28 11:08:42 -03:00
Pablo Carranza Vélez
1a5a9b0e23 findSimilarImage should always return an array, and test the repoTag[0] 2016-01-28 11:08:42 -03:00
Pablo Carranza Vélez
8e4e844cfa JSON.parse env before checking for delta, and use progress.percentage 2016-01-28 11:08:42 -03:00
Petros Angelatos
1bc149866d deltas: sync() after running rsync on the new subvolume 2016-01-28 11:08:42 -03:00
Petros Angelatos
f7a2668c4f config: change default delta endpoint to https and production
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-01-28 11:08:42 -03:00
Petros Angelatos
f6f88941eb delta: only use deltas when RESIN_DELTA is set
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2016-01-28 11:08:42 -03:00
Petros Angelatos
582e3322ec Set a 5 min timeout to delta requests 2016-01-28 11:08:42 -03:00
Petros Angelatos
88f0e4e229 Fix typo 2016-01-28 11:08:42 -03:00
Petros Angelatos
a12ebf884b Increase rsync timeout to 5 mins 2016-01-28 11:08:42 -03:00
Petros Angelatos
83931a0915 Add timeout to prevent rsync from hanging 2016-01-28 11:08:42 -03:00
Petros Angelatos
071ee3dcf4 Ignore output from dockersync.sh 2016-01-28 11:08:42 -03:00
Petros Angelatos
79d638f4f5 Pass the --delete parameter to rsync 2016-01-28 11:08:42 -03:00
Petros Angelatos
f6eafb7b96 Always send the final progress event 2016-01-28 11:08:42 -03:00
Petros Angelatos
004286a07e Tag the target image at the last step 2016-01-28 11:08:42 -03:00
Petros Angelatos
595f80e031 Fix rsync stream resumption 2016-01-28 11:08:42 -03:00
Petros Angelatos
7eefee77d0 Fix config var typo 2016-01-28 11:08:42 -03:00
Petros Angelatos
8c7964684a Return the supervisor tag containing the git commit 2016-01-28 11:08:42 -03:00
Petros Angelatos
d0b6ba1721 Switch to http default transport 2016-01-28 11:08:42 -03:00
Petros Angelatos
bd2f31624b Delete unused functions 2016-01-28 11:08:42 -03:00
Petros Angelatos
10e166020e Speed up rsync diff application 2016-01-28 11:08:42 -03:00
Petros Angelatos
c13e16c96a Remove fallback to docker pull 2016-01-28 11:08:42 -03:00
Petros Angelatos
9adbd81bc0 Avoid shadowing the config variable 2016-01-28 11:08:42 -03:00
Petros Angelatos
11dfbd1687 Don't timeout while waiting for delta 2016-01-28 11:08:42 -03:00
Petros Angelatos
cbde944565 Implement rsync diff fetching method 2016-01-28 11:08:42 -03:00
Pablo Carranza Velez
3e3e2a8d99 Quickfix again: Cast buffer to string when getting OS version. (Sorry) 2016-01-27 17:17:53 +00:00
Pablo Carranza Vélez
94e34ee990 Quickfix: use String .split instead of _.split
lodash 3 doesn't have the _.split function :S
2016-01-26 20:56:19 -03:00
Pablo Carranza Velez
8a4514ac00 Report Host OS version to the API 2016-01-26 10:20:04 -03:00
Pablo Carranza Velez
0f20251a8b Use _.defaults instead of _.extend to ensure internal env vars are not overwritten 2016-01-22 12:40:41 -03:00
Pablo Carranza Velez
11b5e0abc9 Expose resin API key to apps 2016-01-21 17:50:47 -03:00
Pablo Carranza Velez
5961be6ffb Set status to Idle when download is over 2016-01-21 10:52:36 -03:00
Pablo Carranza Velez
7d31ae9b24 Set download_progress to 0 when beginning download 2016-01-15 16:59:55 +00:00
Praneeth Bodduluri
fb47f73907 Add missing container filtering + Address PR Comments by removing regexp and making more idiomatic choices 2016-01-12 17:58:07 +05:30
Praneeth Bodduluri
396fe7d619 Initialize DOCKER_SOCKET in entry.sh 2016-01-08 18:30:14 +05:30
Pablo Carranza Vélez
17deb53c7c Revert "Make config.json writes atomic" 2016-01-07 21:01:12 -03:00
Pablo Carranza Velez
c29f54b08c Make config.json writes atomic 2015-12-19 02:14:07 +00:00
Praneeth Bodduluri
89abff57f6 Fix: Duplicated exports.connectivityCheck in utils.coffee 2015-12-10 20:30:04 +05:30
Pablo Carranza Velez
50137c163d Bugfix: assign app.containerId before attaching logger 2015-12-04 23:27:45 +00:00
Pablo Carranza Velez
f0afdb9b2a Only save the app if starting the container was successful 2015-12-02 11:37:47 -08:00
Pablo Carranza Velez
ac0917b114 Quick-fix: knex.select doesn't have .get() 2015-12-01 09:51:06 -08:00
Pablo Carranza Velez
10350c3d4a Remove volumes when removing a container 2015-11-25 15:00:45 -08:00
Pablo Carranza Vélez
cbb3e2f461 Improve the update strategies:
* On handover, fetch old app from DB before starting the new app (and overwriting the DB record)
* Tidy up the logging
* Fix waitToKill so that it actually works
* Several other fixups
2015-11-23 10:02:19 -08:00
Pablo Carranza Vélez
1d6811a423 Implement waitToKill, keep RESIN_OVERRIDE_LOCK, and changelog for update strategies 2015-11-16 19:03:37 +00:00
Pablo Carranza Vélez
13dce75a21 Implement several update strategies
* Break up the update function into manageable parts
* Refactor the special variables into the RESIN_SUPERVISOR_ namespace
* Use three update strategies: normal, kill before download, hand over

TO-DO: implement waitToKill in the hand over case.
2015-11-16 19:03:36 +00:00
Praneeth Bodduluri
51ee79b7a2 Fix the error that comes up when no ip addresses are returned by gosuper 2015-11-12 20:33:18 +05:30
Pagan Gazzard
16a9cfa365 Switch to docker-progress for pull progress. 2015-11-10 17:29:22 +00:00
Praneeth Bodduluri
6bc92b4276 Fix semvar versioning in tcp-ping endpoint 2015-11-09 19:50:49 +05:30
Pablo Carranza Vélez
0605a9f4ee Use generic config.forceSecret[name] and allow forcing logsChannel 2015-11-03 13:49:24 -03:00
Pablo Carranza Vélez
b08a028d69 Use random secret for logs channel 2015-10-28 20:02:00 -03:00
Pablo Carranza Vélez
811e929955 Don't bind mount docker.sock. It doesn't exist on devices that use rce 2015-10-16 13:56:06 +00:00
Pablo Carranza Vélez
ee273f1ec7 Expose a RESIN_SUPERVISOR_VERSION env var to app 2015-10-15 23:08:21 +00:00
Pablo Carranza Vélez
4bcba5adf6 Refactor to use a different name for the env vars (otherwise resin-vars overrides it with a null value) 2015-10-14 18:50:26 -03:00
Pablo Carranza Vélez
33d402c3c0 Default PubNub and Mixpanel keys are now passed at build time 2015-10-14 16:53:33 -03:00
Pablo Carranza Vélez
7eb17bd79b Don't let the bootstrap delete apiSecret from DB 2015-10-13 13:45:08 -03:00
Pablo Carranza Vélez
b57dd10e81 Add API endpoint to expire and create new API key 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
4130df7771 Add Changelog and switch to using RESIN variables 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
96d4aebb76 Refactor api.go to use abstracted sendResponse and sendError - Also fix most go doc complaints 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
4413397103 Abstract update polling function and fix wrong comment for disabling logging 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
8fe516253a Modify the earlier logic of Interval instead of a timeout 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
50a804683d Use Promises for requests+ Add better console logs 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
9efcc59252 Reorganize callbacks to utils and check for status accepted from go supervisor 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
e43e11b3c1 Enable control of API poll interval through Device Variables 2015-10-13 13:45:08 -03:00
Praneeth Bodduluri
b91cb78eea Allow control of VPN + TCP check + Pub nub logs with Device Environment variables 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
3d7f5f3ced Fix getting API key from DB by returning its .value 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
e975f0f69f Do auth for localhost too 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
ec6fd6eb03 Pass api key to app, and keep it saved in the DB (do not regenerate on startup) 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
6ed2fddd37 Wrap all update errors as Errors 2015-10-13 13:45:07 -03:00
Petros Angelatos
2d891262a7 wait 5s after sending SIGTERM and before sending SIGKILL
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
0fd03054e8 Expose supervisor API to app by allowing all requests from 127.0.0.1 and passing address and port as env vars 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
7f7a550363 Only apply boot config or special actions when env vars have changed and within lock, and persist the new env to the DB 2015-10-13 13:45:07 -03:00
Pablo Carranza Vélez
8da8092104 Use a function in utils to extend env vars 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
65df89aab6 Give extra environment variables to preloaded apps. Ensures the app is not unnecessarily restarted as soon as we gain connectivity. 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
d25447d539 Promisify executeSpecialActionsAndBootConfig and remount /boot rw 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
c136793cdd Blacklist certain config.txt entries, Update node to 0.10.40 everywhere
Use board-specific images until we have new arch based ones
2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
39a07b8cd4 Remove the RPi /boot bind mount 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
0e283e8e72 Actually apply config.txt changes and reboot
Keep the original statements where possible. (to ensure same config keys under different filters are not overwritten with always the same value)
2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
8b4d1e9f75 Ensure special env vars are persistent and add placeholder for device.setBootConfig 2015-10-13 13:45:06 -03:00
Praneeth Bodduluri
38df4651cb Change to using _.has 2015-10-13 13:45:06 -03:00
Praneeth Bodduluri
173d5ee651 Execute the callback function associated with the specialActionVars only once and remove unused parts 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
941d3b15af Allow special env vars with a callback which don't cause an app restart 2015-10-13 13:45:06 -03:00
Praneeth Bodduluri
66a4bf4ab3 Remove unused config.supervisorContainer in config.coffee 2015-10-13 13:45:06 -03:00
Pablo Carranza Vélez
bd889e06a1 Bind mount /boot in RPi 2015-10-13 13:45:06 -03:00
Praneeth Bodduluri
391a141843 Change ipAddress to IPAddresses and add error message on unknown ip addr type 2015-10-13 13:45:05 -03:00
Praneeth Bodduluri
ea0b058721 Change APIResponse to a struct with a Data Interface 2015-10-13 13:45:05 -03:00
Praneeth Bodduluri
e1957def25 Address style fixes in app.coffee 2015-10-13 13:45:05 -03:00
Praneeth Bodduluri
f86f5881d9 Implement and use golang endpoint for getting ipaddress' of the device 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
8eb1c3ea7b Ensure we have the deviceId by GETting it from the Resin API 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
8de173f6c3 Use crypto.randomBytes for API secret 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
0373607c56 Refactor bootstrapper. Run preloaded supervisor dind. Change dind configs to be ignored and document how to populate them. 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
909e193cea Update resin-register-device to 2.0.0 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
9d2c142c36 Put preloaded apps in DB, and use promise for when boostrap is done 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
0bfd329ebc change the bootstrap process 2015-10-13 13:45:05 -03:00
Pablo Carranza Vélez
6f42fc2036 Try to do systemd calls in gosuper 2015-10-13 13:45:04 -03:00
Pablo Carranza Vélez
3da4dae190 Add systemd interface and reboot/shutdown endpoints 2015-10-13 13:45:04 -03:00
Pablo Carranza Vélez
53ed41a4e2 Allow lockfile force to be specified in the request body 2015-10-13 13:45:04 -03:00
Pablo Carranza Vélez
d5ddad914e Add /v1/restart API endpoint 2015-10-13 13:45:04 -03:00
Praneeth Bodduluri
a15c9e636e Add additional mount for the host's docker.sock 2015-10-13 13:45:04 -03:00
Praneeth Bodduluri
efc272533c Also mount the host dbus on host_run/dbus 2015-10-13 13:45:04 -03:00
Pablo Carranza Vélez
6e62366541 Always unlock the lockfile when killing the app.
Otherwise, we have a deadlock whenever the lock is forced: the app
will be restarted, and will find the lockfile is already there so it won't be
able to lock/unlock it. The supervisor will have the same problem.
So the solution is that, whenever we kill the app, that is the lock owner, we also unlock the file.
2015-10-13 13:45:04 -03:00
Pablo Carranza Vélez
233004d130 Download/update/remove/install all apps in a map 2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
4aea117330 Purge handles strings and numbers, and is tested with a table 2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
3da961d4fd Use env var for force, and don't touch lockfile on force
Also:

* Force lock when purging

* Use updateStatus object to keep update state
2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
c7c4aed746 Use rwlock together with lockfile
Select app to kill from DB within lock (otherwise, if some other part kills and restarts the app, the
containerId will have changed and the real container will not be removed).
2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
d1b317399e Updates by appId and use Promise.using for lock
Change the update cycle to go by appId instead of imageId.
Use Promise.using for lockFile locks and unlocks.
Now updates shouldn't stop if one of the apps fails to update
(it's a step towards better supporting multiple apps).

Forcing the lock now works.

Remove unnecessary require fs

Nicer assignment for s in joinErrorMessages
2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
1eb31ce5f6 Apply coffeelint everywhere 2015-10-13 13:45:03 -03:00
Pablo Carranza Vélez
c52c2c0bd9 First attempt at locking updates with files 2015-10-13 13:45:03 -03:00
Praneeth Bodduluri
a8e1d476e3 Change to use 204 for API, Remove extra space in upscript.sh and Make fswatch start only on EEXIST error 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
7b8ca9fd73 Start the fs watch after the VPN directory has been created - Use finally and not then 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
ac545ccc52 Change the EEXIST to a function 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
a57c723e8a Remove inotify and lint changes 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
a4966a798a Change the fs functions to promise 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
0213916b90 Style changes 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
8642371094 Pause TCP Pings on VPN connection 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
d6b6d2d73b Distinguish betweek - permanent TCP check disable and pausing tcp check 2015-10-13 13:43:37 -03:00
Praneeth Bodduluri
03299d77f5 API to pause TCP checks 2015-10-13 13:43:37 -03:00
Pablo Carranza Vélez
c250ff483c Fix double app start (app.id = null after kill) 2015-10-13 13:43:37 -03:00
Pablo Carranza Vélez
c2496d30c2 Use Promise Disposer for lock, + cleanup 2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
6d54e6663e Lock app restart, cleanup and better testing 2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
9bc2f6212d Handle App not found in purge, + cleanup
* gosuper in dockerignored folder
* correctly handle app not found in purge
* test formatting in test-gosuper
* Fix test-gosuper
* DRY up test-integration
2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
53668647c8 Integration test is now working.
* More work on the integration test
* Correctly get supervisor IP
* Use Fatal for test errors
* test-integration working separate from run-supervisor
* Use jenkins' JOB_NAME to identify and remove containers with their volumes
* Document testing procedure
* Document the assume-unchanged tip
* Use /mnt/root for data path
* Nicer secret assignment
2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
513cc24d1c Purge restarts app, and first attempt at integration testing
* Restart app when purging
* Use log.Fatal to exit with status 1
* Quotes in entry.sh
* Use JSON for request body
* Handle errors for parseJsonBody
* Better error printing in main
* First attempt at testing nodesuper from Go
* Cleaner build
* Use ARCH to differentiate concurrent tests/builds
* Use --rm to autoremove containers
2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
dd53bbd1db Call the gosuper from node via unix socket + http. 2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
5d5f38ea69 Add /lib/firmware to the app bind mounts 2015-10-13 13:43:36 -03:00
Pablo Carranza Vélez
1e340f4fac Return when no appId 2015-10-13 13:43:35 -03:00
Praneeth Bodduluri
418d838dec Make resolv.conf writable from a User container 2015-10-13 13:43:35 -03:00
Pagan Gazzard
b8ecdb3ce2 Rename state module to device and use sensible function names for the new module name. 2015-10-13 13:43:35 -03:00
Pagan Gazzard
0917a46a2d Separate the device state updating into its own module. 2015-10-13 13:43:35 -03:00
Pagan Gazzard
3ad47adce4 Fix an issue where an image would not be cleaned up if it was tagged in multiple repos. 2015-10-13 13:43:35 -03:00
Juan Cruz Viotti
aead4c7531 Make use of resin-register-device 2015-10-13 13:42:25 -03:00
Pagan Gazzard
4003bd4828 Write the registered_at time to config.json as well, in case there is a failure between writing to config.json and writing to knex [Page] 2015-10-13 13:39:39 -03:00
Pagan Gazzard
1ee3072c75 Force a newer bluebird so that we can rely on error properties also being available on the root error. 2015-10-13 13:39:39 -03:00
Pagan Gazzard
52d4cfb9d9 Fix an error where mixpanel events would have the wrong uuid set on first provision. 2015-10-13 13:39:39 -03:00
Pagan Gazzard
ab26c6a401 Don't cache config.json 2015-10-13 13:39:38 -03:00
Praneeth Bodduluri
cb24f338af Add /etc/resolv.conf bind mounts 2015-10-13 13:39:38 -03:00
Pagan Gazzard
e56d9b678e Stop displaying an error message when trying to start a container that is already started. 2015-10-13 13:39:38 -03:00
Pagan Gazzard
a959660f90 Improve error messages reported to the user in the case of finding an empty string. 2015-10-13 13:39:38 -03:00
Pagan Gazzard
e38796e92a Fix trying to delete supervisor container when it reports an alternate tag instead of the primary tag. 2015-10-13 13:39:38 -03:00
Pagan Gazzard
099c13446a Switch to using the dockerode pull progress mechanism. 2015-10-13 13:39:38 -03:00
Pagan Gazzard
b6a1388c56 mixpanelTrack expects the error property to be called error 2015-10-13 13:39:38 -03:00
Pagan Gazzard
4d3a179fcb Nicer error when image tag isn't found 2015-10-13 13:39:38 -03:00
Pagan Gazzard
0063eaf7e7 Reset download progress to null when starting up the supervisor. 2015-10-13 13:39:38 -03:00
Pagan Gazzard
b4306e85db Fix reporting errors without a "cause" 2015-10-13 13:39:37 -03:00
Pagan Gazzard
1b0cdfe094 Remove some logging from supervisor that wasn't that useful (and caused a lot of noise when looking for issues). 2015-10-13 13:39:37 -03:00
Eugene Mirotin
0cb3316ad9 use pinejs request for env vars retrieval 2015-10-13 13:39:37 -03:00
Eugene Mirotin
9b14babc78 use API endpoint to get merged env vars 2015-10-13 13:39:37 -03:00
Pagan Gazzard
98ae03cf67 Add success/failure messages for better user info when there are issues. 2015-10-13 13:39:09 -03:00
Pagan Gazzard
368a23b823 Centralise the logging logic. 2015-10-13 13:39:09 -03:00
Pagan Gazzard
7a3d5b06c2 Report failures to start the container (eg bad CMD in a Dockerfile) 2015-10-13 13:39:09 -03:00
Pagan Gazzard
84b5746111 Share request settings between request and pinejs-client, and make sure a 30s timeout is used. 2015-10-13 13:39:09 -03:00
Pagan Gazzard
c29e0720c6 Switch to monitoring if the host is reachable via tcp, rather than a using a full http request. 2015-10-13 13:39:09 -03:00
Pagan Gazzard
a97cd40b44 Close the tty.js server as well as the ngrok listener. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
5f5b6f5be1 Fix stopping a tty session via the api using the wrong app id. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
cd6dbedfa2 Be very careful about marking an update attempt finished 2015-10-13 13:39:08 -03:00
Pagan Gazzard
c8df0b2f9e Make use of the new cache feature of the request backend for pinejs-client 1.2.0 to make use of an ETags based cache for requests to the api. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
82873d2ef2 Add a comment about updateDeviceState 2015-10-13 13:39:08 -03:00
Pagan Gazzard
48c21e9275 Keep track of target and actual device state, and make sure we keep updating the api with any differences until the two match. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
7765bc6a59 Just consume the stream for publish, avoiding any chance of it returning a value and getting stored up in the stream. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
2c94ea57a2 Only load ngrok/tty on demand. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
d578bbfba3 Use the new status/send/sendStatus style. 2015-10-13 13:39:08 -03:00
Pagan Gazzard
6144ea3aeb Update to express ^4.0.0 2015-10-13 13:39:08 -03:00
Pagan Gazzard
933cbdedad Be more frugal with the bandwidth used for device updates. 2015-10-13 13:37:56 -03:00
Pagan Gazzard
5b82667b3b Remove unused require. 2015-10-13 13:37:56 -03:00
Pagan Gazzard
73c7f29c65 Update pinejs-client to ^1.0.0 2015-10-13 13:37:53 -03:00
Pagan Gazzard
8ca8f96f46 Switch to npm deps for blinking and network-checker 2015-10-13 13:37:08 -03:00
Eugene Mirotin
433d0bc0f0 shorter defaults setting, also allows manual timestamps should someone need them 2015-10-13 13:36:13 -03:00
Eugene Mirotin
d47fdf8a3c log compound messages with timestamp and proper system flag 2015-10-13 13:36:13 -03:00
Pagan Gazzard
3d83c03868 The SUPERVISOR_IMAGE is now the fully qualified image (since it can be on another registry) - update to work with this and stop attempting to delete the actual supervisor image. 2015-10-13 13:36:13 -03:00
Pagan Gazzard
16dea4efcc Download the new version of an application before stopping/deleting the old. 2015-10-13 13:36:13 -03:00
Aleksis Brezas
af89179886 reset provisioning progress to null when supervisor starts 2015-10-13 13:36:12 -03:00
Pagan Gazzard
2d5dca2171 Make sure the supervisor version update is also retried until succeeding. 2015-10-13 13:36:12 -03:00
Pagan Gazzard
1784c75c57 Add secret/apikey based authentication to the supervisor. 2015-10-13 13:36:12 -03:00
Pagan Gazzard
fafef6cc6f Post the supervisor api port to the resin api. 2015-10-13 13:36:12 -03:00
Pagan Gazzard
c8023e0780 Add a config var to determine what port for the api to listen on. 2015-10-13 13:36:12 -03:00
Pagan Gazzard
644ad14295 Use the api to do the filtering, avoiding fetching unnecessary data. 2015-10-13 13:36:12 -03:00
Eugene Mirotin
3c9be7e2ed update Open terminal button styles 2015-10-13 13:36:12 -03:00
Aleksis Brezas
7161c04123 update config.json on device registration 2015-10-13 13:36:12 -03:00
Pagan Gazzard
3f94b353f5 Remove VPN from the supervisor 2015-10-13 13:36:12 -03:00
Aleksis Brezas
c667b55025 move uncaught exception to the top of app.coffee 2015-10-13 13:36:12 -03:00
Aleksis Brezas
0665054a79 no updates 2015-10-13 13:34:23 -03:00
Pagan Gazzard
f216a691a1 Add missing import to logger module. 2015-10-13 13:29:42 -03:00
Pagan Gazzard
ab44c79f62 Switch to using a separate module for network checking. 2015-10-13 13:29:42 -03:00
Pagan Gazzard
f0682b162a Switch to using a separate module for blinking. 2015-10-13 13:29:42 -03:00
Pagan Gazzard
b1d16da9fa Separate out the pubnub logging functionality. 2015-10-13 13:29:40 -03:00
Pagan Gazzard
56f54331a5 Fix TypeError: Cannot read property 'Running' of undefined 2015-10-13 13:28:00 -03:00
Pagan Gazzard
848aa66494 Fix reference error. 2015-10-13 13:28:00 -03:00
Praneeth Bodduluri
d300ec6baf User Supervisord for logging 2015-10-13 13:28:00 -03:00
Praneeth Bodduluri
497ecc90a8 Log Supervisor to file and mount the /var/log from host to the supervisor 2015-10-13 13:28:00 -03:00
Aleksis Brezas
b584c6b705 improve code flow 2015-10-13 13:28:00 -03:00
Aleksis Brezas
528bf39a66 use docker inspect output 2015-10-13 13:28:00 -03:00
Aleksis Brezas
85626a4157 Exited containers do not have empty status 2015-10-13 13:28:00 -03:00
Pagan Gazzard
df536f672f Update to pinejs-client-js v0.3.1 2015-10-13 13:28:00 -03:00
Pagan Gazzard
fe05824429 Extract out a duplicate function. 2015-10-13 13:28:00 -03:00
Pagan Gazzard
9673ae40d9 Remove some unneeded dependencies. 2015-10-13 13:28:00 -03:00
Pagan Gazzard
c5506d4566 Separate vpn connecting. 2015-10-13 13:28:00 -03:00
Pagan Gazzard
a7f5689873 Separate vpn bootstrapping. 2015-10-13 13:28:00 -03:00
Pagan Gazzard
6aa6ff5773 Specify the tty app to stop. 2015-10-13 13:28:00 -03:00
Pagan Gazzard
e25563f85c Add a dummy user.js 2015-10-13 13:28:00 -03:00
Pagan Gazzard
f0afcb706a Separate out tty.js 2015-10-13 13:28:00 -03:00
Pagan Gazzard
0b93c1ce2c Use typed-error for the disconnected error. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
e054b36d58 Use sensible defaults for the blink patterns, and make use of it for the API blink. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
b63e7fd595 Accept the pattern as an argument for the blink module. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
cd2603f228 Change the blink pattern to use a pattern specified by an object. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
c218adb09e Separate the blinking out, ready to move to a separate module. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
1c46e1e2a4 Separate the network polling out, ready to move to a separate module. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
e67de4b279 Simplify the state checking logic. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
49d6e3142c Use a 10s timeout for the connectivity check to make the internet connectivity check more responsive. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
bf0b38354f Use a repeating blink pattern that starts on the first failed internet check, and is consistent until we get internet again.
Previously it would pause whilst waiting for the next check (potentially a very very long time, as request doesn't have a timeout by default)
2015-10-13 13:27:59 -03:00
Pagan Gazzard
5e380fb66a Turn the connectivity check into a singleton, so we only have one running. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
2557ebcfc2 Move the connectivity check into utils. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
63f1d66402 Fix trying to delete supervisor images. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
58b9040a36 Use read -p to wait for enter. 2015-10-13 13:27:59 -03:00
Aleksis Brezas
32e1712df7 register device fallback fix 2015-10-13 13:27:59 -03:00
Pagan Gazzard
53196208b0 Start the connectivity check straight away, rather than waiting for bootstrapping to succeed. 2015-10-13 13:27:59 -03:00
Aleksis Brezas
460768d366 do not override dockerfile cmd 2015-10-13 13:27:59 -03:00
Pagan Gazzard
fcc6d1375d Fix the default device type. 2015-10-13 13:27:59 -03:00
Pagan Gazzard
b9675de9e0 Change IP address update interval from 5m to 30s 2015-10-13 13:27:58 -03:00
Petros Angelatos
7ffb65d3fa Expose host dbus to containers. This enables control of host connman 2015-10-13 13:27:58 -03:00
Aleksis Brezas
433f0920c8 remove exited supervisors 2015-10-13 13:27:58 -03:00
Aleksis Brezas
86c2e1280e delete exited containers 2015-10-13 13:27:58 -03:00
Pagan Gazzard
f5f6ee3a61 Enable compression for all of our custom requests. 2015-10-13 13:27:58 -03:00
Pagan Gazzard
26c8b140ce Only get the device id once, rather than for every request to updateDeviceInfo 2015-10-13 13:27:58 -03:00
Pagan Gazzard
6a50889086 Only select the fields we need to compare/update apps. 2015-10-13 13:27:58 -03:00
Pagan Gazzard
de6de9d397 Select just the id as it's all we need, and reduces network traffic. 2015-10-13 13:27:58 -03:00
Aleksis Brezas
e6e42d6631 improved getregistryandname 2015-10-13 13:27:58 -03:00
Aleksis Brezas
4185fb56c8 comment docker utility functions 2015-10-13 13:27:58 -03:00
Aleksis Brezas
a5ee91ceaf calculate progress in a transform stream and expose a callback for progress events 2015-10-13 13:27:58 -03:00
Aleksis Brezas
6b496693ad download progress bars 2015-10-13 13:27:58 -03:00
Aleksis Brezas
cdca01eed1 Use require to parse package.json for supervisor version 2015-10-13 13:27:58 -03:00
Aleksis Brezas
523a8b5637 update device supervisor_version 2015-10-13 13:27:58 -03:00
Pagan Gazzard
3b2b75998e Tell startNewSupervisor which image to start, we need to start the working image on a restart, and the new (possibly broken) image on update. 2015-10-13 13:27:58 -03:00
Pagan Gazzard
c8a7c49cd5 Move the application update poll interval to an env var and reduce to 60s. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
c7c1c45f38 Deal with int env vars more nicely (actually parse them and check they're valid ints) 2015-10-13 13:27:57 -03:00
Praneeth Bodduluri
10012a48cf Enforce a TLS check while connecting to the server - Prevents MITM 2015-10-13 13:27:57 -03:00
Pagan Gazzard
ffc05f9d84 Use .constructor.prototype for promisifying instead of __proto__. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
00d725cfac Move the cleanupContainersAndImages code into the docker utils, and make use of a count of currently fetching images to only clean up images if we aren't fetching any. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
07a4df1d05 Share the code for fetching an image. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
67c9db9fce Move the docker promisification/creation to a util lib. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
73c62cb5be Make sure the responses are at least non-empty, otherwise we're going to get into a broken vpn situation. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
4c257c8e7d Log the body of the sign_certificate response, it'd be very useful for debugging. 2015-10-13 13:27:57 -03:00
Pagan Gazzard
19e066bf24 Log errors when updating device info. 2015-10-13 13:27:56 -03:00
Pagan Gazzard
0240f74f47 Fix reference error when failing to delete containers. 2015-10-13 13:27:56 -03:00
Aleksis Brezas
c4f9fd853d require config is needed to retry bootstrap 2015-10-13 13:27:56 -03:00
Pagan Gazzard
2a28046533 Use Promise suffix for promise to make it a little clearer. 2015-10-13 13:27:56 -03:00
Pagan Gazzard
6c9ccfcb8c Make the supervisor container remove itself rather than just exiting when launching a new supervisor. 2015-10-13 13:27:56 -03:00
Pagan Gazzard
cd7ee9b82f There is no need to resolve currentSupervisor again as we have already resolved it. 2015-10-13 13:27:56 -03:00
Pagan Gazzard
7e3c9707cb Cleanup containers as well as images, this stops issues with having containers hanging around on an old image, stopping that image from being deleted. 2015-10-13 13:27:56 -03:00
Aleksis Brezas
01f6794ccd meta logs system prefix 2015-10-13 13:27:56 -03:00
Aleksis Brezas
b24a06a935 use channel prefix for differentiating with app logs 2015-10-13 13:27:56 -03:00
Aleksis Brezas
df2066e4de supervisor meta logs 2015-10-13 13:27:52 -03:00
Pagan Gazzard
5cf8e2c180 Silence the pubnub "Missing Message" errors. 2015-10-13 13:19:45 -03:00
Pagan Gazzard
85e1777a65 We can use mapSync as we don't need anything asynchronous, also we can return nothing as we're done with the stream data at that point. 2015-10-13 13:19:45 -03:00
Pagan Gazzard
7f38248cfa Let the new supervisor handle tagging itself as a working supervisor, this means that the check that a supervisor update is a working update will not be nullified by a reboot. 2015-10-13 13:19:45 -03:00
Aleksis Brezas
4cf6ce657a use promise.try to start promise chain 2015-10-13 13:19:45 -03:00
Aleksis Brezas
2d4c22d6eb use resin-platform-api 2015-10-13 13:19:45 -03:00
Aleksis Brezas
9c9d520da7 multi device support 2015-10-13 13:19:45 -03:00
Aleksis Brezas
ffedae683d early stage app 2015-10-13 13:19:44 -03:00
Pagan Gazzard
2d8df956a6 Move the starting timeout to a config var. 2015-10-13 13:19:44 -03:00
Pagan Gazzard
2210b1be29 Only wait for success if we're restarting due to an update attempt.
If we're restarting for binds/mounts then we're already in a non-working state, and starting the new supervisor may have to wait for bootstrap to complete (which takes an indefinite amount of time to complete, meaning the timeout was killing the new container before it could bootstrap in some cases)
2015-10-13 13:19:44 -03:00
Pagan Gazzard
5efcde7922 Start the supervisor update check ASAP, it allows us to push (and automatically update to) new supervisor images that fix issues in earlier stages. 2015-10-13 13:19:44 -03:00
Pagan Gazzard
5bb552f065 Make mixpanelTrack nicely handle errors being passed in and use it for logging bootstrapping errors. 2015-10-13 13:19:44 -03:00
Pagan Gazzard
f43afd4a95 Retry the bootstrap process if it fails - this means that we remove a point of failure (the previous connectivity check barrier merely reduced the chance of hitting that failure point) 2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
7866d7a9f7 Use API endpoint var as heartbeat endpoint. 2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
77f5c776f5 Allow configuration of heartbeat endpoint via env var. 2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
8ce9c2448f Spread is neater. 2015-10-13 13:19:44 -03:00
Lorenzo Stoakes
aa4ff76581 Avoid ICMP on connectivity check. 2015-10-13 13:19:44 -03:00
Petros Angelatos
d054ca7023 Use host networking for user containers 2015-10-13 13:19:44 -03:00
Aleksis Brezas
ff12b4b736 comment explaining why we dont throw on supervisor update 2015-10-13 13:19:44 -03:00
Aleksis Brezas
5a9f5bebc6 increase supervisor update timeout to 1 minute 2015-10-13 13:19:44 -03:00
Aleksis Brezas
81fbbab362 remove unnecessary catch 2015-10-13 13:19:44 -03:00
Aleksis Brezas
e65a0b9c66 do not throw update errors 2015-10-13 13:19:43 -03:00
Pagan Gazzard
58cbb3808e Log the stack trace as well when catching an unhandled error. 2015-10-13 13:18:12 -03:00
Pagan Gazzard
4f431d36ed Fix binding a folder using the wrong id. 2015-10-13 13:10:12 -03:00
Pagan Gazzard
2746d875f7 Fix "undefined is not a function" error due to not passing a callback to container.stop 2015-10-13 13:10:12 -03:00
Pagan Gazzard
4734f8e834 Remove duplicate require. 2015-10-13 13:10:12 -03:00
Eugene Mirotin
31a48c75f5 pass the error message in despawn as well 2015-10-13 13:10:12 -03:00
Eugene Mirotin
378913862f pass the proper error message 2015-10-13 13:10:12 -03:00
Lorenzo Stoakes
3810a394c9 Up max comment length to 120 chars. 2015-10-13 13:10:12 -03:00
Lorenzo Stoakes
f39b51885d Syntax cleanup pass. 2015-10-13 13:10:12 -03:00
Pagan Gazzard
70eef70be2 Log an error if failing to stop a tty session 2015-10-13 13:10:12 -03:00
Pagan Gazzard
a9672bd5af Make sure that the command socket exists and is a socket.
This handles the case of running an updated supervisor on an old image which doesn't support host commands - printing out a nice message and waiting rather than exiting silently.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
33441c74e7 Silence the setting up of the socket.
This was appearing whenever you started a new tty.js terminal - leaking stuff that shouldn't really be.
2015-10-13 13:10:12 -03:00
Pagan Gazzard
c1b1aba985 Make sure to stop any spawned tty sessions on container stop. 2015-10-13 13:10:12 -03:00
Pagan Gazzard
ad107b30ae Enable destroying a tty.js tunnel. 2015-10-13 13:10:12 -03:00
Pagan Gazzard
1b0e364322 Enable spawning a tty.js tunnel. 2015-10-13 13:10:12 -03:00
Aleksis Brezas
aab2a3b3d3 missing require 2015-10-13 13:10:12 -03:00
Aleksis Brezas
839b6ec7ca get full container id from /proc/1/cgroup 2015-10-13 13:10:12 -03:00
Aleksis Brezas
69e2af5aa1 wait for an ok from next supervisor before exit 2015-10-13 13:10:11 -03:00
Praneeth Bodduluri
b790e4e304 Blink interval of 200ms was too slow to be seen - reverting to 400ms used in api.coffee 2015-10-13 13:10:11 -03:00
Petros Angelatos
a10f118ab9 Use the registry endpoint from config, not environment 2015-10-13 13:10:11 -03:00
Pagan Gazzard
3c5e856ef2 Mount a /data directory for containers, to allow persistent storage. 2015-10-13 13:10:11 -03:00
Pagan Gazzard
a9fe6f3414 Update the app info the moment we create the container, even if then starting the container fails.
This stops issues with constantly creating new containers for an image that fails to start.
2015-10-13 13:10:11 -03:00
Praneeth Bodduluri
e7216618ad Make Blinkable LED configurable + Move blink to utils + Check connectivity before bootstrap + Blink LED on loss of connection 2015-10-13 13:10:11 -03:00
Pagan Gazzard
3975939181 Cleanup unneeded images after a successful update. 2015-10-13 13:10:11 -03:00
Pagan Gazzard
4cc3092b73 Remove /dev mount, privileged flag does it by default. 2015-10-13 13:10:11 -03:00
Pagan Gazzard
d07c6abe99 Store and make use of container ids.
This stores the container id for an app when creating that app, using it when it is necessary to stop/remove the app and when attempting to start it again (rather than creating a new container each time, eg restarting the pi does not create a new container any more)
2015-10-13 13:10:11 -03:00
Pagan Gazzard
51bfb69354 Treat the bluebird OperationalError wrapper correctly. 2015-10-13 13:10:11 -03:00
Pagan Gazzard
0fae904f1c Make sure to use string comparisons for the status code, to avoid issues where the types are different. 2015-10-13 13:10:10 -03:00
Praneeth Bodduluri
7aa66b5cb6 x86 support + Change localImage variable to SUPERVISOR_IMAGE 2015-10-13 13:09:58 -03:00
Pagan Gazzard
e64e6e6dbe Handle trying to remove already stopped/removed containers gracefully. 2015-10-13 13:08:24 -03:00
Pagan Gazzard
7072b1df96 On update failure schedule another attempt briefly in the future. 2015-10-13 13:08:24 -03:00
Praneeth Bodduluri
0f23ddded8 Change the data mount point to /resin-data 2015-10-13 13:08:23 -03:00
Petros Angelatos
d511d9df94 Set the 'RESIN' env var in user applications 2015-10-13 13:08:23 -03:00
Pagan Gazzard
5bd4ee7ee6 Fix event-stream usage. 2015-10-13 13:08:23 -03:00
Pagan Gazzard
f317927284 Move the restart check to the earliest possible stage, such that the only mount that we actually need in order to bootstrap the the docker.sock mounting. 2015-10-13 13:08:23 -03:00
Pagan Gazzard
2c11b34bdf Have the supervisor update if it finds itself missing Volumes/Binds it expects to have (or has additional that it does not expect).
Conflicts:
	src/config.coffee
	src/supervisor-update.coffee
2015-10-13 13:08:23 -03:00
Pagan Gazzard
b7149bb266 Report the commit to the API as soon as the container is started. 2015-10-13 13:08:23 -03:00
Pagan Gazzard
3ef5a86344 Report the device status to the API 2015-10-13 13:08:23 -03:00
Pagan Gazzard
c436d8d5c0 Set default values for the config vars, which will be used in the case of an env var not being set, and copy all existing env vars in the case of an update. 2015-10-13 13:08:07 -03:00
Pagan Gazzard
c03a51d404 Make sure the fib_trie mount is propogated on an update. 2015-10-13 13:06:43 -03:00
Pagan Gazzard
a47022a0b4 Report the host ip address to the API on startup and every 5mins after. 2015-10-13 13:06:43 -03:00
Pagan Gazzard
6fb20a5dc5 Add support for exposing multiple ports. 2015-10-13 13:06:42 -03:00
Petros Angelatos
3ae3668221 Test for both 'id' and 'Id' when docker responds with image info 2015-10-13 13:06:42 -03:00
Pagan Gazzard
58035f8b24 Switch from "id" to "Id" to match a docker change.. 2015-10-13 13:06:42 -03:00
Pagan Gazzard
597fefcb33 Fix reference error. 2015-10-13 13:06:42 -03:00
Pagan Gazzard
148d067ab9 Add a log entry that we're exiting on a supervisor update. 2015-10-13 13:06:42 -03:00
Petros Angelatos
3e1dd1f922 Log every mixpanel event and remove redundant logs 2015-10-13 13:06:42 -03:00
Petros Angelatos
d00372b5d2 Move mixpanel calls inside corresponding methods 2015-10-13 13:06:42 -03:00
Petros Angelatos
d06b5117f0 Keep method of loading JSON files consistent 2015-10-13 13:06:42 -03:00
Petros Angelatos
7b483e983d Fix bug of using mixpanel module as the mixpanel client 2015-10-13 13:06:42 -03:00
Petros Angelatos
e622491f37 Add mixpanel events to the update process 2015-10-13 13:06:42 -03:00
Petros Angelatos
1501cf3122 Integrate mixpanel 2015-10-13 13:06:42 -03:00
Petros Angelatos
0772638d92 Supply USER environment variable to containers 2015-10-13 13:06:42 -03:00
Petros Angelatos
a5fa371f22 Bind mount /lib/modules to enable module loading from inside the container 2015-10-13 13:06:42 -03:00
Page
4cfcd39524 Enable periodic update checks, and add logic to only switch to the new image if it is different. 2015-10-13 13:06:42 -03:00
Page
0d2d372cb9 Share the docker socket via config. 2015-10-13 13:06:42 -03:00
Page
959da25c9f Add all expected env vars to the new supervisor container. 2015-10-13 13:06:41 -03:00
Page
f78786b065 Rename the images more appropriately. 2015-10-13 13:06:41 -03:00
Page
599f8ae503 Remove trailing commas. 2015-10-13 13:06:41 -03:00
Page
96d1e48edd Use a promise constructor so we can make the code a bit cleaner. 2015-10-13 13:06:41 -03:00
Page
a0f9219cb3 Initial version of self-updates, adds an "/v1/update-supervisor" endpoint that can be posted to in order to trigger a supervisor update, which it then fetches as the resin/rpi-supervisor repo of the registry endpoint. 2015-10-13 13:06:41 -03:00
Petros Angelatos
d47ba654b7 Pass the device uuid as an env var 2015-10-13 13:06:41 -03:00
Petros Angelatos
04ca3b3042 Clarify publish function definition 2015-10-13 13:06:41 -03:00
Petros Angelatos
7e5fe4802f Don't filter out ANSI colours 2015-10-13 13:06:41 -03:00
Petros Angelatos
29f5c9b7e0 Use promise API 2015-10-13 13:06:41 -03:00
Petros Angelatos
604a05a21a Style fixes 2015-10-13 13:06:41 -03:00
Petros Angelatos
94eeaaa510 Resolve variable collision 2015-10-13 13:06:41 -03:00
Petros Angelatos
39261f5d6b Enclose publish queuing vars in their own closure 2015-10-13 13:06:41 -03:00
Petros Angelatos
7c33f28724 Queue publish calls while getting uuid from db 2015-10-13 13:06:41 -03:00
Petros Angelatos
ca736233e7 Move all configuration variables to a separate file 2015-10-13 13:06:39 -03:00
Petros Angelatos
5caace400f Send logs through pubnub 2015-10-13 13:04:25 -03:00
Page
ff7d6c1f8a Add missing paren. 2015-10-13 13:03:16 -03:00
Page
b3f9f9b1ef Switch to using the Promise constructor rather than deferred, it allows for slightly nicer code. Also add some parens in appropriate places. 2015-10-13 13:03:16 -03:00
Page
4d5c18ec6f Fetch the image using dockerode. 2015-10-13 13:03:16 -03:00
Page
7daebaf85e Fix check if we already have the image. 2015-10-13 13:03:16 -03:00
Page
f47e7fbf2b We have to manually stringify/parse the JSON column for knex - fixes containers restarting every 6 minutes. 2015-10-13 13:03:16 -03:00
Petros Angelatos
e9cbeea11e Docker expects the port to be a string 2015-10-13 13:03:16 -03:00
Petros Angelatos
3c4318893a Remove unused version variable 2015-10-13 13:03:16 -03:00
Petros Angelatos
98870dcd16 Generate random UUID
Generate a random UUID when the device bootstraps instead of
deterministically calculating one from the CPU serial number. This means
that a specific device can be used with many applications and users
without problem.
2015-10-13 13:03:16 -03:00
Petros Angelatos
2b054123fe Remove unused crypto module 2015-10-13 13:03:16 -03:00
Petros Angelatos
387ac995a4 Remove unmatched ) 2015-10-13 13:03:16 -03:00
Page
ab642470ec Make sure the PORT env var is a valid port number before trying to bind it. 2015-10-13 13:03:16 -03:00
Page
9ca8077daa Use the PORT environment variable to choose what port to expose.
Conflicts:
	src/application.coffee
2015-10-13 13:03:16 -03:00
Page
99849ad84c Publish tcp ports 80 and 443 of the container.
Conflicts:
	src/application.coffee

Conflicts:
	src/application.coffee
2015-10-13 13:03:16 -03:00
Page
38481f524d Make sure all apps are removed before adding new/updating existing, this is to make sure any ports they use have been freed in case they're needed by the new/updated apps.
Conflicts:
	src/application.coffee
2015-10-13 13:03:15 -03:00
Page
97d2771826 Change automatic update check to every 5 mins instead of 15. 2015-10-13 13:03:15 -03:00
Vasilis Souleles
502fa105b1 removed unnecessary changes part 2 2015-10-13 13:03:15 -03:00
Vasilis Souleles
34cbb1e699 removed unnecessary changes 2015-10-13 13:03:15 -03:00
Vasilis Souleles
e0aa5e3929 fixed dumb bug 2015-10-13 13:03:15 -03:00
Vasilis Souleles
9a87a8fbf5 fixed tabs over spaces 2015-10-13 13:03:15 -03:00
Vasilis Souleles
1c3e173bd3 added resin-supervisor version as a field of config object. added some notes on posting version using resinAPI 2015-10-13 13:03:15 -03:00
Page
5e620cbf03 Fix typo. 2015-10-13 13:03:15 -03:00
Page
5d89b74bab Use __dirname to make sure the relative path is relative to where we expect. 2015-10-13 13:03:15 -03:00
Page
791cbda490 Fix typo. 2015-10-13 13:03:15 -03:00
Page
06ef69f87e Only allow one update to be occurring at a time, and if another is triggered whilst one is in progress then simply schedule it for after the current one finishes. 2015-10-13 13:03:15 -03:00
Page
9c9288e179 Move the REGISTRY_ENDPOINT into an env var. 2015-10-13 13:03:15 -03:00
Page
b4756db23b The apps to update are the ones that aren't equal! 2015-10-13 13:03:15 -03:00
Page
1b74e0cca5 Pass the env vars in the way docker expects. 2015-10-13 13:03:15 -03:00
Vasilis Souleles
a51a648267 read utf-8 data. fixed Promises bug 2015-10-13 13:03:15 -03:00
Vasilis Souleles
10451fd27d added getSupevisorVersion 2015-10-13 13:03:15 -03:00
Page
b435116207 env is a property, not a var of its own. 2015-10-13 13:03:15 -03:00
Petros Angelatos
1b0a27f19d Remove assumption of supervisor path 2015-10-13 13:01:25 -03:00
Petros Angelatos
c7ce76c436 Use /data instead of /supervisor/data 2015-10-13 13:01:25 -03:00
Petros Angelatos
1654e26245 Drop legacy parameter used in Procfiles 2015-10-13 13:01:25 -03:00
Page
16fb88fab0 We can now use coffee-script for the main file, since it will be compiled before being run anyway. 2015-10-13 13:01:25 -03:00
Page
1c209fa827 Compile all the coffee-script files once after installing, rather than on each run. 2015-10-13 13:01:25 -03:00
Page
7e25bfe91a Expose the docker socket of master that we would need to launch a new resin-supervisor container. 2015-10-13 13:01:25 -03:00
Page
e336eaad6e Increase the blink duration to 15s 2015-10-13 13:01:25 -03:00
Page
b47e8a18dd Get the app object from the local apps - that's the only place it exists! 2015-10-13 13:01:24 -03:00
Page
5482b9208d Properly stop and remove containers. 2015-10-13 12:58:58 -03:00
Page
238768e7d4 Add support for environment variables.
Conflicts:
	src/application.coffee

Conflicts:
	src/application.coffee
2015-10-13 12:58:58 -03:00
Page
4157ab036c Extract out the docker socket and registry endpoint to constants, so they are easier to change/update. 2015-10-13 12:58:58 -03:00
Page
bc0d981610 Use an app object throughout, rather than relying upon just the imageId, this is very useful for adding extra properties to the app when starting/etc (eg env vars/ports/etc) 2015-10-13 12:58:58 -03:00
Page
4d4b633fde Improve feedback for starting an app 2015-10-13 12:58:58 -03:00
Page
eaa16ccd31 Separate the url resolve onto a new line. 2015-10-13 12:58:58 -03:00
Page
a5aaee107d Use the resin-platform-api to access the platform. 2015-10-13 12:58:57 -03:00
Page
c8d8ca9736 Use /run/docker.sock for docker, since it will work when run on a host (and can now be used in a container to access the host docker as well) 2015-10-13 12:58:57 -03:00
Page
c229e8fd49 If bootstrapping fails, then actually fail, rather than covering up the error (the error will still get logged by bluebird if the promise rejection isn't handled - but the returned promise will actually be rejected now) 2015-10-13 12:58:57 -03:00
Page
795b8b4299 And actually remove the now-unused delay function. 2015-10-13 12:58:57 -03:00
Page
2d6f0a7e6d Update bluebird and use the delay helper. 2015-10-13 12:58:57 -03:00
Page
b65e3fd3f9 Remove some more unnecessary parens. 2015-10-13 12:58:57 -03:00
Page
e8e6490dd2 Update to coffee-script 1.7.1 2015-10-13 12:58:57 -03:00
Page
37212cedbe Remove a load of unnecessary parens. 2015-10-13 12:58:57 -03:00
Page
3c3e81a892 Install apps in parallel to deleting them - also fixes SQL errors when there are no apps to install. 2015-10-13 12:58:57 -03:00
Petros Aggelatos
87534cb15e Expose the whole /dev directory in the container 2015-10-13 12:58:57 -03:00
Petros Aggelatos
31a9632fe3 Bug fix. Needed to declade a volume to use bind mounts 2015-10-13 12:58:57 -03:00
Petros Aggelatos
0e360b56ac Bind mount /dev/snd so that containers can play sound 2015-10-13 12:58:57 -03:00
Petros Aggelatos
c0bfbc582d Print helpful message instead of caught error 2015-10-13 12:58:57 -03:00
Petros Aggelatos
3aed83fe04 Removed unsed variables 2015-10-13 12:58:57 -03:00
Petros Aggelatos
94395c7e12 Bugfix. .then() expects a function 2015-10-13 12:58:56 -03:00
Petros Aggelatos
117251bbc1 Only start an application when there is a commit 2015-10-13 12:58:56 -03:00
Petros Aggelatos
57e8b10928 Make all applications privileged 2015-10-13 12:58:56 -03:00
Petros Aggelatos
cec5347c6c Print the application Id 2015-10-13 12:58:56 -03:00
Petros Aggelatos
637d68921f Application management code in its own module 2015-10-13 12:58:56 -03:00
Petros Aggelatos
614b24c796 Fix output format of VPN logs 2015-10-13 12:58:56 -03:00
Petros Aggelatos
12b3e194b5 Run application when supervisor starts 2015-10-13 12:58:56 -03:00
Petros Aggelatos
563df5386d On update get application info from the API 2015-10-13 12:58:56 -03:00
Petros Aggelatos
f10fb532c6 Use versioned API endpoints 2015-10-13 12:58:56 -03:00
Petros Aggelatos
91b59abd42 Save parameters in SQLite on successful bootstrapping 2015-10-13 12:58:56 -03:00
Petros Aggelatos
1dc26396a2 Elegant require calls 2015-10-13 12:58:56 -03:00