-
Notifications
You must be signed in to change notification settings - Fork 232
USHIFT-7187: C2CC Dual Stack support & tests #6954
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
Open
pmtk
wants to merge
8
commits into
openshift:main
Choose a base branch
from
pmtk:c2cc/dual-stack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,202
−225
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
960a199
Extend NextHop to be a slice
pmtk 92f00fd
Setup multiple next hops
pmtk 8eeb52e
Prepare c2cc_common.sh for dualstack scenario
pmtk f620f74
Add dual-stack keywords and variables
pmtk 96c1972
Add dual-stack RF test cases
pmtk c2b055e
Update hello-microshift to PreferDualStack
pmtk 6e820e4
Dual-stack scenarios
pmtk dba0fad
Limit amount of concurrent C2CC scenarios
pmtk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 79 additions & 16 deletions
95
etcd/vendor/github.com/openshift/microshift/pkg/config/c2cc.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,9 @@ type C2CC struct { | |
| } | ||
|
|
||
| type RemoteCluster struct { | ||
| // IP address of the remote cluster's node, used as next-hop for routing. | ||
| NextHop string `json:"nextHop"` | ||
| // IP addresses of the remote cluster's node, used as next-hop for routing. | ||
| // At most one IPv4 and one IPv6 address. Dual-stack clusters need both. | ||
| NextHop []string `json:"nextHop"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New slice is not covered by unit/RF tests to check emptiness or repeated ip families in the values. |
||
| // Pod CIDRs of the remote cluster. Must not overlap with local cluster or other remotes. | ||
| ClusterNetwork []string `json:"clusterNetwork"` | ||
| // Service CIDRs of the remote cluster. Must not overlap with local cluster or other remotes. | ||
|
|
@@ -81,14 +82,40 @@ type RemoteCluster struct { | |
| } | ||
|
|
||
| type ResolvedRemoteCluster struct { | ||
| NextHop net.IP | ||
| NextHops map[int]net.IP // key: netlink.FAMILY_V4 or netlink.FAMILY_V6 | ||
| ClusterNetwork []*net.IPNet | ||
| ServiceNetwork []*net.IPNet | ||
| Domain string | ||
| DNSIP string // 10th IP of ServiceNetwork[0], computed during validation when Domain is set | ||
| ProbeIP string // 11th IP of ServiceNetwork[0], deterministic probe service ClusterIP | ||
| } | ||
|
|
||
| func (rc *ResolvedRemoteCluster) NextHopForFamily(family int) (net.IP, bool) { | ||
| ip, ok := rc.NextHops[family] | ||
| return ip, ok | ||
| } | ||
|
|
||
| func (rc *ResolvedRemoteCluster) PrimaryNextHop() net.IP { | ||
| if len(rc.ClusterNetwork) == 0 { | ||
| return nil | ||
| } | ||
| return rc.NextHops[ipFamilyOfIPNet(rc.ClusterNetwork[0])] | ||
| } | ||
|
|
||
| func ipFamilyOfIPNet(ipNet *net.IPNet) int { | ||
| if ipNet.IP.To4() != nil { | ||
| return netlink.FAMILY_V4 | ||
| } | ||
| return netlink.FAMILY_V6 | ||
| } | ||
|
|
||
| func familyName(family int) string { | ||
| if family == netlink.FAMILY_V4 { | ||
| return "IPv4" | ||
| } | ||
| return "IPv6" | ||
| } | ||
|
|
||
| func (rc *ResolvedRemoteCluster) AllCIDRs() []*net.IPNet { | ||
| all := make([]*net.IPNet, 0, len(rc.ClusterNetwork)+len(rc.ServiceNetwork)) | ||
| all = append(all, rc.ClusterNetwork...) | ||
|
|
@@ -114,7 +141,7 @@ func (c *C2CC) AllRemoteCIDRStrings() []string { | |
| } | ||
|
|
||
| func (rc *RemoteCluster) isEmpty() bool { | ||
| return rc.NextHop == "" && len(rc.ClusterNetwork) == 0 && len(rc.ServiceNetwork) == 0 && rc.Domain == "" | ||
| return len(rc.NextHop) == 0 && len(rc.ClusterNetwork) == 0 && len(rc.ServiceNetwork) == 0 && rc.Domain == "" | ||
| } | ||
|
|
||
| func (c *C2CC) stripEmptyRemoteClusters() { | ||
|
|
@@ -155,11 +182,26 @@ func (c *C2CC) parseRemoteClusters() ([]ResolvedRemoteCluster, []error) { | |
| rc := &c.RemoteClusters[i] | ||
| label := fmt.Sprintf("remoteClusters[%d]", i) | ||
|
|
||
| ip := net.ParseIP(rc.NextHop) | ||
| if ip == nil { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop %q is not a valid IP address", label, rc.NextHop)) | ||
| if len(rc.NextHop) == 0 { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop must not be empty", label)) | ||
| } | ||
| resolved[i].NextHops = make(map[int]net.IP, len(rc.NextHop)) | ||
| for j, hopStr := range rc.NextHop { | ||
| ip := net.ParseIP(hopStr) | ||
| if ip == nil { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop[%d] %q is not a valid IP address", label, j, hopStr)) | ||
| continue | ||
| } | ||
| family := netlink.FAMILY_V4 | ||
| if ip.To4() == nil { | ||
| family = netlink.FAMILY_V6 | ||
| } | ||
| if _, dup := resolved[i].NextHops[family]; dup { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop has multiple %s addresses (max 1 per family)", label, familyName(family))) | ||
| continue | ||
| } | ||
| resolved[i].NextHops[family] = ip | ||
| } | ||
| resolved[i].NextHop = ip | ||
|
|
||
| if len(rc.ClusterNetwork) == 0 { | ||
| errs = append(errs, fmt.Errorf("%s.clusterNetwork must not be empty", label)) | ||
|
|
@@ -359,14 +401,16 @@ func validateRemoteCluster( | |
| label := fmt.Sprintf("remoteClusters[%d]", i) | ||
| var errs []error | ||
|
|
||
| normalizedNextHop := res.NextHop.String() | ||
| if res.NextHop.Equal(nodeIP) || (nodeIPv6 != nil && res.NextHop.Equal(nodeIPv6)) { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop %q must not equal the local node IP (routing loop)", label, normalizedNextHop)) | ||
| } | ||
| if prev, ok := seenNextHops[normalizedNextHop]; ok { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop %q duplicates remoteClusters[%d]", label, normalizedNextHop, prev)) | ||
| } else { | ||
| seenNextHops[normalizedNextHop] = i | ||
| for _, hop := range res.NextHops { | ||
| normalized := hop.String() | ||
| if hop.Equal(nodeIP) || (nodeIPv6 != nil && hop.Equal(nodeIPv6)) { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop %q must not equal the local node IP (routing loop)", label, normalized)) | ||
| } | ||
| if prev, ok := seenNextHops[normalized]; ok { | ||
| errs = append(errs, fmt.Errorf("%s.nextHop %q duplicates remoteClusters[%d]", label, normalized, prev)) | ||
| } else { | ||
| seenNextHops[normalized] = i | ||
| } | ||
| } | ||
|
|
||
| for j, cidrNet := range res.ClusterNetwork { | ||
|
|
@@ -406,6 +450,7 @@ func validateRemoteCluster( | |
| errs = append(errs, validateNetworkShapeNets(res.ClusterNetwork, res.ServiceNetwork, label)...) | ||
| errs = append(errs, validateRemoteIPFamilyCompatibility(localV4, localV6, res.ClusterNetwork, label)...) | ||
| errs = append(errs, validateRemoteIPFamilyCompatibility(localV4, localV6, res.ServiceNetwork, label)...) | ||
| errs = append(errs, validateNextHopCoverage(res.NextHops, res.ClusterNetwork, res.ServiceNetwork, label)...) | ||
|
|
||
| return errs | ||
| } | ||
|
|
@@ -462,6 +507,23 @@ func validateRemoteIPFamilyCompatibility(localV4, localV6 bool, remoteCIDRs []*n | |
| return errs | ||
| } | ||
|
|
||
| func validateNextHopCoverage(nextHops map[int]net.IP, clusterNetwork, serviceNetwork []*net.IPNet, label string) []error { | ||
| needed := make(map[int]bool) | ||
| for _, cidr := range clusterNetwork { | ||
| needed[ipFamilyOfIPNet(cidr)] = true | ||
| } | ||
| for _, cidr := range serviceNetwork { | ||
| needed[ipFamilyOfIPNet(cidr)] = true | ||
| } | ||
| var errs []error | ||
| for family := range needed { | ||
| if _, ok := nextHops[family]; !ok { | ||
| errs = append(errs, fmt.Errorf("%s has %s CIDRs but no %s nextHop", label, familyName(family), familyName(family))) | ||
| } | ||
| } | ||
| return errs | ||
| } | ||
|
|
||
| func checkCIDRConflicts(cidr *net.IPNet, cidrStr, label string, seenCIDRs []labeledCIDR, hostIPs []net.IP) []error { | ||
| var errs []error | ||
| for _, existing := range seenCIDRs { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.