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

Fix worker SG assocation when custom vpc is used #1010

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
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
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 @@ -284,7 +284,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
Loading