Skip to content

Commit

Permalink
Validate at least there is one worker without spot and taints (kubern…
Browse files Browse the repository at this point in the history
  • Loading branch information
kahun authored Jul 28, 2023
1 parent 56d8542 commit e84ff01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 0 additions & 7 deletions pkg/cluster/internal/validate/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,10 @@ func validateAKSVersion(spec commons.Spec, creds *azidentity.ClientSecretCredent

func validateAKSNodes(workerNodes commons.WorkerNodes) error {
var isLetter = regexp.MustCompile(`^[a-z0-9]+$`).MatchString
hasNodeSystem := false
for _, node := range workerNodes {
if !isLetter(node.Name) || len(node.Name) >= AKSMaxNodeNameLength {
return errors.New("AKS node names must be " + strconv.Itoa(AKSMaxNodeNameLength) + " characters or less & contain only lowercase alphanumeric characters")
}
if len(node.Taints) == 0 && !node.Spot {
hasNodeSystem = true
}
}
if !hasNodeSystem {
return errors.New("at least one worker node must be non-spot and without taints")
}
return nil
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/cluster/internal/validate/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func validateWorkers(wn commons.WorkerNodes) error {
if err := validateWorkersTaints(wn); err != nil {
return err
}
if err := validateWorkersType(wn); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -126,6 +129,19 @@ func validateWorkersTaints(wns commons.WorkerNodes) error {
return nil
}

func validateWorkersType(wns commons.WorkerNodes) error {
hasNodeSystem := false
for _, wn := range wns {
if len(wn.Taints) == 0 && !wn.Spot {
hasNodeSystem = true
}
}
if !hasNodeSystem {
return errors.New("at least one worker node must be non spot and without taints")
}
return nil
}

func validateVolumeType(t string, supportedTypes []string) error {
if t != "" && !commons.Contains(supportedTypes, t) {
return errors.New("unsupported type: " + t + ". Supported types: " + fmt.Sprint(strings.Join(supportedTypes, ", ")))
Expand Down

0 comments on commit e84ff01

Please sign in to comment.