Skip to content

Commit d4c59ac

Browse files
authored
Simplify topology validation for NAP enabled clusters (#5964)
1 parent 0176d3f commit d4c59ac

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

pkg/orchestrator/gke/gke_job_orchestrator.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,28 +1056,33 @@ func (g *GKEOrchestrator) selectTopology(requested string, topologies map[string
10561056
}
10571057

10581058
func (g *GKEOrchestrator) validateRequestedTopology(requested string, topologies map[string]bool, accelType string) error {
1059-
if !topologies[requested] {
1060-
contained := false
1061-
for t := range topologies {
1062-
fit, err := config.CheckTopologyContainment(requested, t, accelType)
1063-
if err != nil {
1064-
return fmt.Errorf("failed to check topology containment: %w", err)
1065-
}
1066-
if fit {
1067-
contained = true
1068-
break
1069-
}
1059+
if topologies[requested] {
1060+
logging.Info("Validated provided Topology: %s", requested)
1061+
return nil
1062+
}
1063+
1064+
if g.napEnabled {
1065+
logging.Info("NAP is enabled. Allowing requested topology %s which differs from currently discovered limits (may trigger new node pool creation).", requested)
1066+
return nil
1067+
}
1068+
1069+
for t := range topologies {
1070+
fit, err := config.CheckTopologyContainment(requested, t, accelType)
1071+
if err != nil {
1072+
return fmt.Errorf("failed to check topology containment: %w", err)
10701073
}
1071-
if !contained {
1072-
var valid []string
1073-
for t := range topologies {
1074-
valid = append(valid, t)
1075-
}
1076-
return fmt.Errorf("requested topology %s is not valid for cluster. It must match or fit inside discovered limits: %v", requested, valid)
1074+
if fit {
1075+
logging.Info("Validated provided Topology: %s", requested)
1076+
return nil
10771077
}
10781078
}
1079-
logging.Info("Validated provided Topology: %s", requested)
1080-
return nil
1079+
1080+
var valid []string
1081+
for t := range topologies {
1082+
valid = append(valid, t)
1083+
}
1084+
slices.Sort(valid)
1085+
return fmt.Errorf("requested topology %s is not valid for cluster. It must match or fit inside discovered limits: %v", requested, valid)
10811086
}
10821087

10831088
func (g *GKEOrchestrator) resolveDynamicSlicingTopology(job *orchestrator.JobDefinition) (string, bool, error) {

0 commit comments

Comments
 (0)