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

The Securty Group name must be unique #53714

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -372,7 +372,7 @@ func popMember(members []v2pools.Member, addr string, port int) []v2pools.Member
}

func getSecurityGroupName(clusterName string, service *v1.Service) string {
return fmt.Sprintf("lb-sg-%s-%v", clusterName, service.Name)
return fmt.Sprintf("lb-sg-%s-%s-%s", clusterName, service.Namespace, service.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative would be to use the service UID, which is also unique over time (but less readable).

If I delete a service and then quickly create a new one with the same namespace/name - what do we want to have happen to the securityGroup?

I think we want the securityGroup to not overlap in this case (so the old one can be cleaned up in parallel with the new one being created, without conflicts).
... So I think this means that this function should return

fmt.Sprintf("lb-sg-%s", service.UID)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I delete a service and then quickly create a new one with the same namespace/name - what do we want to have happen to the securityGroup?

That make sense. The service.UID is less readable.
How about "fmt.Sprintf("lb-sg-%s-%s-%s", clusterName, service.Namespace, service.Name, service.UID)"?

Copy link
Member

@anguslees anguslees Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's now very long - is there any length limit that we need to worry about here? A quick look at the code seems to imply that the name is limited to 255 chars, so I think we're ok on length.

Another (better?) option would be to use the securityGroup "description" field (also 255 chars) rather than trying to mash all our user-friendly text in the name field. That way we can have spaces, etc and change the specific text over time without worrying about wider impact.

Personally, I think the user is going to have a pretty good idea of which cluster a securityGroup is related to, and will be able to quickly find the relevant Service based on context, ports referred to, etc without needing any additional help. I agree that the UID is less readable though - so I agree that either your long-name version or the above name+description version is better than my original short-name-only version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I will check the size of its name.

}

func getSecurityGroupRules(client *gophercloud.ServiceClient, opts rules.ListOpts) ([]rules.SecGroupRule, error) {
Expand Down