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

Bug 1831680: Prevent patching the HybridOverlayConfig after install time #611

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion pkg/network/ovn_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ func isOVNKubernetesChangeSafe(prev, next *operv1.NetworkSpec) []error {
if !reflect.DeepEqual(pn.GenevePort, nn.GenevePort) {
errs = append(errs, errors.Errorf("cannot change ovn-kubernetes genevePort"))
}
if pn.HybridOverlayConfig == nil && nn.HybridOverlayConfig != nil {
errs = append(errs, errors.Errorf("cannot start a hybrid overlay network after install time"))
}
if pn.HybridOverlayConfig != nil {
if !reflect.DeepEqual(pn.HybridOverlayConfig, nn.HybridOverlayConfig) {
errs = append(errs, errors.Errorf("once set cannot change ovn-kubernetes Hybrid Overlay Config"))
errs = append(errs, errors.Errorf("cannot edit a running hybrid overlay network"))
}
}

Expand Down
28 changes: 28 additions & 0 deletions pkg/network/ovn_kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,34 @@ func TestOVNKubernetesIsSafe(t *testing.T) {
errs := isOVNKubernetesChangeSafe(prev, next)
g.Expect(errs).To(BeEmpty())

// try to add a new hybrid overlay config
hybridOverlayConfigNext :=
operv1.HybridOverlayConfig{
HybridClusterNetwork: []operv1.ClusterNetworkEntry{
{CIDR: "10.132.0.0/14", HostPrefix: 23},
},
}
next.DefaultNetwork.OVNKubernetesConfig.HybridOverlayConfig = &hybridOverlayConfigNext

errs = isOVNKubernetesChangeSafe(prev, next)
g.Expect(errs).To(HaveLen(1))
g.Expect(errs[0]).To(MatchError("cannot start a hybrid overlay network after install time"))

//try to change a previous hybrid overlay
hybridOverlayConfigPrev :=
operv1.HybridOverlayConfig{
HybridClusterNetwork: []operv1.ClusterNetworkEntry{
{CIDR: "10.135.0.0/14", HostPrefix: 23},
},
}
prev.DefaultNetwork.OVNKubernetesConfig.HybridOverlayConfig = &hybridOverlayConfigPrev
errs = isOVNKubernetesChangeSafe(prev, next)
g.Expect(errs).To(HaveLen(1))
g.Expect(errs[0]).To(MatchError("cannot edit a running hybrid overlay network"))

prev.DefaultNetwork.OVNKubernetesConfig.HybridOverlayConfig = nil
next.DefaultNetwork.OVNKubernetesConfig.HybridOverlayConfig = nil

// change the mtu
mtu := uint32(70000)
next.DefaultNetwork.OVNKubernetesConfig.MTU = &mtu
Expand Down