diff options
Diffstat (limited to 'gnu/machine')
| -rw-r--r-- | gnu/machine/ssh.scm | 96 |
1 files changed, 54 insertions, 42 deletions
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 550c989c340..60d127340af 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm | |||
| @@ -339,9 +339,13 @@ by MACHINE." | |||
| 339 | "Raise a '&message' error condition if it is clear that deploying MACHINE's | 339 | "Raise a '&message' error condition if it is clear that deploying MACHINE's |
| 340 | 'system' declaration would fail." | 340 | 'system' declaration would fail." |
| 341 | (define assertions | 341 | (define assertions |
| 342 | (append (machine-check-file-system-availability machine) | 342 | (parameterize ((%current-system |
| 343 | (machine-check-initrd-modules machine) | 343 | (machine-ssh-configuration-system |
| 344 | (list (machine-check-forward-update machine)))) | 344 | (machine-configuration machine))) |
| 345 | (%current-target-system #f)) | ||
| 346 | (append (machine-check-file-system-availability machine) | ||
| 347 | (machine-check-initrd-modules machine) | ||
| 348 | (list (machine-check-forward-update machine))))) | ||
| 345 | 349 | ||
| 346 | (define aggregate-exp | 350 | (define aggregate-exp |
| 347 | ;; Gather all the expressions so that a single round-trip is enough to | 351 | ;; Gather all the expressions so that a single round-trip is enough to |
| @@ -453,6 +457,10 @@ the 'should-roll-back' field set to SHOULD-ROLL-BACK?" | |||
| 453 | (define (deploy-managed-host machine) | 457 | (define (deploy-managed-host machine) |
| 454 | "Internal implementation of 'deploy-machine' for MACHINE instances with an | 458 | "Internal implementation of 'deploy-machine' for MACHINE instances with an |
| 455 | environment type of 'managed-host." | 459 | environment type of 'managed-host." |
| 460 | (define config (machine-configuration machine)) | ||
| 461 | (define host (machine-ssh-configuration-host-name config)) | ||
| 462 | (define system (machine-ssh-configuration-system config)) | ||
| 463 | |||
| 456 | (maybe-raise-unsupported-configuration-error machine) | 464 | (maybe-raise-unsupported-configuration-error machine) |
| 457 | (when (machine-ssh-configuration-authorize? | 465 | (when (machine-ssh-configuration-authorize? |
| 458 | (machine-configuration machine)) | 466 | (machine-configuration machine)) |
| @@ -466,50 +474,54 @@ have you run 'guix archive --generate-key?'") | |||
| 466 | (get-string-all port)))) | 474 | (get-string-all port)))) |
| 467 | (machine-ssh-session machine) | 475 | (machine-ssh-session machine) |
| 468 | (machine-become-command machine))) | 476 | (machine-become-command machine))) |
| 477 | |||
| 469 | (mlet %store-monad ((_ (check-deployment-sanity machine)) | 478 | (mlet %store-monad ((_ (check-deployment-sanity machine)) |
| 470 | (boot-parameters (machine-boot-parameters machine))) | 479 | (boot-parameters (machine-boot-parameters machine))) |
| 471 | (let* ((os (machine-operating-system machine)) | 480 | ;; Make sure code that check %CURRENT-SYSTEM, such as |
| 472 | (host (machine-ssh-configuration-host-name | 481 | ;; %BASE-INITRD-MODULES, gets to see the right value. |
| 473 | (machine-configuration machine))) | 482 | (parameterize ((%current-system system) |
| 474 | (eval (cut machine-remote-eval machine <>)) | 483 | (%current-target-system #f)) |
| 475 | (menu-entries (map boot-parameters->menu-entry boot-parameters)) | 484 | (let* ((os (machine-operating-system machine)) |
| 476 | (bootloader-configuration (operating-system-bootloader os)) | 485 | (eval (cut machine-remote-eval machine <>)) |
| 477 | (bootcfg (operating-system-bootcfg os menu-entries))) | 486 | (menu-entries (map boot-parameters->menu-entry boot-parameters)) |
| 478 | (define-syntax-rule (eval/error-handling condition handler ...) | 487 | (bootloader-configuration (operating-system-bootloader os)) |
| 479 | ;; Return a wrapper around EVAL such that HANDLER is evaluated if an | 488 | (bootcfg (operating-system-bootcfg os menu-entries))) |
| 480 | ;; exception is raised. | 489 | (define-syntax-rule (eval/error-handling condition handler ...) |
| 481 | (lambda (exp) | 490 | ;; Return a wrapper around EVAL such that HANDLER is evaluated if an |
| 482 | (lambda (store) | 491 | ;; exception is raised. |
| 483 | (guard (condition ((inferior-exception? condition) | 492 | (lambda (exp) |
| 484 | (values (begin handler ...) store))) | 493 | (lambda (store) |
| 485 | (values (run-with-store store (eval exp)) | 494 | (guard (condition ((inferior-exception? condition) |
| 486 | store))))) | 495 | (values (begin handler ...) store))) |
| 487 | 496 | (values (run-with-store store (eval exp) | |
| 488 | (mbegin %store-monad | 497 | #:system system) |
| 489 | (with-roll-back #f | 498 | store))))) |
| 490 | (switch-to-system (eval/error-handling c | 499 | |
| 491 | (raise (formatted-message | 500 | (mbegin %store-monad |
| 492 | (G_ "\ | 501 | (with-roll-back #f |
| 502 | (switch-to-system (eval/error-handling c | ||
| 503 | (raise (formatted-message | ||
| 504 | (G_ "\ | ||
| 493 | failed to switch systems while deploying '~a':~%~{~s ~}") | 505 | failed to switch systems while deploying '~a':~%~{~s ~}") |
| 494 | host | 506 | host |
| 495 | (inferior-exception-arguments c)))) | 507 | (inferior-exception-arguments c)))) |
| 496 | os)) | 508 | os)) |
| 497 | (with-roll-back #t | 509 | (with-roll-back #t |
| 498 | (mbegin %store-monad | 510 | (mbegin %store-monad |
| 499 | (upgrade-shepherd-services (eval/error-handling c | 511 | (upgrade-shepherd-services (eval/error-handling c |
| 500 | (warning (G_ "\ | 512 | (warning (G_ "\ |
| 501 | an error occurred while upgrading services on '~a':~%~{~s ~}~%") | 513 | an error occurred while upgrading services on '~a':~%~{~s ~}~%") |
| 502 | host | 514 | host |
| 503 | (inferior-exception-arguments | 515 | (inferior-exception-arguments |
| 504 | c))) | 516 | c))) |
| 505 | os) | 517 | os) |
| 506 | (install-bootloader (eval/error-handling c | 518 | (install-bootloader (eval/error-handling c |
| 507 | (raise (formatted-message | 519 | (raise (formatted-message |
| 508 | (G_ "\ | 520 | (G_ "\ |
| 509 | failed to install bootloader on '~a':~%~{~s ~}~%") | 521 | failed to install bootloader on '~a':~%~{~s ~}~%") |
| 510 | host | 522 | host |
| 511 | (inferior-exception-arguments c)))) | 523 | (inferior-exception-arguments c)))) |
| 512 | bootloader-configuration bootcfg))))))) | 524 | bootloader-configuration bootcfg)))))))) |
| 513 | 525 | ||
| 514 | 526 | ||
| 515 | ;;; | 527 | ;;; |
