Skip to content

Conversation

squeed
Copy link
Contributor

@squeed squeed commented Oct 9, 2024

The connectivity-test code allows for creating dependent resources as a part of tests (e.g. NetworkPolicies). However, the code as written requires new methods for every kind of resource.

This change converts this to use the dynamic client, which is resource-agnostic. That allows for creating arbitrary sets of resources, as well as mixing resource kinds in a single YAML file. It removes a lot of boilerplate and churn as new resources are needed.

Internally, it uses Server-Side Apply to reduce the number of k8s API calls necessary.

@squeed squeed added kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact. labels Oct 9, 2024
@squeed squeed requested review from a team as code owners October 9, 2024 12:41
@github-actions github-actions bot added cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary labels Oct 9, 2024
@squeed squeed force-pushed the ccli-generic-objects branch from 1afd8c4 to e6e7af8 Compare October 9, 2024 12:43
@squeed
Copy link
Contributor Author

squeed commented Oct 9, 2024

/test

Copy link
Member

@nathanjsweet nathanjsweet left a comment

Choose a reason for hiding this comment

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

noice!

The connectivity-test code allows for creating dependent resources as a
part of tests (e.g. NetworkPolicies). However, the code as written
requires new methods for every kind of resource.

This change converts this to use the dynamic client, which is
resource-agnostic. That allows for creating arbitrary sets of resources,
as well as mixing resource kinds in a single YAML file. It removes a lot
of boilerplate and churn as new resources are needed.

Internally, it uses Server-Side Apply to reduce the number of k8s API
calls necessary.

Signed-off-by: Casey Callendrello <cdc@isovalent.com>
@squeed squeed force-pushed the ccli-generic-objects branch from e6e7af8 to 8b17441 Compare October 9, 2024 20:34
@squeed
Copy link
Contributor Author

squeed commented Oct 9, 2024

/test

@nathanjsweet nathanjsweet added this pull request to the merge queue Oct 9, 2024
Merged via the queue into cilium:main with commit aabda4b Oct 9, 2024
62 checks passed
jschwinger233 added a commit that referenced this pull request Dec 17, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium IPv6 had basic connectivity. Previously CI workflows
didn't cover IPv6 connectivity in 1.13, until #35314
recently enabled it. Subsequently, We noticed a number of CI failures in
ci-ipsec-upgrade, caused by testing IPv6 connectivity in 1.13.

This patch skips IPv6 connectivity test for Cilium<1.14.

Signed-off-by: gray <gray.liang@isovalent.com>
jschwinger233 added a commit that referenced this pull request Dec 18, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch skips IPsec IPv6 connectivity test for Cilium<1.14.

[1] #23461

Signed-off-by: gray <gray.liang@isovalent.com>
Comment on lines -952 to -961
// The per-endpoint routes feature is broken with IPv6 on < v1.14 when there
// are any netpols installed (https://github.com/cilium/cilium/issues/23852
// and https://github.com/cilium/cilium/issues/23910).
if f, ok := t.Context().Feature(features.EndpointRoutes); ok &&
f.Enabled && (len(t.cnps) > 0 || len(t.knps) > 0) &&
versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) {

ipFams = []features.IPFamily{features.IPFamilyV4}
}

Copy link
Member

Choose a reason for hiding this comment

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

This part (and the other skip if <v1.14 part below) should have really been a separate patch. And ideally even a separate PR, so that the impact on downgrade testing for v1.14 -> v1.13 would have been obvious.

jschwinger233 added a commit that referenced this pull request Dec 26, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch reverts the deletion of `if <1.14 then skip` made by
#35314.

[1] #23461

Signed-off-by: gray <gray.liang@isovalent.com>
jschwinger233 added a commit that referenced this pull request Dec 26, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch reverts the deletion of `if <1.14 then skip` made by
#35314. [2]

[1] #23461
[2] g diff aabda4b aabda4b~ | grep '<1.14.0' -C8

```diff
 func (t *Test) ForEachIPFamily(do func(features.IPFamily)) {
 	ipFams := []features.IPFamily{features.IPFamilyV4, features.IPFamilyV6}

+	// The per-endpoint routes feature is broken with IPv6 on < v1.14 when there
+	// are any netpols installed (#23852
+	// and #23910).
+	if f, ok := t.Context().Feature(features.EndpointRoutes); ok &&
+		f.Enabled && (len(t.cnps) > 0 || len(t.knps) > 0) &&
+		versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) {
+
+		ipFams = []features.IPFamily{features.IPFamilyV4}
+	}
+
 	for _, ipFam := range ipFams {
 		switch ipFam {
 		case features.IPFamilyV4:
@@ -853,6 +979,18 @@ func (t *Test) CertificateCAs() map[string][]byte {
--
+	"github.com/cilium/cilium/pkg/versioncheck"
 )

 // PodToService sends an HTTP request from all client Pods
@@ -227,6 +228,13 @@ func curlNodePort(ctx context.Context, s check.Scenario, t *check.Test,
 				}
 			}

+			//  Skip IPv6 requests when running on <1.14.0 Cilium with CNPs
+			if features.GetIPFamily(addr.Address) == features.IPFamilyV6 &&
+				versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) &&
+				(len(t.CiliumNetworkPolicies()) > 0 || len(t.KubernetesNetworkPolicies()) > 0) {
+				continue
+			}
+
 			// Manually construct an HTTP endpoint to override the destination IP
 			// and port of the request.
 			ep := check.HTTPEndpoint(name, fmt.Sprintf("%s://%s:%d%s", svc.Scheme(), addr.Address, np, svc.Path()))
diff --git a/cilium-cli/k8s/client.go b/cilium-cli/k8s/client.go
```

Signed-off-by: gray <gray.liang@isovalent.com>
jschwinger233 added a commit that referenced this pull request Dec 26, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch reverts the deletion of `if <1.14 then skip` made by
#35314. [2]

[1] #23461
[2] g diff aabda4b aabda4b~ | grep '<1.14.0' -C8

```
 func (t *Test) ForEachIPFamily(do func(features.IPFamily)) {
 	ipFams := []features.IPFamily{features.IPFamilyV4, features.IPFamilyV6}

+	// The per-endpoint routes feature is broken with IPv6 on < v1.14 when there
+	// are any netpols installed (#23852
+	// and #23910).
+	if f, ok := t.Context().Feature(features.EndpointRoutes); ok &&
+		f.Enabled && (len(t.cnps) > 0 || len(t.knps) > 0) &&
+		versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) {
+
+		ipFams = []features.IPFamily{features.IPFamilyV4}
+	}
+
 	for _, ipFam := range ipFams {
 		switch ipFam {
 		case features.IPFamilyV4:
@@ -853,6 +979,18 @@ func (t *Test) CertificateCAs() map[string][]byte {
--
+	"github.com/cilium/cilium/pkg/versioncheck"
 )

 // PodToService sends an HTTP request from all client Pods
@@ -227,6 +228,13 @@ func curlNodePort(ctx context.Context, s check.Scenario, t *check.Test,
 				}
 			}

+			//  Skip IPv6 requests when running on <1.14.0 Cilium with CNPs
+			if features.GetIPFamily(addr.Address) == features.IPFamilyV6 &&
+				versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) &&
+				(len(t.CiliumNetworkPolicies()) > 0 || len(t.KubernetesNetworkPolicies()) > 0) {
+				continue
+			}
+
 			// Manually construct an HTTP endpoint to override the destination IP
 			// and port of the request.
 			ep := check.HTTPEndpoint(name, fmt.Sprintf("%s://%s:%d%s", svc.Scheme(), addr.Address, np, svc.Path()))
diff --git a/cilium-cli/k8s/client.go b/cilium-cli/k8s/client.go
```

Signed-off-by: gray <gray.liang@isovalent.com>
jschwinger233 added a commit that referenced this pull request Dec 27, 2024
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch reverts the deletion of `if <1.14 then skip` made by
#35314. [2]

[1] #23461
[2] git diff aabda4b aabda4b~

```
 func (t *Test) ForEachIPFamily(do func(features.IPFamily)) {
+	// The per-endpoint routes feature is broken with IPv6 on < v1.14 when there
+	// are any netpols installed (#23852
+	// and #23910).
+	if f, ok := t.Context().Feature(features.EndpointRoutes); ok &&
+		f.Enabled && (len(t.cnps) > 0 || len(t.knps) > 0) &&
+		versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) {
+
+		ipFams = []features.IPFamily{features.IPFamilyV4}
+	}
+

func curlNodePort(ctx context.Context, s check.Scenario, t *check.Test,
+			//  Skip IPv6 requests when running on <1.14.0 Cilium with CNPs
+			if features.GetIPFamily(addr.Address) == features.IPFamilyV6 &&
+				versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) &&
+				(len(t.CiliumNetworkPolicies()) > 0 || len(t.KubernetesNetworkPolicies()) > 0) {
+				continue
+			}
+
```

Signed-off-by: gray <gray.liang@isovalent.com>
aanm pushed a commit that referenced this pull request Jan 6, 2025
It wasn't until #23445 was fixed
in 1.14 when Cilium had robust IPv6 connectivity for IPsec[1].
Previously CI workflows didn't run IPv6 connectivity for IPsec in 1.13,
until #35314 recently enabled it.
Subsequently, We noticed a number of CI failures in ci-ipsec-upgrade,
caused by testing IPv6 connectivity in 1.13.

This patch reverts the deletion of `if <1.14 then skip` made by
#35314. [2]

[1] #23461
[2] git diff aabda4b aabda4b~

```
 func (t *Test) ForEachIPFamily(do func(features.IPFamily)) {
+	// The per-endpoint routes feature is broken with IPv6 on < v1.14 when there
+	// are any netpols installed (#23852
+	// and #23910).
+	if f, ok := t.Context().Feature(features.EndpointRoutes); ok &&
+		f.Enabled && (len(t.cnps) > 0 || len(t.knps) > 0) &&
+		versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) {
+
+		ipFams = []features.IPFamily{features.IPFamilyV4}
+	}
+

func curlNodePort(ctx context.Context, s check.Scenario, t *check.Test,
+			//  Skip IPv6 requests when running on <1.14.0 Cilium with CNPs
+			if features.GetIPFamily(addr.Address) == features.IPFamilyV6 &&
+				versioncheck.MustCompile("<1.14.0")(t.Context().CiliumVersion) &&
+				(len(t.CiliumNetworkPolicies()) > 0 || len(t.KubernetesNetworkPolicies()) > 0) {
+				continue
+			}
+
```

Signed-off-by: gray <gray.liang@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants