Paul Bonaud [Thu, 6 Aug 2020 09:44:26 +0000 (11:44 +0200)]
deploy: try to restart the app when the CLI asks to do it
In some cases (rollback or deployment errored on clever side),
clever-tools will fail when calling `clever deploy` because it thinks
the currently being deployed commit is already deployed. However in
some cases the git pushed commit is not the currently running commit.
Leading to a failure in our deployment process. The proposed solution
from the clever tools error is to launch `clever restart`.
Until we wait for
https://github.com/CleverCloud/clever-tools/issues/422 to be fixed,
let's do what the error message say: try to restart in case of a
deployment failure.
`grep -v` makes sure a file contains other lines than the one that
matched. This is different from `! grep` which makes sure the file
does not contain a line that matched.
Don't run `clever deploy` if the app is up-to-date
Running `git push` when the remote is up-to-date
no-ops (it does not trigger a deployment, but it does not fail either).
Running `clever deploy` when the remote is up-to-date triggers a failure. Here, we care about the _end result_ (ie the app is deployed on the correct commit), so no-oping is more appropriate.
This behaviour is not baked in `clever-tools`, but I think it should. I opened an issue. This script
is a temporary workaround. (at least I hope it's temporary)
https://github.com/CleverCloud/clever-tools/issues/422
Paul Bonaud [Mon, 29 Jun 2020 16:29:25 +0000 (18:29 +0200)]
ci: trying to fix nix-channel by removing unstable channel
NIX_PATH used to be enough to select the channel to use, but as Travis
add the nixpkgs-unstable channel we can get unexpected results when
nix decides to push a new unstable version out there in the public.
Paul Bonaud [Fri, 19 Jun 2020 14:20:43 +0000 (16:20 +0200)]
fix: make sure not to include unecessary ENV variable
This is a fix to an unfortunate bug introduced by #64 because we had a
default value set to `None` on the
`clever_haskell_entry_point`. Ansible considers `None` as a defined
value so the `is defined` condition doesn't match our need
The env can be provided as a JSON list `[{"name": "PORT", "value": "8080"}]`.
The `dict2items` filter provided by ansible is _almost_ what we want, but it
keeps the value original types (a boolean is kept as a boolean in the JSON value).
Since environment variables are strings and `clever-tools` does not want to make
the implicit coercion for us, we need to do it ourselves.
Paul Bonaud [Tue, 24 Mar 2020 09:18:14 +0000 (10:18 +0100)]
vars: fix `clever_base_env` by removing a variable if not necessary
The `CC_RUN_COMMAND` variable was defined in case we use haskell
binary as entrypoints. However if the `clever_haskell_entry_point`
variable is not defined we shouldn't define the `CC_RUN_COMMAND` env variable.
clever-tools now supports multiline env vars. It did so by supporting
quotes in the formats it reads from.
This commit quotes the exported values using the `tojson` filter.
Of course, a better solution would be for clever env to directly read
json value, but it's not there yet
Paul Bonaud [Mon, 25 Nov 2019 14:05:51 +0000 (15:05 +0100)]
ci: fix nix version and nix channel version
In order to avoid having bad surprises with automatic updates let's
fix the nix channel version. For now the default travis behavior is to
use `nixpkgs-unstable` (see
https://docs.travis-ci.com/user/languages/nix#overview).
Paul Bonaud [Fri, 11 Oct 2019 15:44:42 +0000 (17:44 +0200)]
fix: addon environment variables fetch for clever >= 1.5.0
It seems the output of `clever env` has changed and now env values are
surrounded by quotes with the latest 1.5.0 clever tools version.
We used to add quotes ourselves because they were missing in the
output. So this commit is adapting its parsing depending of the clever
tools' version.
Paul Bonaud [Fri, 6 Sep 2019 08:53:58 +0000 (10:53 +0200)]
scripts: use short options instead of long ones
In order to be compatible with more `grep` versions (notably busybox
ones which don't have long option names in our new CI environments) we
need to use short cli options.
Paul Bonaud [Tue, 30 Jul 2019 15:57:55 +0000 (17:57 +0200)]
deploy: revert back to git push + polling
In #19 we removed the polling script to rely on the clever cli's
ability to wait on `clever deploy` command.
After more than 6 months of experimentation it seems the command is
still not reliable (sometimes the command never returns, sometimes it
returns even when the deployment has finished..).
Thus we are reverting back to our manual process of polling `clever
activity` every 5 seconds.
The timeout for this polling is set at the Ansible level (not in the
bash script) and set for 40 minutes. This should give enough time for
any of our applications to deploy.
It was just constructing a record without adding any information. Now
it constructs a record from its mandatory parts. The caller can then
override fields as they please.
Paul Bonaud [Tue, 26 Feb 2019 08:16:11 +0000 (09:16 +0100)]
login: force the `.clever.json` file to be created
In case a project already has a `.clever.json` file (for debugging
purpose to communicate with dev environment for instance) this step
was never done because of the `creates:`.
Removing it forces the role to always create a new clever.json file.