Skip to content

Dependency upgrade and e2e tests - #308

Merged
salv-orlando merged 2 commits into
mainfrom
dep_upgrade_and_e2e
Jun 23, 2026
Merged

salv-orlando merged 2 commits into
mainfrom
dep_upgrade_and_e2e

Conversation

@salv-orlando

Copy link
Copy Markdown
Member

e2e testing:

Key components implemented:
- Mock NSX API Service (nsx-mock): A custom Go-based server simulating NSX-T
  Policy APIs (VIF queries, logical switch port tagging, search, and dynamic
  node mapping) with self-signed TLS support.
- Fake NCP Container Image: A lightweight Alpine-based mock image simulating
  NCP workloads, with graceful signal handling (SIGTERM/SIGINT) to prevent
  stuck terminations.
- Declarative Manifests: Kind cluster configuration (setting node provider-id),
  operator deployment with custom DNS policy (ClusterFirstWithHostNet) to
  resolve in-cluster services, and mock NSX service definitions.
- Go-based E2E Test Suite: 9 comprehensive test scenarios in operator_test.go
  covering operator startup, status reporting, node port tagging, self-healing
  of lost tags, MTU updates, NcpInstall CR reconciliation (replicas, addNodeTag),
  and image patching.
- Makefile Integration: Automation targets for cluster lifecycle management,
  image building/loading, and local test execution.
- GitHub Actions Workflow: CI pipeline integration to build, deploy, and run
  the entire E2E test suite on every PR.

dependency upgrade:

Upgrades completed:
- github.com/openshift/api: v3.9.1+incompatible -> v0.0.0-20260521125114 (latest)
- github.com/pkg/errors: v0.9.1 -> v0.9.2-0.20260327151000 (latest commit)
- github.com/sirupsen/logrus: v1.8.3 -> v1.9.4
- github.com/spf13/pflag: v1.0.5 -> v1.0.10
- github.com/stretchr/testify: v1.7.0 -> v1.11.1
- github.com/vmware/go-vmware-nsxt: v0.0.0-20201207175959 -> v0.0.0-20230223012718
- github.com/vmware/vsphere-automation-sdk-go/runtime: v0.7.0 -> v0.8.1-0.20250317060414
- github.com/vmware/vsphere-automation-sdk-go/services/nsxt: v0.12.0 -> v0.12.1-0.20250317060414
- gopkg.in/ini.v1: v1.51.0 -> v1.67.2
- github.com/vmware/go-vmware-nsxt: v0.0.0-20230223012718-d31b8a1ca05e -> v0.0.0-20260605141659-71d9620e9c4e

Kubernetes ecosystem coordinated upgrade:
- k8s.io/api: v0.18.2 -> v0.36.1
- k8s.io/apimachinery: v0.18.3 -> v0.36.1
- k8s.io/client-go: v12.0.0+incompatible -> v0.36.1
- k8s.io/kubectl: v0.17.4 -> v0.36.1
- sigs.k8s.io/controller-runtime: v0.5.2 -> v0.24.1

Indirect dependency upgrades:
- github.com/klauspost/compress: v1.18.1 -> v1.18.6
- golang.org/x/net: v0.53.0 -> v0.55.0
- golang.org/x/oauth2: v0.35.0 -> v0.36.0
- golang.org/x/sys: v0.43.0 -> v0.45.0
- golang.org/x/term: v0.42.0 -> v0.43.0
- golang.org/x/text: v0.36.0 -> v0.37.0
- golang.org/x/time: v0.14.0 -> v0.15.0

Dependencies removed:
- github.com/ghodss/yaml v1.0.0 (replaced with sigs.k8s.io/yaml v1.6.0)
- github.com/imdario/mergo v0.3.7 (replaced with dario.cat/mergo v1.0.2)
- github.com/openshift/cluster-network-operator v0.0.0-20200505233431 (internalized utilities)
- github.com/openshift/library-go v0.0.0-20200511081854 (internalized helpers)
- github.com/operator-framework/operator-sdk v0.17.1 (no longer needed)
- github.com/antihax/optional v1.0.0 dependency (no longer needed)

Dependencies added:
- dario.cat/mergo v1.0.2 (modern replacement for imdario/mergo)
- github.com/go-logr/zapr v1.3.1-0.20260413055308 (latest commit)
- go.uber.org/zap v1.28.0 (structured logging)
- k8s.io/utils v0.0.0-20260507154919 (Kubernetes utilities)
- sigs.k8s.io/yaml v1.6.0 (modern YAML library)

Comprehensive application logic changes:
- Removed dependency on openshift/cluster-network-operator by internalizing utilities:
  * Created pkg/util/render/render.go with custom template rendering
  * Created pkg/util/k8s/unstructured.go with ToUnstructured helper
  * Created pkg/util/k8s/v1helpers.go with status condition helpers
- Updated import paths across all controllers to use internal utilities
- Replaced github.com/ghodss/yaml with sigs.k8s.io/yaml throughout codebase
- Fixed controller-runtime v0.18+ status subresource semantics in tests:
  * Configured fake clients with WithStatusSubresource()
  * Changed client.Update() to client.Status().Update() for status fields
- Updated Go version requirement to 1.26.2
- Modernized dependency analyzer script with enhanced pseudo-version handling
- All unit tests pass with new dependency versions
- Build verified with latest Kubernetes v0.36.1 APIs

This upgrade resolves version conflicts, removes multiple obsolete transitive
dependencies, and positions the project for modern Kubernetes environments.

Comment thread .github/workflows/e2e.yml
Comment on lines +13 to +54
name: End-to-End Test
runs-on: ubuntu-latest
steps:
- name: Check-out code
uses: actions/checkout@v4

- name: Set up Go 1.26
uses: actions/setup-go@v4
with:
go-version: 1.26.2
cache: false

- name: Log in to Docker Hub
env:
DOCKER_USER_ENV: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASS_ENV: ${{ secrets.DOCKER_PASSWORD }}

if: ${{ env.DOCKER_USER_ENV != '' && env.DOCKER_PASS_ENV != '' }}

uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create Kind Cluster
run: make kind-start

- name: Build Test Images
run: make build-test-images

- name: Load Images into Kind
run: make load-images

- name: Deploy Operator and Mock NSX
run: make deploy-e2e

- name: Run E2E Test Suite
run: make test-e2e-local

- name: Clean up Kind Cluster
if: always()
run: make kind-stop
Comment thread cmd/manager/main.go
log.Error(err, "")
log.Error(err, "unable to start manager")
os.Exit(1)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

L79 to 82 are dup of 73 to 76

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I made some mistakes while rebasing

Comment thread cmd/manager/main.go
options := manager.Options{
Namespace: namespace,
MetricsBindAddress: metricsBindAddr,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we don't need to use these options anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right. An assumption was made that a single replica of the operator was running.
While we don't need to pass anymore the namespace to manager.Options, we still need it for leader election.

The Namespace field in manager.Options has been removed. Also, the operator is actuall watching resources in multiple namespaces, and for controllers where we watch resources in a specific namespace (nsx-system) we already use predicates.

I will restore the logic for leaderEletion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ack


annotations:
container.apparmor.security.beta.kubernetes.io/nsx-node-agent: localhost/node-agent-apparmor
annotations: {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we added this annotation long ago (6-7 years). It maybe that it's not needed. Does the test run on Ubuntu?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, support for this annotation is completely removed.
I did this as a part of the "modernization" of the operator.

However, we should have added the apparmor profile to the security context, and it seems we didn't. Therefore this needs additional investigation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should keep this considering we're not supporting yet 1.36 (where it was removed) and that manifest should be synced differently.

Still, we need to prepare for this change by updating the nsx-node-agent ds template, but this should be done in a different PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ack

}

if err = apply.ApplyObject(context.TODO(), r.client, obj); err != nil {
// TODO: Remove deprecated client.Apply

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not do it in this patch?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. No reason to be lazy

This commit modernizes all dependencies and removes obsolete packages while
maintaining full API compatibility and test coverage.

Upgrades completed:
- github.com/openshift/api: v3.9.1+incompatible -> v0.0.0-20260521125114 (latest)
- github.com/pkg/errors: v0.9.1 -> v0.9.2-0.20260327151000 (latest commit)
- github.com/sirupsen/logrus: v1.8.3 -> v1.9.4
- github.com/spf13/pflag: v1.0.5 -> v1.0.10
- github.com/stretchr/testify: v1.7.0 -> v1.11.1
- github.com/vmware/go-vmware-nsxt: v0.0.0-20201207175959 -> v0.0.0-20230223012718
- github.com/vmware/vsphere-automation-sdk-go/runtime: v0.7.0 -> v0.8.1-0.20250317060414
- github.com/vmware/vsphere-automation-sdk-go/services/nsxt: v0.12.0 -> v0.12.1-0.20250317060414
- gopkg.in/ini.v1: v1.51.0 -> v1.67.2
- github.com/vmware/go-vmware-nsxt: v0.0.0-20230223012718-d31b8a1ca05e -> v0.0.0-20260605141659-71d9620e9c4e

Kubernetes ecosystem coordinated upgrade:
- k8s.io/api: v0.18.2 -> v0.36.1
- k8s.io/apimachinery: v0.18.3 -> v0.36.1
- k8s.io/client-go: v12.0.0+incompatible -> v0.36.1
- k8s.io/kubectl: v0.17.4 -> v0.36.1
- sigs.k8s.io/controller-runtime: v0.5.2 -> v0.24.1

Indirect dependency upgrades:
- github.com/klauspost/compress: v1.18.1 -> v1.18.6
- golang.org/x/net: v0.53.0 -> v0.55.0
- golang.org/x/oauth2: v0.35.0 -> v0.36.0
- golang.org/x/sys: v0.43.0 -> v0.45.0
- golang.org/x/term: v0.42.0 -> v0.43.0
- golang.org/x/text: v0.36.0 -> v0.37.0
- golang.org/x/time: v0.14.0 -> v0.15.0

Dependencies removed:
- github.com/ghodss/yaml v1.0.0 (replaced with sigs.k8s.io/yaml v1.6.0)
- github.com/imdario/mergo v0.3.7 (replaced with dario.cat/mergo v1.0.2)
- github.com/openshift/cluster-network-operator v0.0.0-20200505233431 (internalized utilities)
- github.com/openshift/library-go v0.0.0-20200511081854 (internalized helpers)
- github.com/operator-framework/operator-sdk v0.17.1 (no longer needed)
- github.com/antihax/optional v1.0.0 dependency (no longer needed)

Dependencies added:
- dario.cat/mergo v1.0.2 (modern replacement for imdario/mergo)
- github.com/go-logr/zapr v1.3.1-0.20260413055308 (latest commit)
- go.uber.org/zap v1.28.0 (structured logging)
- k8s.io/utils v0.0.0-20260507154919 (Kubernetes utilities)
- sigs.k8s.io/yaml v1.6.0 (modern YAML library)

Comprehensive application logic changes:
- Removed dependency on openshift/cluster-network-operator by internalizing utilities:
  * Created pkg/util/render/render.go with custom template rendering
  * Created pkg/util/k8s/unstructured.go with ToUnstructured helper
  * Created pkg/util/k8s/v1helpers.go with status condition helpers
- Updated import paths across all controllers to use internal utilities
- Replaced github.com/ghodss/yaml with sigs.k8s.io/yaml throughout codebase
- Fixed controller-runtime v0.18+ status subresource semantics in tests:
  * Configured fake clients with WithStatusSubresource()
  * Changed client.Update() to client.Status().Update() for status fields
- Updated Go version requirement to 1.26.2
- Modernized dependency analyzer script with enhanced pseudo-version handling
- All unit tests pass with new dependency versions
- Build verified with latest Kubernetes v0.36.1 APIs

This upgrade resolves version conflicts, removes multiple obsolete transitive
dependencies, and positions the project for modern Kubernetes environments.

Co-authored-by: Cursor <cursoragent@cursor.com>
@salv-orlando
salv-orlando force-pushed the dep_upgrade_and_e2e branch 2 times, most recently from e645cae to 46e0e04 Compare June 22, 2026 14:43
This commit implements a comprehensive end-to-end (E2E) testing framework
for the NSX Container Plugin Operator, enabling automated verification of
operator deployment, status reporting, and reconciliation behavior.

Key components implemented:
- Mock NSX API Service (nsx-mock): A custom Go-based server simulating NSX-T
  Policy APIs (VIF queries, logical switch port tagging, search, and dynamic
  node mapping) with self-signed TLS support.
- Fake NCP Container Image: A lightweight Alpine-based mock image simulating
  NCP workloads, with graceful signal handling (SIGTERM/SIGINT) to prevent
  stuck terminations.
- Declarative Manifests: Kind cluster configuration (setting node provider-id),
  operator deployment with custom DNS policy (ClusterFirstWithHostNet) to
  resolve in-cluster services, and mock NSX service definitions.
- Go-based E2E Test Suite: 9 comprehensive test scenarios in operator_test.go
  covering operator startup, status reporting, node port tagging, self-healing
  of lost tags, MTU updates, NcpInstall CR reconciliation (replicas, addNodeTag),
  and image patching.
- Makefile Integration: Automation targets for cluster lifecycle management,
  image building/loading, and local test execution.
- GitHub Actions Workflow: CI pipeline integration to build, deploy, and run
  the entire E2E test suite on every PR.

Co-authored-by: Cursor <cursoragent@cursor.com>
@salv-orlando
salv-orlando force-pushed the dep_upgrade_and_e2e branch from 46e0e04 to 00a553d Compare June 22, 2026 16:24
@salv-orlando
salv-orlando merged commit f7cd179 into main Jun 23, 2026
9 checks passed
@salv-orlando
salv-orlando deleted the dep_upgrade_and_e2e branch July 2, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants