Skip to content

Commit 4c8ea17

Browse files
author
Serhii Zakharov
authored
obfuscation ovn clusters bug (#515)
1 parent 986801e commit 4c8ea17

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/anonymization/anonymizer.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,17 @@ func NewAnonymizerFromConfigClient(
137137
return nil, err
138138
}
139139

140-
// for egress subnets
140+
var networks []string
141+
142+
// hostsubnets are needed for egress subnets (on SDN clusters only)
141143
hostSubnets, err := networkClient.HostSubnets().List(ctx, metav1.ListOptions{})
142144
if err != nil {
143-
return nil, err
145+
klog.Infof("unable to find HostSubnets, could be OVN cluster: %v", err)
146+
networks = getNetworksForAnonymizer(networksConfig, clusterConfigV1, nil)
147+
} else {
148+
networks = getNetworksForAnonymizer(networksConfig, clusterConfigV1, hostSubnets.Items)
144149
}
145150

146-
networks := getNetworksForAnonymizer(networksConfig, clusterConfigV1, hostSubnets.Items)
147-
148151
secretsClient := kubeClient.CoreV1().Secrets(secretNamespace)
149152

150153
return NewAnonymizer(baseDomain, networks, secretsClient)
@@ -226,6 +229,13 @@ func getNetworksForAnonymizer(
226229
}
227230
}
228231

232+
// ovn clusters don't have hostsubnet objects and their egress CIDR is 192.168.126.0/18
233+
// nolint:lll
234+
// https://docs.openshift.com/container-platform/4.8/networking/ovn_kubernetes_network_provider/configuring-egress-ips-ovn.html#configuring-egress-ips-ovn
235+
if len(hostSubnets) == 0 {
236+
networks = append(networks, "192.168.126.0/18")
237+
}
238+
229239
sortNetworks(networks)
230240

231241
return networks

0 commit comments

Comments
 (0)