Skip to content

Commit f3d55f4

Browse files
authored
Merge pull request #109 from boinkor-net/actually-fix-shutdown
Correctly sequence the shutdown operations
2 parents 7b3b309 + 6618d3e commit f3d55f4

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

nixos/tests/flake-part.nix

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
6767
headscale users create --config ./config.yaml bob
6868
api_key="$(headscale apikeys create --config ./config.yaml)"
69-
auth_key="$(headscale preauthkeys create --reusable -e 24h --config ./config.yaml -u bob)"
69+
auth_key="$(headscale preauthkeys create --reusable -e 100y --config ./config.yaml -u bob)"
7070
cat >$out/apikey-envfile <<EOF
7171
TS_API_KEY=$api_key
7272
TS_BASE_URL=${config.server_url}
@@ -235,11 +235,11 @@
235235
def wait_for_hoopsnake_registered(name):
236236
"Poll until hoopsnake appears in the list of hosts, then return its IP."
237237
while True:
238-
output = json.loads(headscale.succeed("headscale nodes list -o json-line"))
239-
print(output)
240-
basic_entry = [elt["ip_addresses"][0] for elt in output if elt["given_name"] == name]
241-
if len(basic_entry) == 1:
242-
return basic_entry[0]
238+
status = json.loads(bob.succeed("tailscale status --json --peers --self=false"))
239+
if status["Peer"] is not None:
240+
basic_entry = [elt["TailscaleIPs"][0] for _, elt in status["Peer"].items() if elt["HostName"] == name]
241+
if len(basic_entry) == 1:
242+
return basic_entry[0]
243243
time.sleep(1)
244244
245245
@@ -319,11 +319,11 @@
319319
def wait_for_hoopsnake_registered(name):
320320
"Poll until hoopsnake appears in the list of hosts, then return its IP."
321321
while True:
322-
output = json.loads(headscale.succeed("headscale nodes list -o json-line"))
323-
print(output)
324-
basic_entry = [elt["ip_addresses"][0] for elt in output if elt["given_name"] == name]
325-
if len(basic_entry) == 1:
326-
return basic_entry[0]
322+
status = json.loads(bob.succeed("tailscale status --json --peers --self=false"))
323+
if status["Peer"] is not None:
324+
basic_entry = [elt["TailscaleIPs"][0] for _, elt in status["Peer"].items() if elt["HostName"] == name]
325+
if len(basic_entry) == 1:
326+
return basic_entry[0]
327327
time.sleep(1)
328328
329329
with subtest("Test setup"):

ssh.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,15 @@ func (s *TailnetSSH) Run(ctx context.Context) error {
106106
return nil
107107
}
108108

109-
go func() {
110-
<-ctx.Done()
111-
srv.Close()
112-
}()
113-
114109
err = s.setupPrometheus(ctx, srv)
115110
if err != nil {
116111
log.Printf("Setting up prometheus failed, but continuing anyway: %v", err)
117112
}
118113
log.Printf("starting ssh server on port :22...")
114+
go func() {
115+
<-ctx.Done()
116+
_ = s.Server.Close()
117+
}()
119118
err = s.Server.Serve(listener)
120119
if err != nil && ctx.Err() == nil {
121120
return fmt.Errorf("ssh server failed serving: %w", err)

0 commit comments

Comments
 (0)