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

Automated backport of #1010: Fix worker SG assocation when custom vpc is used #1013

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}}-worker-sg
- {{.NodeSG}}
- {{.SecurityGroup}}
subnet:
filters:
Expand Down
20 changes: 20 additions & 0 deletions pkg/aws/ocpgwdeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type machineSetConfig struct {
Region string
SecurityGroup string
PublicSubnet string
NodeSG string
}

func (d *ocpGatewayDeployer) findAMIID(vpcID string) (string, error) {
Expand Down Expand Up @@ -277,6 +278,25 @@ func (d *ocpGatewayDeployer) loadGatewayYAML(gatewaySecurityGroup, amiID string,
PublicSubnet: extractName(publicSubnet.Tags),
}

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)
if err != nil {
return nil, errors.Wrap(err, "error executing the template")
Expand Down
Loading