Skip to content

Commit

Permalink
Fix worker SG assocation when custom vpc is used
Browse files Browse the repository at this point in the history
Signed-off-by: Aswin Suryanarayanan <[email protected]>
  • Loading branch information
aswinsuryan authored and tpantelis committed Sep 27, 2024
1 parent b73b847 commit cce0407
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/aws/gw-machineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
- filters:
- name: tag:Name
values:
- {{.InfraID}}{{.NodeSGSuffix}}
- {{.NodeSG}}
- {{.SecurityGroup}}
subnet:
filters:
Expand Down
22 changes: 20 additions & 2 deletions pkg/aws/ocpgwdeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ type machineSetConfig struct {
Region string
SecurityGroup string
PublicSubnet string
NodeSGSuffix string
NodeSG string
}

func (d *ocpGatewayDeployer) findAMIID(vpcID string) (string, error) {
Expand Down Expand Up @@ -286,7 +286,25 @@ func (d *ocpGatewayDeployer) loadGatewayYAML(gatewaySecurityGroup, amiID string,
Region: d.aws.region,
SecurityGroup: gatewaySecurityGroup,
PublicSubnet: extractName(publicSubnet.Tags),
NodeSGSuffix: d.aws.nodeSGSuffix,
}

if id, exists := d.aws.cloudConfig[WorkerSecurityGroupIDKey]; exists {
if workerGroupIDStr, ok := id.(string); ok && workerGroupIDStr != "" {
workerSecurityGroup, err := d.aws.getSecurityGroupByID(workerGroupIDStr)
if err != nil {
return nil, errors.Wrapf(err, "error finding the worker security group with ID %s", workerGroupIDStr)
}

if workerSecurityGroup.GroupName == nil {
return nil, errors.Errorf("security group with ID %s has no group name", workerGroupIDStr)
}

tplVars.NodeSG = *workerSecurityGroup.GroupName
} else {
return nil, errors.New("worker Security Group ID must be a valid non-empty string")
}
} else {
tplVars.NodeSG = d.aws.infraID + d.aws.nodeSGSuffix
}

err = tpl.Execute(&buf, tplVars)
Expand Down

0 comments on commit cce0407

Please sign in to comment.