Skip to content

Commit 461f635

Browse files
committed
fix: publish a UKC worker domain on create
The instance name is registered as the service domain so the health check hits the host Unikraft actually publishes.
1 parent 6c33253 commit 461f635

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎internal/tools/ukc/api.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ type createInstanceBody struct {
5252
}
5353

5454
type createInstanceServiceGroup struct {
55-
Services []apiService `json:"services"`
55+
Services []apiService `json:"services"`
56+
Domains []createInstanceDomain `json:"domains,omitempty"`
57+
}
58+
59+
type createInstanceDomain struct {
60+
Name string `json:"name"`
5661
}
5762

5863
type apiService struct {
@@ -120,6 +125,9 @@ func CreateInstance(ctx context.Context, cfg Config, name, image string, memoryM
120125
DestinationPort: agentListenPort,
121126
Handlers: []string{"tls", "http"},
122127
}},
128+
// A bare name becomes {name}.{metro}.unikraft.app. Without it the
129+
// edge answers "There is no service on this URL."
130+
Domains: []createInstanceDomain{{Name: name}},
123131
},
124132
}
125133
if memoryMB > 0 {

‎internal/tools/ukc/api_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ func TestCreateInstanceOmitsMetro(t *testing.T) {
3434
if _, ok := got["metro"]; ok {
3535
t.Fatalf("body included metro")
3636
}
37+
sg, _ := got["service_group"].(map[string]any)
38+
domains, _ := sg["domains"].([]any)
39+
if len(domains) != 1 {
40+
t.Fatalf("domains: %#v", sg["domains"])
41+
}
42+
domain, _ := domains[0].(map[string]any)
43+
if domain["name"] != "worker" {
44+
t.Fatalf("domain name: %#v", domain["name"])
45+
}
3746
}
3847

3948
func TestInstanceHTTPSURL_fallbackMetro(t *testing.T) {

0 commit comments

Comments
 (0)