summaryrefslogtreecommitdiff
path: root/tests/machine
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim@guixotic.coop>2026-04-30 15:28:44 +0900
committerMaxim Cournoyer <maxim@guixotic.coop>2026-05-23 13:21:16 +0900
commit3777bf133e00d9ef685e463e51a1fb0350ffb056 (patch)
treec7e79d5b89945e5bb146abc732517c4dcdf162dc /tests/machine
parent6e7d100ee39bdfdb2ad350633c34bcd2dc4ca73a (diff)
machine: hetzner: Fix initial deploy when ssh-key is #f.
This fixes a regression introduced in commit a2ef2bcbfd7 ("machine: hetzner: Allow connections using ssh-agent"), where having no ssh-key would cause the early Hetzner provisioning to fail due to the lack of SSH authentication. * gnu/machine/hetzner.scm (%hetzner-ssh-key-file): New parameter. (<hetzner-configuration>) [ssh-public-key]: Compute default according to the value of the private ssh-key field. Introduce an indirection via... (hetzner-configuration-ssh-public-key): ... this new procedure, to honor %hetzner-ssh-key-file. (hetzner-configuration-ssh-key): Likewise for the private ssh-key. (hetzner-configuration-ssh-key-fingerprint): Rename to... (public-key->fingerprint): ... this, taking just the public key as argument. Update doc. (hetzner-configuration-ssh-key-public): Rename to... (public-key->string-with-type): ...this, for clarity, and accept just a public-key object. Update doc. (hetzner-machine-ssh-key): Exit early with #f when no ssh key is provided. (temporary-ssh-key-file): New procedure. (hetzner-machine-ssh-key-create): Assert a public key is defined. Adjust calls to renamed procedures, and adjust for the `hetzner-api-server-create' API change. (hetzner-machine-enable-rescue-system): Refine doc and fix code path when ssh-key is #f. (hetzner-machine-rescue-install-os): Document. (hetzner-machine-provision): Refine doc. Remove extraneous sleep and #:unwind argument. Limit ssh-session dynamic scope to where it's needed. (cleanup-temporary-ssh-key/maybe): New procedure. (deploy-hetzner): Create and use a temporary SSH key when none is defined, and clean it up when done or on errors. * gnu/machine/hetzner/http.scm (hetzner-api-server-create): Make ssh-keys a keyword argument, and fix execution when it's #f. (hetzner-api-server-enable-rescue-system): Likewise. * tests/machine/hetzner.scm ("deploy-machine-mock-with-unprovisioned-server"): Adjust test. * tests/machine/hetzner/http.scm (create-server) ("hetzner-api-server-create-unit") ("hetzner-api-server-enable-rescue-system-unit") ("hetzner-api-actions-integration") ("hetzner-api-server-enable-rescue-system-integration"): Likewise. * doc/guix.texi (Invoking guix deploy): Precise what happens when 'ssh-key' is #f in hetzner-configuration, and suggest declaratively authorizing your SSH key. Change-Id: I812b348fb553f3b5aebd0bf66850c6ecb9e06653
Diffstat (limited to 'tests/machine')
-rw-r--r--tests/machine/hetzner.scm4
-rw-r--r--tests/machine/hetzner/http.scm15
2 files changed, 12 insertions, 7 deletions
diff --git a/tests/machine/hetzner.scm b/tests/machine/hetzner.scm
index 1552bcb9a08..6f02c349f91 100644
--- a/tests/machine/hetzner.scm
+++ b/tests/machine/hetzner.scm
@@ -234,11 +234,11 @@
234 (lambda* (api . options) 234 (lambda* (api . options)
235 servers)) 235 servers))
236 ((gnu machine hetzner http) hetzner-api-server-create 236 ((gnu machine hetzner http) hetzner-api-server-create
237 (lambda* (api name ssh-keys . options) 237 (lambda* (api name #:key ssh-keys #:allow-other-keys)
238 (set! servers (list (mock-server machine))) 238 (set! servers (list (mock-server machine)))
239 (car servers))) 239 (car servers)))
240 ((gnu machine hetzner http) hetzner-api-server-enable-rescue-system 240 ((gnu machine hetzner http) hetzner-api-server-enable-rescue-system
241 (lambda (api server ssh-keys) 241 (lambda* (api server #:key ssh-keys #:allow-other-keys)
242 (mock-action "enable_rescue"))) 242 (mock-action "enable_rescue")))
243 ((gnu machine hetzner http) hetzner-api-server-power-on 243 ((gnu machine hetzner http) hetzner-api-server-power-on
244 (lambda (api server) 244 (lambda (api server)
diff --git a/tests/machine/hetzner/http.scm b/tests/machine/hetzner/http.scm
index 6c6d848a578..bd516db023b 100644
--- a/tests/machine/hetzner/http.scm
+++ b/tests/machine/hetzner/http.scm
@@ -286,7 +286,8 @@
286 #:labels labels)) 286 #:labels labels))
287 287
288(define* (create-server api ssh-key #:key (labels %labels)) 288(define* (create-server api ssh-key #:key (labels %labels))
289 (hetzner-api-server-create api %server-name (list ssh-key) 289 (hetzner-api-server-create api %server-name
290 #:ssh-keys (list ssh-key)
290 #:labels labels 291 #:labels labels
291 #:server-type "cpx31")) 292 #:server-type "cpx31"))
292 293
@@ -384,7 +385,8 @@
384 (body `(("actions" . ,(vector (cons `("status" . "success") 385 (body `(("actions" . ,(vector (cons `("status" . "success")
385 action-create-server-alist))) 386 action-create-server-alist)))
386 ("meta" . ,meta-page-alist)))))))) 387 ("meta" . ,meta-page-alist))))))))
387 (hetzner-api-server-create (hetzner-api) %server-name (list ssh-key-root)))) 388 (hetzner-api-server-create (hetzner-api) %server-name
389 #:ssh-keys (list ssh-key-root))))
388 390
389(test-equal "hetzner-api-server-delete-unit" 391(test-equal "hetzner-api-server-delete-unit"
390 (make-hetzner-action 392 (make-hetzner-action
@@ -425,7 +427,8 @@
425 (body `(("actions" . ,(vector (cons `("status" . "success") 427 (body `(("actions" . ,(vector (cons `("status" . "success")
426 action-enable-rescue-alist))) 428 action-enable-rescue-alist)))
427 ("meta" . ,meta-page-alist)))))))) 429 ("meta" . ,meta-page-alist))))))))
428 (hetzner-api-server-enable-rescue-system (hetzner-api) server-x86 (list ssh-key-root)))) 430 (hetzner-api-server-enable-rescue-system
431 (hetzner-api) server-x86 #:ssh-keys (list ssh-key-root))))
429 432
430(test-equal "hetzner-api-server-power-on-unit" 433(test-equal "hetzner-api-server-power-on-unit"
431 action-power-on 434 action-power-on
@@ -557,7 +560,8 @@
557 (with-cleanup-api (api (hetzner-api)) 560 (with-cleanup-api (api (hetzner-api))
558 (let* ((ssh-key (create-ssh-key api %ssh-key)) 561 (let* ((ssh-key (create-ssh-key api %ssh-key))
559 (server (create-server api ssh-key)) 562 (server (create-server api ssh-key))
560 (action (hetzner-api-server-enable-rescue-system api server (list ssh-key)))) 563 (action (hetzner-api-server-enable-rescue-system
564 api server #:ssh-keys (list ssh-key))))
561 (member action (hetzner-api-actions api (list (hetzner-action-id action))))))) 565 (member action (hetzner-api-actions api (list (hetzner-action-id action)))))))
562 566
563(test-skip %when-no-token) 567(test-skip %when-no-token)
@@ -595,7 +599,8 @@
595 (with-cleanup-api (api (hetzner-api)) 599 (with-cleanup-api (api (hetzner-api))
596 (let* ((ssh-key (create-ssh-key api %ssh-key)) 600 (let* ((ssh-key (create-ssh-key api %ssh-key))
597 (server (create-server api ssh-key)) 601 (server (create-server api ssh-key))
598 (action (hetzner-api-server-enable-rescue-system api server (list ssh-key)))) 602 (action (hetzner-api-server-enable-rescue-system
603 api server #:ssh-keys (list ssh-key))))
599 (and (hetzner-action? action) 604 (and (hetzner-action? action)
600 (equal? "enable_rescue" 605 (equal? "enable_rescue"
601 (hetzner-action-command action)))))) 606 (hetzner-action-command action))))))