-
Notifications
You must be signed in to change notification settings - Fork 68
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
Conversation
🤖 Created branch: z_pr3230/vthapar/clusterset_cidr |
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) { |
There was a problem hiding this comment.
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".
func GetValidClusterSize(cidrRange string, clusterSize uint) (uint, error) { | |
func GetValidAllocationSize(cidrRange string, allocationSize uint) (uint, error) { |
There was a problem hiding this comment.
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.
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 | ||
} |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this one.
DefaultClustersetIPCIDR = "243.0.0.0/8" | ||
DefaultClustersetIPClusterSize = 4096 // i.e., x.x.x.x/20 subnet mask |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClusterSize uint | |
AllocationSize uint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
data := map[string]string{ | ||
clustersetIPEnabledKey: "false", | ||
clustersetIPCidrRange: string(cidrRange), | ||
clustersetIPClusterSize: fmt.Sprint(defaultClustersetIPClusterSize), | ||
} | ||
|
||
if clustersetIPEnabled { | ||
data[clustersetIPEnabledKey] = "true" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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), | |
} |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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:
func AllocateAndUpdateClustersetIPCIDRConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string, | |
func AllocateCIDRFromConfigMap(ctx context.Context, brokerAdminClient controllerClient.Client, brokerNamespace string, |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
func AssignClustersetIPs(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) { | |
func assignClustersetIPs(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
func ValidateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) { | |
func validateClustersetIPConfiguration(clustersetIPInfo *Info, netconfig Config, status reporter.Interface) (string, error) { |
There was a problem hiding this comment.
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.
13d26e4
to
d424aa5
Compare
...to allow subctl to allocate clustersetIP cidrs during join Signed-off-by: Vishal Thapar <[email protected]>
d424aa5
to
a97c228
Compare
🤖 Closed branches: [z_pr3230/vthapar/clusterset_cidr] |
...to allow subctl to allocate clustersetIP cidrs during join