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

ResolveSubnets/ResolveSecurityGroups may cause infinite reconcile #300

Closed
eytan-avisror opened this issue May 11, 2021 · 0 comments · Fixed by #302
Closed

ResolveSubnets/ResolveSecurityGroups may cause infinite reconcile #300

eytan-avisror opened this issue May 11, 2021 · 0 comments · Fixed by #302
Labels
bug Something isn't working

Comments

@eytan-avisror
Copy link
Collaborator

We should add sorting to the slice so that we don't end up constantly reconciling because the list is changing.

func (ctx *EksInstanceGroupContext) ResolveSubnets() []string {
var (
instanceGroup = ctx.GetInstanceGroup()
configuration = instanceGroup.GetEKSConfiguration()
state = ctx.GetDiscoveredState()
resolved = make([]string, 0)
)
for _, s := range configuration.GetSubnets() {
if strings.HasPrefix(s, "subnet-") {
resolved = append(resolved, s)
continue
}
sn, err := ctx.AwsWorker.SubnetByName(s, state.GetVPCId())
if err != nil {
ctx.Log.Error(err, "failed to resolve subnet id by name", "subnet", s)
continue
}
if sn == nil {
ctx.Log.Error(errors.New("subnet not found"), "failed to resolve subnet by name", "subnet", s)
continue
}
resolved = append(resolved, aws.StringValue(sn.SubnetId))
}
return resolved
}

Same thing for resolve security groups by name:

func (ctx *EksInstanceGroupContext) ResolveSecurityGroups() []string {
var (
instanceGroup = ctx.GetInstanceGroup()
configuration = instanceGroup.GetEKSConfiguration()
state = ctx.GetDiscoveredState()
resolved = make([]string, 0)
)
for _, g := range configuration.GetSecurityGroups() {
if strings.HasPrefix(g, "sg-") {
resolved = append(resolved, g)
continue
}
sg, err := ctx.AwsWorker.SecurityGroupByName(g, state.GetVPCId())
if err != nil {
ctx.Log.Error(err, "failed to resolve security group by name", "security-group", g)
continue
}
if sg == nil {
ctx.Log.Error(errors.New("security group not found"), "failed to resolve security group by name", "security-group", g)
continue
}
resolved = append(resolved, aws.StringValue(sg.GroupId))
}
return resolved
}

@eytan-avisror eytan-avisror added the bug Something isn't working label May 11, 2021
@eytan-avisror eytan-avisror changed the title ResolveSubnet may cause infinite reconcile ResolveSubnet/ResolveSecurityGroups may cause infinite reconcile May 11, 2021
@eytan-avisror eytan-avisror changed the title ResolveSubnet/ResolveSecurityGroups may cause infinite reconcile ResolveSubnets/ResolveSecurityGroups may cause infinite reconcile May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant