Skip to content

Conversation

@supershal
Copy link
Contributor

What problem does this PR solve?:
This bug was found when integrating EKS provider with NKP UI.
The Managed Kubernetes providers like EKS and AKS will not have controlplane infrastructure provider reference.
This PR copies controlplane infrastructure provider template only if they exists.
Tested with unit tests:
Before fix the test failed with:

Starting the test environment manager
I1027 17:01:27.066340    8612 controller.go:204] "Starting EventSource" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" source="kind source: *v1beta1.ClusterClass"
I1027 17:01:27.066340    8612 controller.go:204] "Starting EventSource" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" source="kind source: *v1.Namespace"
I1027 17:01:27.169218    8612 controller.go:239] "Starting Controller" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace"
I1027 17:01:27.169236    8612 controller.go:248] "Starting workers" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" worker count=1
E1027 17:01:29.548837    8612 controller.go:347] "Reconciler error" err="failed to copy source ClusterClass source/test-5r8wr or its referenced Templates to namespace target-kx6ls: error processing references: failed to get reference: failed to get GenericBootstrapConfigTemplate test-5r8wr/source: failed to retrieve GenericBootstrapConfigTemplate source/test-5r8wr: GenericBootstrapConfigTemplate.bootstrap.cluster.x-k8s.io \"test-5r8wr\" not found" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" Namespace="target-kx6ls" namespace="" name="target-kx6ls" reconcileID="8ca531d5-2634-4a4c-9b96-fe34a9245399"
E1027 17:01:29.554044    8612 controller.go:347] "Reconciler error" err="failed to copy source ClusterClass source/test-5r8wr or its referenced Templates to namespace target-kx6ls: error processing references: failed to get reference: failed to get GenericInfrastructureClusterTemplate test-5r8wr/source: failed to retrieve GenericInfrastructureClusterTemplate source/test-5r8wr: GenericInfrastructureClusterTemplate.infrastructure.cluster.x-k8s.io \"test-5r8wr\" not found" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" Namespace="target-kx6ls" namespace="" name="target-kx6ls" reconcileID="840dc3e9-594e-43f1-83c4-ab549d8c11f1"
E1027 17:01:29.562716    8612 signal_unix.go:925] "Observed a panic" controller="syncclusterclass" controllerGroup="" controllerKind="Namespace" Namespace="target-87wdz" namespace="" name="target-87wdz" reconcileID="fb7cbaa9-cf65-4cce-87b3-d773403de9d2" panic="runtime error: invalid memory address or nil pointer dereference" panicGoValue="\"invalid memory address or nil pointer dereference\"" stacktrace=<
	goroutine 298 [running]:
	k8s.io/apimachinery/pkg/util/runtime.logPanic({0x10299b1d0, 0x1400099bb00}, {0x1026c5800, 0x103940090})
		/Users/shalinpatel/go/pkg/mod/k8s.io/apimachinery@v0.32.9/pkg/util/runtime/runtime.go:107 +0x94
	sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile.func1()
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:108 +0xdc
	panic({0x1026c5800?, 0x103940090?})
		/Users/shalinpatel/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.1.darwin-arm64/src/runtime/panic.go:783 +0x120
	github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync.walkReferences({0x10299b1d0, 0x1400099bb00}, 0x140009e6008, 0x14000ff3aa0)
		/Users/shalinpatel/gitrepos/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync/references.go:63 +0x44
	github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync.copyClusterClassAndTemplates({0x10299b1d0, 0x1400099bb00}, {0x14b31e140, 0x14001082f30}, {0x14d490230, 0x14001083a70}, 0x14000ff3b38?, {0x14001100340, 0xc})
		/Users/shalinpatel/gitrepos/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync/copy.go:25 +0xb4
	github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync.(*Reconciler).Reconcile(0x14000e53800, {0x10299b1d0, 0x1400099bb00}, {{{0x0?, 0x14000ff3c38?}, {0x14001100340?, 0x14000ff3c58?}}})
		/Users/shalinpatel/gitrepos/cluster-api-runtime-extensions-nutanix/pkg/controllers/namespacesync/controller.go:134 +0x134
	sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile(0x140005e1240?, {0x10299b1d0?, 0x1400099bb00?}, {{{0x0?, 0x0?}, {0x14001100340?, 0x0?}}})
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:119 +0x8c
	sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler(0x1029b3160, {0x10299b208, 0x14000035270}, {{{0x0, 0x0}, {0x14001100340, 0xc}}}, 0x0)
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:334 +0x280
	sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem(0x1029b3160, {0x10299b208, 0x14000035270})
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:294 +0x16c
	sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2()
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:255 +0x74
	created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2 in goroutine 313
		/Users/shalinpatel/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:251 +0x4e4

Which issue(s) this PR fixes:
Fixes #

How Has This Been Tested?:

Special notes for your reviewer:

@github-actions github-actions bot added the fix label Oct 28, 2025
@supershal supershal self-assigned this Oct 28, 2025
@supershal supershal changed the title fix: skip syncing eks controlplane's infrastructure templates for EKS Clusterclass fix: skip syncing controlplane's infrastructure templates for EKS Clusterclass Oct 28, 2025
@github-actions github-actions bot added fix and removed fix labels Oct 28, 2025
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

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

Thank you for the tests!

@dlipovetsky
Copy link
Contributor

Thanks for finding this bug!

Copy link
Contributor

@dlipovetsky dlipovetsky left a comment

Choose a reason for hiding this comment

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

Brilliant! Thank you 🙏

@supershal supershal enabled auto-merge (squash) October 28, 2025 22:43
@supershal supershal merged commit 0f4ce8a into main Oct 29, 2025
22 checks passed
@supershal supershal deleted the shalin/fix-namespace branch October 29, 2025 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants