Skip to content

Commit 21dcc09

Browse files
committed
fix: restore hermes ownership after runtime sync
1 parent 5e81a42 commit 21dcc09

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

internal/hermes/hermes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,8 @@ func generateValues(namespace, hostname, dashboardHostname, agentBaseURL, token,
10631063

10641064
func syncRuntimeFiles(cfg *config.Config, id string, configData []byte, u *ui.UI) error {
10651065
targetDir := agentruntime.HomePath(cfg, agentruntime.Hermes, id)
1066-
ensureVolumeWritable(cfg, targetDir, u)
1066+
ensureVolumeWritableFn(cfg, targetDir, u)
1067+
defer fixRuntimeVolumeOwnershipFn(cfg, targetDir, u)
10671068
if err := os.MkdirAll(targetDir, 0o755); err != nil {
10681069
return fmt.Errorf("failed to create Hermes home %s: %w", targetDir, err)
10691070
}

internal/tunnel/status_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,45 @@ func TestHumanTunnelMode(t *testing.T) {
3737
}
3838
}
3939

40+
func TestDefaultPersistentConnectorStatus(t *testing.T) {
41+
cases := []struct {
42+
name string
43+
st *tunnelState
44+
want string
45+
}{
46+
{
47+
name: "remote managed",
48+
st: &tunnelState{
49+
ExposureMode: tunnelExposurePersistent,
50+
ManagementMode: tunnelManagementRemote,
51+
Hostname: "stack.example.com",
52+
},
53+
want: "not_probed",
54+
},
55+
{
56+
name: "local managed",
57+
st: &tunnelState{
58+
ExposureMode: tunnelExposurePersistent,
59+
ManagementMode: tunnelManagementLocal,
60+
Hostname: "stack.example.com",
61+
},
62+
want: "managed-locally",
63+
},
64+
{
65+
name: "quick tunnel",
66+
st: &tunnelState{ExposureMode: tunnelExposureQuick},
67+
want: "",
68+
},
69+
}
70+
for _, tc := range cases {
71+
t.Run(tc.name, func(t *testing.T) {
72+
if got := defaultPersistentConnectorStatus(tc.st); got != tc.want {
73+
t.Fatalf("defaultPersistentConnectorStatus() = %q, want %q", got, tc.want)
74+
}
75+
})
76+
}
77+
}
78+
4079
func TestParseCloudflaredMetrics(t *testing.T) {
4180
metrics := `# HELP cloudflared_tunnel_total_requests Amount of requests
4281
cloudflared_tunnel_total_requests 42

internal/tunnel/tunnel.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func Status(cfg *config.Config, u *ui.UI, opts StatusOptions) error {
212212
}
213213
}
214214
if result.ConnectorStatus == "" && st != nil && st.IsPersistent() {
215-
result.ConnectorStatus = "managed-locally"
215+
result.ConnectorStatus = defaultPersistentConnectorStatus(st)
216216
}
217217

218218
// Public reachability probe: GET the public URL root and assert HTTP < 400.
@@ -270,6 +270,16 @@ func summarizeTunnelStatus(result tunnelStatusResult) string {
270270
return "active"
271271
}
272272

273+
func defaultPersistentConnectorStatus(st *tunnelState) string {
274+
if st == nil || !st.IsPersistent() {
275+
return ""
276+
}
277+
if st.Management() == tunnelManagementRemote {
278+
return "not_probed"
279+
}
280+
return "managed-locally"
281+
}
282+
273283
// InjectBaseURL sets AGENT_BASE_URL on the default Hermes deployment so that
274284
// monetize.py uses the tunnel URL in registration JSON.
275285
func InjectBaseURL(cfg *config.Config, tunnelURL string) error {

0 commit comments

Comments
 (0)