Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Node Group Configs #40

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cluster-autoscaler/cloudprovider/gce/gce_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,26 @@
}
}
return err
} else {

Check failure on line 456 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block

Check failure on line 456 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block
// Skip migs whose instance templates don't have the corresponding config labels
var labelMismatch bool
for k, v := range cfg.Labels {
if instanceTemplate.Properties.Labels[k] != v {
klog.V(4).Infof("Instance template %s missing label %s=%s.\nIgnoring mig %s", instanceTemplate.Name, k, v, mig.GceRef().Name)
continue
labelMismatch = true
break
}
}

if labelMismatch {
continue
}

// Update the min size of mig config based on labels in the instance template
if val, ok := instanceTemplate.Properties.Labels[migAutoDiscovererKeyMinNodes]; ok {
if m, err := strconv.Atoi(val); err != nil {
return fmt.Errorf("invalid min nodes %s in instance template labels: %s", val, instanceTemplate.Name)
} else {

Check failure on line 475 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)

Check failure on line 475 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
cfg.MinSize = m
}
}
Expand All @@ -475,10 +481,16 @@
if val, ok := instanceTemplate.Properties.Labels[migAutoDiscovererKeyMaxNodes]; ok {
if m, err := strconv.Atoi(val); err != nil {
return fmt.Errorf("invalid max nodes %s in instance template labels: %s", val, instanceTemplate.Name)
} else {

Check failure on line 484 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)

Check failure on line 484 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
cfg.MaxSize = m
}
}

// Rebuild the mig with updated min and max sizes
mig, err = m.buildMigFromAutoCfg(link, cfg)
if err != nil {
return err
}
}
}

Expand Down Expand Up @@ -648,7 +660,7 @@
} else if labelEntryFound {
if c.Labels != nil {
return nil, fmt.Errorf("more than 1 label-based entry found in NodeGroupAutoDiscoverySpecs")
} else {

Check failure on line 663 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block

Check failure on line 663 in cluster-autoscaler/cloudprovider/gce/gce_manager.go

View workflow job for this annotation

GitHub Actions / test-and-verify

if block ends with a return statement, so drop this else and outdent its block
return nil, fmt.Errorf("label-based and name-prefix-based entries are both specified in NodeGroupAutoDiscoverySpecs")
}
} else if len(c.Labels) > 0 {
Expand Down
Loading