Skip to content

Commit

Permalink
Add override field to extraIgnition config on worker pools
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Oct 11, 2024
1 parent 09e25b4 commit ac160cc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions example/30-infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@ spec:
providerConfig:
apiVersion: metal.provider.extensions.gardener.cloud/v1alpha1
kind: InfrastructureConfig
#networkRef: # (optional)
# name: my-network
worker:
WORKER_POOL_NAME:
extraIgnition:
raw: "the-ignition"
# override: true
3 changes: 2 additions & 1 deletion pkg/apis/metal/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

// IgnitionConfig contains ignition settings.
type IgnitionConfig struct {
Raw string
Raw string
Override bool
}

// WorkerConfig contains settings per pool, which are specific to the metal-operator.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/metal/v1alpha1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ type IgnitionConfig struct {
// Raw contains an inline ignition config, which is merged with the config from the os extension.
// +optional
Raw string `json:"raw,omitempty"`

// Override configures, if ignition keys set by the os-extension can be merged
// with extra ignition.
// +optional
Override bool `json:"override,omitempty"`
}

// WorkerConfig contains settings per pool, which are specific to the metal-operator.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/metal/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (w *workerDelegate) generateMachineClassAndSecrets() ([]*machinecontrollerv
metalConfig, ok := infrastructureConfig.Worker[pool.Name]
if ok && metalConfig.ExtraIgnition != nil {
machineClassProviderSpec[metal.IgnitionFieldName] = metalConfig.ExtraIgnition.Raw
machineClassProviderSpec[metal.IgnitionOverrideFieldName] = metalConfig.ExtraIgnition.Override
}

for zoneIndex, zone := range pool.Zones {
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/worker/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ var _ = Describe("Machines", func() {
Worker: map[string]metalv1alpha1.WorkerConfig{
pool.Name: {
ExtraIgnition: &metalv1alpha1.IgnitionConfig{
Raw: "abc",
Raw: "abc",
Override: true,
},
},
},
Expand All @@ -133,7 +134,8 @@ var _ = Describe("Machines", func() {
metal.ServerLabelsFieldName: map[string]string{
"foo": "bar",
},
metal.IgnitionFieldName: "abc",
metal.IgnitionFieldName: "abc",
metal.IgnitionOverrideFieldName: true,
}

Eventually(Object(machineClass)).Should(SatisfyAll(
Expand Down
4 changes: 3 additions & 1 deletion pkg/metal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const (
ImageFieldName = "image"
// ServerLabelsFieldName is the name of the server labels field
ServerLabelsFieldName = "serverLabels"
// ExtraIgnition is the name of the ignition field
// IgnitionFieldName is the name of the ignition field
IgnitionFieldName = "ignition"
// IgnitionOverrideFieldName is the name of the ignitionOverride field
IgnitionOverrideFieldName = "ignitionOverride"
// ClusterNameLabel is the name is the label key of the cluster name
ClusterNameLabel = "extension.metal.dev/cluster-name"

Expand Down

0 comments on commit ac160cc

Please sign in to comment.