Skip to content

Commit 2e23c82

Browse files
Merge pull request #2201 from pperiyasamy/render-cno-ipsec-mc
OCPBUGS-26952: Deploy CNO IPsec MC even if user already have one
2 parents e53cc19 + 1bbc97b commit 2e23c82

File tree

4 files changed

+76
-73
lines changed

4 files changed

+76
-73
lines changed

pkg/bootstrap/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ type InfraStatus struct {
9191
// NetworkNodeIdentityEnabled define if the network node identity feature should be enabled
9292
NetworkNodeIdentityEnabled bool
9393

94-
// MasterIPsecMachineConfig contains ipsec machine config object of master nodes.
95-
MasterIPsecMachineConfig *mcfgv1.MachineConfig
94+
// MasterIPsecMachineConfigs contains ipsec machine config objects of master nodes.
95+
MasterIPsecMachineConfigs []*mcfgv1.MachineConfig
9696

97-
// WorkerIPsecMachineConfig contains ipsec machine config object of worker nodes.
98-
WorkerIPsecMachineConfig *mcfgv1.MachineConfig
97+
// WorkerIPsecMachineConfigs contains ipsec machine config objects of worker nodes.
98+
WorkerIPsecMachineConfigs []*mcfgv1.MachineConfig
9999

100100
// MasterMCPStatus contains machine config pool status of master nodes.
101101
MasterMCPStatus mcfgv1.MachineConfigPoolStatus

pkg/network/ovn_kubernetes.go

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4040
uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
4141
"k8s.io/apimachinery/pkg/types"
42+
"k8s.io/apimachinery/pkg/util/sets"
4243
"k8s.io/klog/v2"
4344
utilnet "k8s.io/utils/net"
4445
crclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -537,7 +538,7 @@ func getIPsecMode(conf *operv1.OVNKubernetesConfig) operv1.IPsecMode {
537538

538539
// shouldRenderIPsec method ensures the have following IPsec states for upgrade path from 4.14 to 4.15 or later versions:
539540
// When 4.14 cluster is already installed with MachineConfig for IPsec extension and ipsecConfig is set in network operator
540-
// config (i.e. IPsec for NS+EW), then reuse the installed MC extension and render ipsec-host daemonset.
541+
// config (i.e. IPsec for NS+EW), then render CNO's IPsec MC extension and ipsec-host daemonset.
541542
// When 4.14 cluster is just running with ipsecConfig set in network operator config (i.e. IPsec for EW only), then activate
542543
// IPsec MachineConfig and render ipsec-host daemonset.
543544
// When 4.14 cluster is just installed with MachineConfig for IPsec extension (i.e. IPsec for NS only), then just keep MachineConfig
@@ -561,11 +562,10 @@ func shouldRenderIPsec(conf *operv1.OVNKubernetesConfig, bootstrapResult *bootst
561562
// On upgrade, we will just remove any existing ipsec deployment without making any
562563
// change to them. So during upgrade, we must keep track if IPsec MachineConfigs are
563564
// active or not for non Hybrid hosted cluster.
564-
isUserIPsecMachineConfigPresent := isUserIPsecMachineConfigPresent(bootstrapResult.Infra)
565-
isIpsecMachineConfigActive := isIPsecMachineConfigActive(bootstrapResult.Infra)
566-
isIPsecMachineConfigNotActiveOnUpgrade := isIpsecUpgrade && !isIpsecMachineConfigActive && !isHypershiftHostedCluster
565+
isIPsecMachineConfigActive := isIPsecMachineConfigActive(bootstrapResult.Infra)
566+
isIPsecMachineConfigNotActiveOnUpgrade := isIpsecUpgrade && !isIPsecMachineConfigActive && !isHypershiftHostedCluster
567567
isMachineConfigClusterOperatorReady := bootstrapResult.Infra.MachineConfigClusterOperatorReady
568-
isCNOIPsecMachineConfigPresent := isIPsecMachineConfigPresent(bootstrapResult.Infra) && !isUserIPsecMachineConfigPresent
568+
isCNOIPsecMachineConfigPresent := isCNOIPsecMachineConfigPresent(bootstrapResult.Infra)
569569

570570
// We render the ipsec deployment if IPsec is already active in OVN
571571
// or if EW IPsec config is enabled.
@@ -576,19 +576,15 @@ func shouldRenderIPsec(conf *operv1.OVNKubernetesConfig, bootstrapResult *bootst
576576
// extensions to be active first. We must also render host ipsec deployment
577577
// at the time of upgrade though user created IPsec Machine Config is not
578578
// present/active.
579-
renderIPsecHostDaemonSet = (renderIPsecDaemonSet && isIpsecMachineConfigActive && !isHypershiftHostedCluster) || isIPsecMachineConfigNotActiveOnUpgrade
579+
renderIPsecHostDaemonSet = (renderIPsecDaemonSet && isIPsecMachineConfigActive && !isHypershiftHostedCluster) || isIPsecMachineConfigNotActiveOnUpgrade
580580

581581
// The containerized ipsec deployment is only rendered during upgrades or
582582
// for hypershift hosted clusters.
583583
renderIPsecContainerizedDaemonSet = (renderIPsecDaemonSet && isHypershiftHostedCluster) || isIPsecMachineConfigNotActiveOnUpgrade
584584

585585
// MachineConfig IPsec extensions rollout is needed for the ipsec enablement and are used in both External and Full modes.
586586
// except when the containerized deployment is used in hypershift hosted clusters.
587-
// We will rollout unless the user has rolled out its own.
588-
renderCNOIPsecMachineConfig = (mode != operv1.IPsecModeDisabled ||
589-
renderIPsecDaemonSet) &&
590-
!isUserIPsecMachineConfigPresent &&
591-
!isHypershiftHostedCluster
587+
renderCNOIPsecMachineConfig = (mode != operv1.IPsecModeDisabled || renderIPsecDaemonSet) && !isHypershiftHostedCluster
592588
// Wait for MCO to be ready unless we had already rendered the IPsec MachineConfig
593589
renderCNOIPsecMachineConfig = renderCNOIPsecMachineConfig && (isCNOIPsecMachineConfigPresent || isMachineConfigClusterOperatorReady)
594590

@@ -1455,11 +1451,19 @@ func shouldUpdateOVNKonPrepull(ovn bootstrap.OVNBootstrapResult, releaseVersion
14551451
return true, false
14561452
}
14571453

1458-
// isUserIPsecMachineConfigPresent returns true if user owned MachineConfigs for IPsec plugin
1459-
// are already present either in master or worker nodes, otherwise returns false.
1460-
func isUserIPsecMachineConfigPresent(infra bootstrap.InfraStatus) bool {
1461-
return (infra.MasterIPsecMachineConfig != nil && !containsNetworkOwnerRef(infra.MasterIPsecMachineConfig.OwnerReferences)) ||
1462-
(infra.WorkerIPsecMachineConfig != nil && !containsNetworkOwnerRef(infra.WorkerIPsecMachineConfig.OwnerReferences))
1454+
// isCNOIPsecMachineConfigPresent returns true if CNO owned MachineConfigs for IPsec plugin
1455+
// are already present in both master and worker nodes, otherwise returns false.
1456+
func isCNOIPsecMachineConfigPresent(infra bootstrap.InfraStatus) bool {
1457+
isCNOIPsecMachineConfigPresentIn := func(mcs []*mcfgv1.MachineConfig) bool {
1458+
for _, mc := range mcs {
1459+
if containsNetworkOwnerRef(mc.OwnerReferences) {
1460+
return true
1461+
}
1462+
}
1463+
return false
1464+
}
1465+
return isCNOIPsecMachineConfigPresentIn(infra.MasterIPsecMachineConfigs) &&
1466+
isCNOIPsecMachineConfigPresentIn(infra.WorkerIPsecMachineConfigs)
14631467
}
14641468

14651469
func containsNetworkOwnerRef(ownerRefs []metav1.OwnerReference) bool {
@@ -1475,28 +1479,28 @@ func containsNetworkOwnerRef(ownerRefs []metav1.OwnerReference) bool {
14751479
// isIPsecMachineConfigActive returns true if both master and worker's machine config pool are ready with
14761480
// ipsec machine config extension rolled out, otherwise returns false.
14771481
func isIPsecMachineConfigActive(infra bootstrap.InfraStatus) bool {
1478-
if infra.MasterIPsecMachineConfig == nil || infra.WorkerIPsecMachineConfig == nil {
1482+
if infra.MasterIPsecMachineConfigs == nil || infra.WorkerIPsecMachineConfigs == nil {
14791483
// One of the IPsec MachineConfig is not created yet, so return false.
14801484
return false
14811485
}
1482-
ipSecPluginOnMasterNodes := hasSourceInMachineConfigStatus(infra.MasterMCPStatus, infra.MasterIPsecMachineConfig.Name)
1483-
ipSecPluginOnWorkerNodes := hasSourceInMachineConfigStatus(infra.WorkerMCPStatus, infra.WorkerIPsecMachineConfig.Name)
1486+
ipSecPluginOnMasterNodes := hasSourceInMachineConfigStatus(infra.MasterMCPStatus, infra.MasterIPsecMachineConfigs)
1487+
ipSecPluginOnWorkerNodes := hasSourceInMachineConfigStatus(infra.WorkerMCPStatus, infra.WorkerIPsecMachineConfigs)
14841488
return ipSecPluginOnMasterNodes && ipSecPluginOnWorkerNodes
14851489
}
14861490

1487-
func hasSourceInMachineConfigStatus(machineConfigStatus mcfgv1.MachineConfigPoolStatus, sourceName string) bool {
1491+
func hasSourceInMachineConfigStatus(machineConfigStatus mcfgv1.MachineConfigPoolStatus, machineConfigs []*mcfgv1.MachineConfig) bool {
1492+
sourceNames := sets.New[string]()
1493+
for _, machineConfig := range machineConfigs {
1494+
sourceNames.Insert(machineConfig.Name)
1495+
}
14881496
for _, source := range machineConfigStatus.Configuration.Source {
1489-
if source.Name == sourceName {
1497+
if sourceNames.Has(source.Name) {
14901498
return true
14911499
}
14921500
}
14931501
return false
14941502
}
14951503

1496-
func isIPsecMachineConfigPresent(infra bootstrap.InfraStatus) bool {
1497-
return infra.MasterIPsecMachineConfig != nil && infra.WorkerIPsecMachineConfig != nil
1498-
}
1499-
15001504
// shouldUpdateOVNKonUpgrade determines if we should roll out changes to
15011505
// the node daemonset and the control plane deployment upon upgrades.
15021506
// We roll out node first, then control plane. In downgrades, we do the opposite.

pkg/network/ovn_kubernetes_test.go

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,12 +2200,12 @@ func TestRenderOVNKubernetesEnableIPsec(t *testing.T) {
22002200
t.Errorf("The MachineConfig %s must exist, but it's not available", workerMachineConfigIPsecExtName)
22012201
}
22022202

2203-
bootstrapResult.Infra.MasterIPsecMachineConfig = &mcfgv1.MachineConfig{}
2204-
bootstrapResult.Infra.MasterIPsecMachineConfig.Name = masterMachineConfigIPsecExtName
2205-
bootstrapResult.Infra.MasterIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2206-
bootstrapResult.Infra.WorkerIPsecMachineConfig = &mcfgv1.MachineConfig{}
2207-
bootstrapResult.Infra.WorkerIPsecMachineConfig.Name = workerMachineConfigIPsecExtName
2208-
bootstrapResult.Infra.WorkerIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2203+
bootstrapResult.Infra.MasterIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2204+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].Name = masterMachineConfigIPsecExtName
2205+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
2206+
bootstrapResult.Infra.WorkerIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2207+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].Name = workerMachineConfigIPsecExtName
2208+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
22092209
objs, _, err = renderOVNKubernetes(config, bootstrapResult, manifestDirOvn, fakeClient, featureGatesCNO)
22102210
if err != nil {
22112211
t.Errorf("Unexpected error: %v", err)
@@ -2470,14 +2470,13 @@ func TestRenderOVNKubernetesIPsecUpgradeWithMachineConfig(t *testing.T) {
24702470
},
24712471
}
24722472

2473-
// Start the upgrade and it's going rollout only ovn-ipsec-host DS without any changes into
2474-
// installed IPsec MachineConfigs.
2473+
// Start the upgrade and it's going rollout ovn-ipsec-host DS with CNO IPsec MachineConfigs.
24752474
bootstrapResult.Infra = bootstrap.InfraStatus{}
24762475
bootstrapResult.Infra.MachineConfigClusterOperatorReady = true
2477-
bootstrapResult.Infra.MasterIPsecMachineConfig = &mcfgv1.MachineConfig{}
2478-
bootstrapResult.Infra.MasterIPsecMachineConfig.Name = masterMachineConfigIPsecExtName
2479-
bootstrapResult.Infra.WorkerIPsecMachineConfig = &mcfgv1.MachineConfig{}
2480-
bootstrapResult.Infra.WorkerIPsecMachineConfig.Name = workerMachineConfigIPsecExtName
2476+
bootstrapResult.Infra.MasterIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2477+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].Name = masterMachineConfigIPsecExtName
2478+
bootstrapResult.Infra.WorkerIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2479+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].Name = workerMachineConfigIPsecExtName
24812480
bootstrapResult.Infra.MasterMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
24822481
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{Source: []v1.ObjectReference{{Name: masterMachineConfigIPsecExtName}}}}
24832482
bootstrapResult.Infra.WorkerMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
@@ -2491,12 +2490,12 @@ func TestRenderOVNKubernetesIPsecUpgradeWithMachineConfig(t *testing.T) {
24912490
}
24922491
// Ensure renderOVNKubernetes doesn't roll out its own MachineConfigs
24932492
renderedMasterIPsecExtension := findInObjs("machineconfiguration.openshift.io", "MachineConfig", masterMachineConfigIPsecExtName, "", objs)
2494-
if renderedMasterIPsecExtension != nil {
2495-
t.Errorf("The MachineConfig %s must not exist, but it's available", masterMachineConfigIPsecExtName)
2493+
if renderedMasterIPsecExtension == nil {
2494+
t.Errorf("The MachineConfig %s must exist, but it's not available", masterMachineConfigIPsecExtName)
24962495
}
24972496
renderedWorkerIPsecExtension := findInObjs("machineconfiguration.openshift.io", "MachineConfig", workerMachineConfigIPsecExtName, "", objs)
2498-
if renderedWorkerIPsecExtension != nil {
2499-
t.Errorf("The MachineConfig %s must not exist, but it's available", workerMachineConfigIPsecExtName)
2497+
if renderedWorkerIPsecExtension == nil {
2498+
t.Errorf("The MachineConfig %s must exist, but it's not available", workerMachineConfigIPsecExtName)
25002499
}
25012500
// Ensure only ipsec host daemonset exists now.
25022501
renderedIPsec := findInObjs("apps", "DaemonSet", "ovn-ipsec-host", "openshift-ovn-kubernetes", objs)
@@ -2636,12 +2635,12 @@ func TestRenderOVNKubernetesIPsecUpgradeWithNoMachineConfig(t *testing.T) {
26362635
}
26372636

26382637
// After IPsec Machine Configs rollout is complete, it must have only ovn-ipsec-host DS.
2639-
bootstrapResult.Infra.MasterIPsecMachineConfig = &mcfgv1.MachineConfig{}
2640-
bootstrapResult.Infra.MasterIPsecMachineConfig.Name = masterMachineConfigIPsecExtName
2641-
bootstrapResult.Infra.MasterIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2642-
bootstrapResult.Infra.WorkerIPsecMachineConfig = &mcfgv1.MachineConfig{}
2643-
bootstrapResult.Infra.WorkerIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2644-
bootstrapResult.Infra.WorkerIPsecMachineConfig.Name = workerMachineConfigIPsecExtName
2638+
bootstrapResult.Infra.MasterIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2639+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].Name = masterMachineConfigIPsecExtName
2640+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
2641+
bootstrapResult.Infra.WorkerIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2642+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
2643+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].Name = workerMachineConfigIPsecExtName
26452644
bootstrapResult.Infra.MasterMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
26462645
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{Source: []v1.ObjectReference{{Name: masterMachineConfigIPsecExtName}}}}
26472646
bootstrapResult.Infra.WorkerMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
@@ -2858,12 +2857,12 @@ func TestRenderOVNKubernetesDisableIPsec(t *testing.T) {
28582857
fakeClient := cnofake.NewFakeClient()
28592858
bootstrapResult.Infra = bootstrap.InfraStatus{}
28602859
bootstrapResult.Infra.MachineConfigClusterOperatorReady = true
2861-
bootstrapResult.Infra.MasterIPsecMachineConfig = &mcfgv1.MachineConfig{}
2862-
bootstrapResult.Infra.MasterIPsecMachineConfig.Name = masterMachineConfigIPsecExtName
2863-
bootstrapResult.Infra.MasterIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2864-
bootstrapResult.Infra.WorkerIPsecMachineConfig = &mcfgv1.MachineConfig{}
2865-
bootstrapResult.Infra.WorkerIPsecMachineConfig.Name = workerMachineConfigIPsecExtName
2866-
bootstrapResult.Infra.WorkerIPsecMachineConfig.OwnerReferences = networkOwnerRef()
2860+
bootstrapResult.Infra.MasterIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2861+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].Name = masterMachineConfigIPsecExtName
2862+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
2863+
bootstrapResult.Infra.WorkerIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2864+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].Name = workerMachineConfigIPsecExtName
2865+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].OwnerReferences = networkOwnerRef()
28672866
bootstrapResult.Infra.MasterMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
28682867
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{Source: []v1.ObjectReference{{Name: masterMachineConfigIPsecExtName}}}}
28692868
bootstrapResult.Infra.WorkerMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
@@ -2991,10 +2990,10 @@ func TestRenderOVNKubernetesDisableIPsecWithUserInstalledIPsecMachineConfigs(t *
29912990

29922991
fakeClient := cnofake.NewFakeClient()
29932992
bootstrapResult.Infra = bootstrap.InfraStatus{}
2994-
bootstrapResult.Infra.MasterIPsecMachineConfig = &mcfgv1.MachineConfig{}
2995-
bootstrapResult.Infra.MasterIPsecMachineConfig.Name = masterMachineConfigIPsecExtName
2996-
bootstrapResult.Infra.WorkerIPsecMachineConfig = &mcfgv1.MachineConfig{}
2997-
bootstrapResult.Infra.WorkerIPsecMachineConfig.Name = workerMachineConfigIPsecExtName
2993+
bootstrapResult.Infra.MasterIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2994+
bootstrapResult.Infra.MasterIPsecMachineConfigs[0].Name = masterMachineConfigIPsecExtName
2995+
bootstrapResult.Infra.WorkerIPsecMachineConfigs = []*mcfgv1.MachineConfig{{}}
2996+
bootstrapResult.Infra.WorkerIPsecMachineConfigs[0].Name = workerMachineConfigIPsecExtName
29982997
bootstrapResult.Infra.MasterMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,
29992998
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{Source: []v1.ObjectReference{{Name: masterMachineConfigIPsecExtName}}}}
30002999
bootstrapResult.Infra.WorkerMCPStatus = mcfgv1.MachineConfigPoolStatus{MachineCount: 1, ReadyMachineCount: 1,

pkg/platform/platform.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ func InfraStatus(client cnoclient.Client) (*bootstrap.InfraStatus, error) {
144144
// The IPsecMachineConfig in 4.14 is created by user and can be created with any name and also is not managed by network operator, so find it by using the label
145145
// and looking for the extension.
146146

147-
masterIPsecMachineConfig, err := findIPsecMachineConfigWithLabel(client, "machineconfiguration.openshift.io/role=master")
147+
masterIPsecMachineConfigs, err := findIPsecMachineConfigsWithLabel(client, "machineconfiguration.openshift.io/role=master")
148148
if err != nil {
149-
return nil, fmt.Errorf("failed to get ipsec machine config for master: %v", err)
149+
return nil, fmt.Errorf("failed to get ipsec machine configs for master: %v", err)
150150
}
151-
res.MasterIPsecMachineConfig = masterIPsecMachineConfig
151+
res.MasterIPsecMachineConfigs = masterIPsecMachineConfigs
152152

153-
workerIPsecMachineConfig, err := findIPsecMachineConfigWithLabel(client, "machineconfiguration.openshift.io/role=worker")
153+
workerIPsecMachineConfigs, err := findIPsecMachineConfigsWithLabel(client, "machineconfiguration.openshift.io/role=worker")
154154
if err != nil {
155-
return nil, fmt.Errorf("failed to get ipsec machine config for worker: %v", err)
155+
return nil, fmt.Errorf("failed to get ipsec machine configs for worker: %v", err)
156156
}
157-
res.WorkerIPsecMachineConfig = workerIPsecMachineConfig
157+
res.WorkerIPsecMachineConfigs = workerIPsecMachineConfigs
158158

159-
if res.MasterIPsecMachineConfig != nil {
159+
if res.MasterIPsecMachineConfigs != nil {
160160
mcpMaster := &mcfgv1.MachineConfigPool{}
161161
if err := client.Default().CRClient().Get(context.TODO(), types.NamespacedName{Name: "master"}, mcpMaster); err != nil {
162162
if !apierrors.IsNotFound(err) {
@@ -166,7 +166,7 @@ func InfraStatus(client cnoclient.Client) (*bootstrap.InfraStatus, error) {
166166
res.MasterMCPStatus = mcpMaster.Status
167167
}
168168

169-
if res.WorkerIPsecMachineConfig != nil {
169+
if res.WorkerIPsecMachineConfigs != nil {
170170
mcpWorker := &mcfgv1.MachineConfigPool{}
171171
if err := client.Default().CRClient().Get(context.TODO(), types.NamespacedName{Name: "worker"}, mcpWorker); err != nil {
172172
if !apierrors.IsNotFound(err) {
@@ -185,7 +185,7 @@ func InfraStatus(client cnoclient.Client) (*bootstrap.InfraStatus, error) {
185185
return res, nil
186186
}
187187

188-
func findIPsecMachineConfigWithLabel(client cnoclient.Client, selector string) (*mcfgv1.MachineConfig, error) {
188+
func findIPsecMachineConfigsWithLabel(client cnoclient.Client, selector string) ([]*mcfgv1.MachineConfig, error) {
189189
lSelector, err := labels.Parse(selector)
190190
if err != nil {
191191
return nil, err
@@ -195,13 +195,13 @@ func findIPsecMachineConfigWithLabel(client cnoclient.Client, selector string) (
195195
if err != nil {
196196
return nil, err
197197
}
198-
var ipsecMachineConfig *mcfgv1.MachineConfig
198+
var ipsecMachineConfigs []*mcfgv1.MachineConfig
199199
for i, machineConfig := range machineConfigs.Items {
200200
if sets.New(machineConfig.Spec.Extensions...).Has("ipsec") {
201-
ipsecMachineConfig = &machineConfigs.Items[i]
201+
ipsecMachineConfigs = append(ipsecMachineConfigs, &machineConfigs.Items[i])
202202
}
203203
}
204-
return ipsecMachineConfig, nil
204+
return ipsecMachineConfigs, nil
205205
}
206206

207207
func isMachineConfigClusterOperatorReady(client cnoclient.Client) (bool, error) {

0 commit comments

Comments
 (0)