diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org> | 2019-08-15 04:05:57 -0400 |
|---|---|---|
| committer | Christopher Lemmer Webber <cwebber@dustycloud.org> | 2019-08-15 07:43:09 -0400 |
| commit | 9c70c460a05b2bc60f3f3602f0a2dba0f79ce86c (patch) | |
| tree | 5b55aca91aba654177e117e61020b68236b8dc58 /gnu/machine.scm | |
| parent | 5ea7537b9a650cfa525401c19879080a9cf42e13 (diff) | |
machine: Implement 'roll-back-machine'.
* gnu/machine.scm (roll-back-machine, &deploy-error, deploy-error?)
(deploy-error-should-roll-back)
(deploy-error-captured-args): New variable.
* gnu/machine/ssh.scm (roll-back-managed-host): New variable.
* guix/scripts/deploy.scm (guix-deploy): Roll-back systems when a
deployment fails.
Diffstat (limited to 'gnu/machine.scm')
| -rw-r--r-- | gnu/machine.scm | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gnu/machine.scm b/gnu/machine.scm index 30ae97f6ecb..05b03b21d49 100644 --- a/gnu/machine.scm +++ b/gnu/machine.scm | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #:use-module (guix records) | 24 | #:use-module (guix records) |
| 25 | #:use-module (guix store) | 25 | #:use-module (guix store) |
| 26 | #:use-module ((guix utils) #:select (source-properties->location)) | 26 | #:use-module ((guix utils) #:select (source-properties->location)) |
| 27 | #:use-module (srfi srfi-35) | ||
| 27 | #:export (environment-type | 28 | #:export (environment-type |
| 28 | environment-type? | 29 | environment-type? |
| 29 | environment-type-name | 30 | environment-type-name |
| @@ -40,7 +41,13 @@ | |||
| 40 | machine-display-name | 41 | machine-display-name |
| 41 | 42 | ||
| 42 | deploy-machine | 43 | deploy-machine |
| 43 | machine-remote-eval)) | 44 | roll-back-machine |
| 45 | machine-remote-eval | ||
| 46 | |||
| 47 | &deploy-error | ||
| 48 | deploy-error? | ||
| 49 | deploy-error-should-roll-back | ||
| 50 | deploy-error-captured-args)) | ||
| 44 | 51 | ||
| 45 | ;;; Commentary: | 52 | ;;; Commentary: |
| 46 | ;;; | 53 | ;;; |
| @@ -66,6 +73,7 @@ | |||
| 66 | ;; of the form '(machine-remote-eval machine exp)'. | 73 | ;; of the form '(machine-remote-eval machine exp)'. |
| 67 | (machine-remote-eval environment-type-machine-remote-eval) ; procedure | 74 | (machine-remote-eval environment-type-machine-remote-eval) ; procedure |
| 68 | (deploy-machine environment-type-deploy-machine) ; procedure | 75 | (deploy-machine environment-type-deploy-machine) ; procedure |
| 76 | (roll-back-machine environment-type-roll-back-machine) ; procedure | ||
| 69 | 77 | ||
| 70 | ;; Metadata. | 78 | ;; Metadata. |
| 71 | (name environment-type-name) ; symbol | 79 | (name environment-type-name) ; symbol |
| @@ -105,3 +113,20 @@ are built and deployed to MACHINE beforehand." | |||
| 105 | MACHINE, activating it on MACHINE and switching MACHINE to the new generation." | 113 | MACHINE, activating it on MACHINE and switching MACHINE to the new generation." |
| 106 | (let ((environment (machine-environment machine))) | 114 | (let ((environment (machine-environment machine))) |
| 107 | ((environment-type-deploy-machine environment) machine))) | 115 | ((environment-type-deploy-machine environment) machine))) |
| 116 | |||
| 117 | (define (roll-back-machine machine) | ||
| 118 | "Monadic procedure rolling back to the previous system generation on | ||
| 119 | MACHINE. Return the number of the generation that was current before switching | ||
| 120 | and the new generation number." | ||
| 121 | (let ((environment (machine-environment machine))) | ||
| 122 | ((environment-type-roll-back-machine environment) machine))) | ||
| 123 | |||
| 124 | |||
| 125 | ;;; | ||
| 126 | ;;; Error types. | ||
| 127 | ;;; | ||
| 128 | |||
| 129 | (define-condition-type &deploy-error &error | ||
| 130 | deploy-error? | ||
| 131 | (should-roll-back deploy-error-should-roll-back) | ||
| 132 | (captured-args deploy-error-captured-args)) | ||
