@@ -10,14 +10,14 @@ import (
1010 "time"
1111
1212 v1 "github.com/openshift/api/operator/v1"
13+ mg "github.com/openshift/origin/test/extended/machine_config"
1314 exutil "github.com/openshift/origin/test/extended/util"
1415 "golang.org/x/sync/errgroup"
1516 corev1 "k8s.io/api/core/v1"
1617 apierrors "k8s.io/apimachinery/pkg/api/errors"
1718 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1819 "k8s.io/apimachinery/pkg/runtime/schema"
1920 "k8s.io/apimachinery/pkg/util/wait"
20- "k8s.io/client-go/util/retry"
2121 "k8s.io/kubernetes/test/e2e/framework"
2222 e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
2323 e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"
@@ -40,7 +40,6 @@ const (
4040 ipsecRolloutWaitDuration = 40 * time .Minute
4141 ipsecRolloutWaitInterval = 1 * time .Minute
4242 nmstateConfigureManifestFile = "nmstate.yaml"
43- nsCertMachineConfigFile = "ipsec-nsconfig-machine-config.yaml"
4443 nsCertMachineConfigName = "99-worker-north-south-ipsec-config"
4544 leftNodeIPsecPolicyName = "left-node-ipsec-policy"
4645 rightNodeIPsecPolicyName = "right-node-ipsec-policy"
@@ -102,27 +101,6 @@ const (
102101 icmp trafficType = "icmp"
103102)
104103
105- // configureIPsecMode helps to rollout specified IPsec Mode on the cluster. If the cluster is already
106- // configured with specified mode, then this is almost like no-op for the cluster.
107- func configureIPsecMode (oc * exutil.CLI , ipsecMode v1.IPsecMode ) error {
108- return retry .RetryOnConflict (retry .DefaultRetry , func () error {
109- network , err := oc .AdminOperatorClient ().OperatorV1 ().Networks ().Get (context .Background (), "cluster" , metav1.GetOptions {})
110- if err != nil {
111- return err
112- }
113- if network .Spec .DefaultNetwork .OVNKubernetesConfig .IPsecConfig == nil {
114- network .Spec .DefaultNetwork .OVNKubernetesConfig .IPsecConfig = & v1.IPsecConfig {Mode : ipsecMode }
115- } else if network .Spec .DefaultNetwork .OVNKubernetesConfig .IPsecConfig .Mode != ipsecMode {
116- network .Spec .DefaultNetwork .OVNKubernetesConfig .IPsecConfig .Mode = ipsecMode
117- } else {
118- // No changes to existing mode, return without updating networks.
119- return nil
120- }
121- _ , err = oc .AdminOperatorClient ().OperatorV1 ().Networks ().Update (context .Background (), network , metav1.UpdateOptions {})
122- return err
123- })
124- }
125-
126104func getIPsecMode (oc * exutil.CLI ) (v1.IPsecMode , error ) {
127105 network , err := oc .AdminOperatorClient ().OperatorV1 ().Networks ().Get (context .Background (), "cluster" , metav1.GetOptions {})
128106 if err != nil {
@@ -451,7 +429,7 @@ var _ = g.Describe("[sig-network][Feature:IPsec]", g.Ordered, func() {
451429 // the selected nodes.
452430 ipsecMode , err := getIPsecMode (oc )
453431 o .Expect (err ).NotTo (o .HaveOccurred ())
454- o .Expect (ipsecMode ).To (o .Equal (v1 .IPsecModeFull ))
432+ o .Expect (ipsecMode ).NotTo (o .Equal (v1 .IPsecModeDisabled ))
455433
456434 srcNode , dstNode := & testNodeConfig {}, & testNodeConfig {}
457435 config = & testConfig {ipsecMode : ipsecMode , srcNodeConfig : srcNode ,
@@ -462,6 +440,39 @@ var _ = g.Describe("[sig-network][Feature:IPsec]", g.Ordered, func() {
462440 g .By ("deploy nmstate handler" )
463441 err = deployNmstateHandler (oc )
464442 o .Expect (err ).NotTo (o .HaveOccurred ())
443+
444+ // Update cluster machine configuration object with few more nodeDisruptionPolicy defined
445+ // in test/extended/testdata/ipsec/nsconfig-reboot-none-policy.yaml file so that worker
446+ // nodes don't go for a reboot while rolling out `99-worker-north-south-ipsec-config`
447+ // machine config which configures certificates for testing IPsec north south traffic.
448+ g .By ("deploy machine configuration policy" )
449+ err = oc .AsAdmin ().Run ("apply" ).Args ("-f" , nsNodeRebootNoneFixture ).Execute ()
450+ o .Expect (err ).NotTo (o .HaveOccurred ())
451+ mg .WaitForBootImageControllerToComplete (oc )
452+
453+ g .By ("configure IPsec certs on the worker nodes" )
454+ // The certificates for configuring NS IPsec between two worker nodes are deployed through machine config
455+ // `99-worker-north-south-ipsec-config` which is in the test/extended/testdata/ipsec/nsconfig-machine-config.yaml file.
456+ // This is a butane generated file via a butane config file available with commit:
457+ // https://github.com/openshift/origin/pull/28658/commits/7399006f3750c530cfef51fa1044e941ccb85087
458+ // The machine config mounts cert files into node's /etc/pki/certs directory and runs ipsec-addcert.sh script
459+ // to import those certs into Libreswan nss db and will be used by Libreswan for IPsec north south connection
460+ // configured via NodeNetworkConfigurationPolicy on the node.
461+ // The certificates in the Machine Config has validity period of 120 months starting from April 11, 2024.
462+ // so proceed with test if system date is before April 10, 2034. Otherwise fail the test.
463+ if ! time .Now ().Before (certExpirationDate ) {
464+ framework .Failf ("certficates in the Machine Config are expired, Please consider recreating those certificates" )
465+ }
466+ nsCertMachineConfig , err := createIPsecCertsMachineConfig (oc )
467+ o .Expect (err ).NotTo (o .HaveOccurred ())
468+ o .Expect (nsCertMachineConfig ).NotTo (o .BeNil ())
469+ o .Eventually (func (g o.Gomega ) bool {
470+ pools , err := getMachineConfigPoolByLabel (oc , workerRoleMachineConfigLabel )
471+ g .Expect (err ).NotTo (o .HaveOccurred ())
472+ return areMachineConfigPoolsReadyWithMachineConfig (pools , nsCertMachineConfigName )
473+ }, ipsecRolloutWaitDuration , ipsecRolloutWaitInterval ).Should (o .BeTrue ())
474+ // Ensure IPsec mode is still correctly configured.
475+ waitForIPsecConfigToComplete (oc , config .ipsecMode )
465476 })
466477
467478 g .BeforeEach (func () {
@@ -489,23 +500,6 @@ var _ = g.Describe("[sig-network][Feature:IPsec]", g.Ordered, func() {
489500 }
490501 }
491502 o .Expect (config .dstNodeConfig .nodeIP ).NotTo (o .BeEmpty ())
492-
493- g .By ("configure IPsec certs on the worker nodes" )
494- // The certificates in the Machine Config has validity period of 120 months starting from April 11, 2024.
495- // so proceed with test if system date is before April 10, 2034. Otherwise fail the test.
496- if ! time .Now ().Before (certExpirationDate ) {
497- framework .Failf ("certficates in the Machine Config are expired, Please consider recreating those certificates" )
498- }
499- nsCertMachineConfig , err := createIPsecCertsMachineConfig (oc )
500- o .Expect (err ).NotTo (o .HaveOccurred ())
501- o .Expect (nsCertMachineConfig ).NotTo (o .BeNil ())
502- o .Eventually (func (g o.Gomega ) bool {
503- pools , err := getMachineConfigPoolByLabel (oc , workerRoleMachineConfigLabel )
504- g .Expect (err ).NotTo (o .HaveOccurred ())
505- return areMachineConfigPoolsReadyWithMachineConfig (pools , nsCertMachineConfigName )
506- }, ipsecRolloutWaitDuration , ipsecRolloutWaitInterval ).Should (o .BeTrue ())
507- // wait for ovn-ipsec-host pod to get rolled out after certs installation.
508- waitForIPsecConfigToComplete (oc , config .ipsecMode )
509503 })
510504
511505 g .AfterEach (func () {
@@ -556,50 +550,24 @@ var _ = g.Describe("[sig-network][Feature:IPsec]", g.Ordered, func() {
556550 g .Expect (err ).NotTo (o .HaveOccurred ())
557551 return false
558552 }).Should (o .Equal (true ))
559-
560- // Removal of IPsec certs are needed otherwise worker nodes still keeping
561- // stale ip xfrm state and policy entries created for north south traffic.
562- g .By ("removing IPsec certs from worker nodes" )
563- err = deleteNSCertMachineConfig (oc )
564- o .Expect (err ).NotTo (o .HaveOccurred ())
565- o .Eventually (func (g o.Gomega ) bool {
566- pools , err := getMachineConfigPoolByLabel (oc , workerRoleMachineConfigLabel )
567- g .Expect (err ).NotTo (o .HaveOccurred ())
568- return areMachineConfigPoolsReadyWithoutMachineConfig (pools , nsCertMachineConfigName )
569- }, ipsecRolloutWaitDuration , ipsecRolloutWaitInterval ).Should (o .BeTrue ())
570-
571- // Restore the cluster back into original state after running each test.
572- g .By ("restoring ipsec config into original state" )
573- err = configureIPsecMode (oc , config .ipsecMode )
574- o .Expect (err ).NotTo (o .HaveOccurred ())
575- waitForIPsecConfigToComplete (oc , config .ipsecMode )
576553 })
577554
578- g .DescribeTable ("check traffic [apigroup:config.openshift.io] [Suite:openshift/network/ipsec]" , func (mode v1. IPsecMode ) {
555+ g .It ("check traffic with IPsec [apigroup:config.openshift.io] [Suite:openshift/network/ipsec]" , func () {
579556 o .Expect (config ).NotTo (o .BeNil ())
580557
581558 g .By ("validate traffic before changing IPsec configuration" )
582559 checkPodTraffic (config .ipsecMode )
583560 // N/S ipsec config is not in effect yet, so node traffic behaves as it were disabled
584561 checkNodeTraffic (v1 .IPsecModeDisabled )
585562
586- g .By (fmt .Sprintf ("configure IPsec in %s mode and validate traffic" , mode ))
587- // Change IPsec mode to given mode and do packet capture on the node's interface
588- err := configureIPsecMode (oc , mode )
589- o .Expect (err ).NotTo (o .HaveOccurred ())
590- waitForIPsecConfigToComplete (oc , mode )
591- checkPodTraffic (mode )
592- // N/S ipsec config is not in effect yet, so node traffic behaves as it were disabled
593- checkNodeTraffic (v1 .IPsecModeDisabled )
594-
595563 // TODO: remove this block when https://issues.redhat.com/browse/RHEL-67307 is fixed.
596- if mode == v1 .IPsecModeFull {
597- g .By (fmt .Sprintf ("skip testing IPsec NS configuration with %s mode due to nmstate bug RHEL-67307" , mode ))
564+ if config . ipsecMode == v1 .IPsecModeFull {
565+ g .By (fmt .Sprintf ("skip testing IPsec NS configuration with %s mode due to nmstate bug RHEL-67307" , config . ipsecMode ))
598566 return
599567 }
600568
601569 g .By ("rollout IPsec configuration via nmstate" )
602- err = ensureNmstateHandlerRunning (oc )
570+ err : = ensureNmstateHandlerRunning (oc )
603571 o .Expect (err ).NotTo (o .HaveOccurred ())
604572 leftConfig := fmt .Sprintf (nodeIPsecConfigManifest , leftNodeIPsecPolicyName , config .srcNodeConfig .nodeName ,
605573 config .srcNodeConfig .nodeIP , leftServerCertName , config .dstNodeConfig .nodeIP )
@@ -623,12 +591,8 @@ var _ = g.Describe("[sig-network][Feature:IPsec]", g.Ordered, func() {
623591 g .By ("validate IPsec traffic between nodes" )
624592 // Pod traffic will be encrypted as a result N/S encryption being enabled between this two nodes
625593 checkPodTraffic (v1 .IPsecModeFull )
626- checkNodeTraffic (mode )
627- },
628- g .Entry ("with IPsec in full mode" , v1 .IPsecModeFull ),
629- g .Entry ("with IPsec in external mode" , v1 .IPsecModeExternal ),
630- // TODO add test for v1.IPsecModeDisabled mode once IPsec tests stabilized in CI.
631- )
594+ checkNodeTraffic (v1 .IPsecModeExternal )
595+ })
632596 })
633597})
634598
0 commit comments