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

Add clustersetip module to discovery #3230

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

vthapar
Copy link
Contributor

@vthapar vthapar commented Sep 18, 2024

...to allow subctl to allocate clustersetIP cidrs during join

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr3230/vthapar/clusterset_cidr
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

pkg/cidr/cidr.go Outdated
@@ -272,3 +272,38 @@ func uintToIP(ip uint32) net.IP {

return netIP
}

func GetValidClusterSize(cidrRange string, clusterSize uint) (uint, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the term "ClusterSize" is a bit confusing. Elsewhere in this code, I referred to it as "AllocationSize".

Suggested change
func GetValidClusterSize(cidrRange string, clusterSize uint) (uint, error) {
func GetValidAllocationSize(cidrRange string, allocationSize uint) (uint, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I wasn't too happy with it, so left it similar to globalnet to discuss during review.

Comment on lines 50 to 59
func isCIDRPreConfigured(clusterID string, clustersetIPNetworks map[string]*cidr.ClusterInfo) bool {
// ClustersetIPCIDR is not pre-configured
if clustersetIPNetworks[clusterID] == nil || clustersetIPNetworks[clusterID].CIDRs == nil ||
len(clustersetIPNetworks[clusterID].CIDRs) == 0 {
return false
}

// ClustersetIPCIDR is pre-configured
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could move this to the cidr package (I think I had intended to).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed this one.

Comment on lines 40 to 41
DefaultClustersetIPCIDR = "243.0.0.0/8"
DefaultClustersetIPClusterSize = 4096 // i.e., x.x.x.x/20 subnet mask
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DefaultClustersetIPCIDR = "243.0.0.0/8"
DefaultClustersetIPClusterSize = 4096 // i.e., x.x.x.x/20 subnet mask
DefaultCIDR = "243.0.0.0/8"
DefaultAllocationSize = 4096 // i.e., x.x.x.x/20 subnet mask

type Config struct {
ClusterID string
ClustersetIPCIDR string
ClusterSize uint
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ClusterSize uint
AllocationSize uint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 73 to 81
data := map[string]string{
clustersetIPEnabledKey: "false",
clustersetIPCidrRange: string(cidrRange),
clustersetIPClusterSize: fmt.Sprint(defaultClustersetIPClusterSize),
}

if clustersetIPEnabled {
data[clustersetIPEnabledKey] = "true"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
data := map[string]string{
clustersetIPEnabledKey: "false",
clustersetIPCidrRange: string(cidrRange),
clustersetIPClusterSize: fmt.Sprint(defaultClustersetIPClusterSize),
}
if clustersetIPEnabled {
data[clustersetIPEnabledKey] = "true"
}
data := map[string]string{
clustersetIPEnabledKey: strconv.FormatBool(clustersetIPEnabled),
clustersetIPCidrRange: string(cidrRange),
clustersetIPClusterSize: fmt.Sprint(defaultClustersetIPClusterSize),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

defaultClustersetIPClusterSize uint, namespace string,
) (*corev1.ConfigMap, error) {
labels := map[string]string{
"component": "submariner-clustersetIP",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this label. Globalnet code sets it to "submariner-globalnet" which is a larger component, though not sure why it needs the label at all. But "submariner-clustersetIP" isn't a larger component.

return nil
}

func AllocateAndUpdateClustersetIPCIDRConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite a mouthful 😄 How about:

Suggested change
func AllocateAndUpdateClustersetIPCIDRConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string,
func AllocateCIDRFromConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

return &clustersetIPInfo, configMap, err //nolint:wrapcheck // No need to wrap
}

func AssignClustersetIPs(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be public.

Suggested change
func AssignClustersetIPs(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {
func assignClustersetIPs(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return true
}

func ValidateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be public.

Suggested change
func ValidateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {
func validateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets called from test, so need public.

...to allow subctl to allocate clustersetIP cidrs during join

Signed-off-by: Vishal Thapar <[email protected]>
@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label Sep 20, 2024
@tpantelis tpantelis merged commit e2de28e into submariner-io:devel Sep 20, 2024
40 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr3230/vthapar/clusterset_cidr]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants