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 2011822: obfuscation ovn clusters bug #515

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pkg/anonymization/anonymizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,17 @@ func NewAnonymizerFromConfigClient(
return nil, err
}

// for egress subnets
var networks []string

// hostsubnets are needed for egress subnets (on SDN clusters only)
hostSubnets, err := networkClient.HostSubnets().List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
klog.Infof("unable to find HostSubnets, could be OVN cluster: %v", err)
networks = getNetworksForAnonymizer(networksConfig, clusterConfigV1, nil)
} else {
networks = getNetworksForAnonymizer(networksConfig, clusterConfigV1, hostSubnets.Items)
}

networks := getNetworksForAnonymizer(networksConfig, clusterConfigV1, hostSubnets.Items)

secretsClient := kubeClient.CoreV1().Secrets(secretNamespace)

return NewAnonymizer(baseDomain, networks, secretsClient)
Expand Down Expand Up @@ -226,6 +229,13 @@ func getNetworksForAnonymizer(
}
}

// ovn clusters don't have hostsubnet objects and their egress CIDR is 192.168.126.0/18
// nolint:lll
// https://docs.openshift.com/container-platform/4.8/networking/ovn_kubernetes_network_provider/configuring-egress-ips-ovn.html#configuring-egress-ips-ovn
if len(hostSubnets) == 0 {
networks = append(networks, "192.168.126.0/18")
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting.... :)

Copy link
Contributor

Choose a reason for hiding this comment

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

OK so right now we have only OVN and SDN right? So this should be hopefully safe now (which might change in the future if there will be some another case when there are no hostsubnets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

}

sortNetworks(networks)

return networks
Expand Down