Skip to content

Commit 38a5119

Browse files
committed
fix: correctly expand parameters in the URL
This fixes multiple issues: * `log.Fatalf` in the machined code leads to kernel panic * return URL if some expansion fails * correctly handle destroyed event (wait for the next one) Fixes #6807 Signed-off-by: Andrey Smirnov <[email protected]>
1 parent af21860 commit 38a5119

File tree

2 files changed

+10
-6
lines changed
  • internal/app/machined/pkg/runtime/v1alpha1/platform/metal

2 files changed

+10
-6
lines changed

internal/app/machined/pkg/runtime/v1alpha1/platform/metal/metal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (m *Metal) Configuration(ctx context.Context, r state.State) ([]byte, error
5151
getURL := func() string {
5252
downloadEndpoint, err := PopulateURLParameters(ctx, *option, r)
5353
if err != nil {
54-
log.Fatalf("failed to populate talos.config fetch URL: %q ; %s", *option, err.Error())
54+
log.Printf("failed to populate talos.config fetch URL: %q ; %s", *option, err.Error())
5555
}
5656

5757
log.Printf("fetching machine config from: %q", downloadEndpoint)

internal/app/machined/pkg/runtime/v1alpha1/platform/metal/url.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/cosi-project/runtime/pkg/resource"
1515
"github.com/cosi-project/runtime/pkg/safe"
1616
"github.com/cosi-project/runtime/pkg/state"
17+
"github.com/hashicorp/go-multierror"
1718

1819
"github.com/siderolabs/talos/pkg/machinery/constants"
1920
hardwareResource "github.com/siderolabs/talos/pkg/machinery/resources/hardware"
@@ -78,25 +79,27 @@ func PopulateURLParameters(ctx context.Context, downloadURL string, r state.Stat
7879
return nil
7980
}
8081

82+
var multiErr *multierror.Error
83+
8184
if err := substitute(constants.UUIDKey, getSystemUUID); err != nil {
82-
return "", err
85+
multiErr = multierror.Append(multiErr, err)
8386
}
8487

8588
if err := substitute(constants.SerialNumberKey, getSystemSerialNumber); err != nil {
86-
return "", err
89+
multiErr = multierror.Append(multiErr, err)
8790
}
8891

8992
if err := substitute(constants.MacKey, getMACAddress); err != nil {
90-
return "", err
93+
multiErr = multierror.Append(multiErr, err)
9194
}
9295

9396
if err := substitute(constants.HostnameKey, getHostname); err != nil {
94-
return "", err
97+
multiErr = multierror.Append(multiErr, err)
9598
}
9699

97100
u.RawQuery = values.Encode()
98101

99-
return u.String(), nil
102+
return u.String(), multiErr.ErrorOrNil()
100103
}
101104

102105
//nolint:gocyclo
@@ -123,6 +126,7 @@ func getResource[T resource.Resource](ctx context.Context, r state.State, namesp
123126
// ok, proceed
124127
case state.Destroyed, state.Bootstrapped:
125128
// ignore
129+
continue
126130
case state.Errored:
127131
return "", event.Error()
128132
}

0 commit comments

Comments
 (0)