Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
aws: Add check for multiple worker pools
Browse files Browse the repository at this point in the history
Add validation check for multiple worker pools, to avoid conflicting
port values in aws_lb_listener. User has to set unique values for
lb_http_port and lb_https_port.

Signed-off-by: knrt10 <kautilya@kinvolk.io>
  • Loading branch information
knrt10 committed Sep 1, 2020
1 parent 375f2c4 commit 97bff06
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/platform/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func (c *config) checkValidConfig() hcl.Diagnostics {
diagnostics = append(diagnostics, c.checkNotEmptyWorkers()...)
diagnostics = append(diagnostics, c.checkWorkerPoolNamesUnique()...)
diagnostics = append(diagnostics, c.checkNameSizes()...)
diagnostics = append(diagnostics, c.checkDifferentPortForMuliplePools()...)

if c.OIDC != nil {
_, diags := c.OIDC.ToKubeAPIServerFlags(c.clusterDomain())
Expand All @@ -287,6 +288,28 @@ func (c *config) checkValidConfig() hcl.Diagnostics {
return diagnostics
}

// checkDifferentPortForMuliplePools checks if user is using multiple worker
// pools, then they should have lb_http_port and lb_https_port flag set
// with different values.
func (c *config) checkDifferentPortForMuliplePools() hcl.Diagnostics {
var diagnostics hcl.Diagnostics

// check only if using multiple worker pools.
if len(c.WorkerPools) > 1 {
for _, wp := range c.WorkerPools {
if wp.LBHTTPPort == 0 && wp.LBHTTPSPort == 0 {
diagnostics = append(diagnostics, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Unique values required",
Detail: fmt.Sprintf("Values lb_http_port and lb_https_port not set for worker pool %s", wp.Name),
})
}
}
}

return diagnostics
}

// checkNameSizes checks the size of names since AWS has a limit of 32
// characters on resources.
func (c *config) checkNameSizes() hcl.Diagnostics {
Expand Down

0 comments on commit 97bff06

Please sign in to comment.