Skip to content

Commit

Permalink
Support the root volume size defined for shoot workers
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Dec 1, 2021
1 parent 2cb86a7 commit 7cf3a89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions charts/internal/machineclass/templates/machineclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ providerSpec:
floatingPoolID: {{ $machineClass.floatingPoolID }}
{{- end }}
{{- if $machineClass.extraConfig }}
volumeSize: {{ $machineClass.volumeSize }}
extraConfig:
{{ toYaml $machineClass.extraConfig | indent 4 }}
{{- end }}
Expand Down
27 changes: 19 additions & 8 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
"datacenterID": infraStatus.DatacenterID,
"cluster": w.worker.Namespace,
"zone": zone,
"cores": values.cores,
"memory": values.memoryInMB,
"cores": values.Cores,
"memory": values.MemoryInMB,
"imageID": imageID,
"sshKey": string(w.worker.Spec.SSHPublicKey),
"networkIDs": infraStatus.NetworkIDs,
Expand All @@ -187,6 +187,17 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
}
}

if nil != pool.Volume && "" != pool.Volume.Size {
volumeSize, err := worker.DiskSize(pool.Volume.Size)
if err != nil {
return err
}

if volumeSize > 0 {
machineClassSpec["volumeSize"] = volumeSize
}
}

deploymentName := fmt.Sprintf("%s-%s-%s", w.worker.Namespace, pool.Name, zone)
className := fmt.Sprintf("%s-%s", deploymentName, workerPoolHash)

Expand Down Expand Up @@ -217,8 +228,8 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
}

type machineValues struct {
cores int
memoryInMB int
Cores int
MemoryInMB int
MachineTypeOptions *apis.MachineTypeOptions
}

Expand All @@ -241,17 +252,17 @@ func (w *workerDelegate) extractMachineValues(machineTypeName string) (*machineV

values := &machineValues{}
if n, ok := machineType.CPU.AsInt64(); ok {
values.cores = int(n)
values.Cores = int(n)
}
if values.cores <= 0 {
if values.Cores <= 0 {
err := fmt.Errorf("machine type %s has invalid CPU value %s", machineTypeName, machineType.CPU.String())
return nil, err
}

if n, ok := machineType.Memory.AsInt64(); ok {
values.memoryInMB = int(n) / (1024 * 1024)
values.MemoryInMB = int(n) / (1024 * 1024)
}
if values.memoryInMB <= 0 {
if values.MemoryInMB <= 0 {
err := fmt.Errorf("machine type %s has invalid Memory value %s", machineTypeName, machineType.Memory.String())
return nil, err
}
Expand Down

0 comments on commit 7cf3a89

Please sign in to comment.