- 
                Notifications
    
You must be signed in to change notification settings  - Fork 220
 
Open
Labels
area/gkeIssues or PRs related to GKEIssues or PRs related to GKEarea/provider/gcpIssues or PRs related to gcp providerIssues or PRs related to gcp providerkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.
Description
/kind bug
What steps did you take and what happened:
Create a GKE Cluster with Private Cluster enabled:
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
metadata:
  name: "capi-cluster1-control-plane"
  namespace: "capi-clusters"
spec:
  clusterName: "capi-cluster1"
  clusterNetwork:
    privateCluster:
      enablePrivateNodes: true
      enablePrivateEndpoint: true
      controlPlaneCidrBlock: "1.2.3.4/28"
  project: "test-project"
  location: "europe-west4"
  endpoint:
    host: "1.2.3.4"
    port: 443CAPG throws nil pointer panics on creation
I0723 16:26:35.409885       1 gcpmanagedcontrolplane_controller.go:157] "Reconciling GCPManagedControlPlane" controller="gcpmanagedcontrolplane" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="GCPManagedControlPlane" GCPManagedControlPlane="capi-clusters/capi-cluster1-control-plane" namespace="capi-clusters" name="capi-cluster1-control-plane" reconcileID="b6fecaff-9e43-48b7-8859-52d5d8899d07" controller="gcpmanagedcontrolplane"
I0723 16:26:35.410484       1 reconcile.go:45] "Reconciling cluster resources" controller="gcpmanagedcontrolplane" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="GCPManagedControlPlane" GCPManagedControlPlane="capi-clusters/capi-cluster1-control-plane" namespace="capi-clusters" name="capi-cluster1-control-plane" reconcileID="b6fecaff-9e43-48b7-8859-52d5d8899d07" service="container.clusters"
I0723 16:26:35.455884       1 reconcile.go:55] "Cluster not found, creating" controller="gcpmanagedcontrolplane" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="GCPManagedControlPlane" GCPManagedControlPlane="capi-clusters/capi-cluster1-control-plane" namespace="capi-clusters" name="capi-cluster1-control-plane" reconcileID="b6fecaff-9e43-48b7-8859-52d5d8899d07" service="container.clusters"
E0723 16:26:35.459280       1 signal_unix.go:917] "Observed a panic" controller="gcpmanagedcontrolplane" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="GCPManagedControlPlane" GCPManagedControlPlane="capi-clusters/capi-cluster1-control-plane" namespace="capi-clusters" name="capi-cluster1-control-plane" reconcileID="b6fecaff-9e43-48b7-8859-52d5d8899d07" panic="runtime error: invalid memory address or nil pointer dereference" panicGoValue="\"invalid memory address or nil pointer dereference\"" stacktrace=<
        goroutine 404 [running]:
        k8s.io/apimachinery/pkg/util/runtime.logPanic({0x433cc70, 0xc0011cb410}, {0x3578ee0, 0x63c6420})
                k8s.io/[email protected]/pkg/util/runtime/runtime.go:107 +0xbc
        sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile.func1()
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:108 +0x112
        panic({0x3578ee0?, 0x63c6420?})
                runtime/panic.go:791 +0x132
        sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/clusters.(*Service).createCluster(0xc00073afb0, {0x433cd18, 0xc000491340}, 0xc000da52a0)
                sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/clusters/reconcile.go:297 +0x832
        sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/clusters.(*Service).Reconcile(0xc00073afb0, {0x433cd18, 0xc000491340})
                sigs.k8s.io/cluster-api-provider-gcp/cloud/services/container/clusters/reconcile.go:84 +0x13b0
        sigs.k8s.io/cluster-api-provider-gcp/exp/controllers.(*GCPManagedControlPlaneReconciler).reconcile(0xc001240e10?, {0x433cd18, 0xc000491340}, 0xc0017b9d80)
                sigs.k8s.io/cluster-api-provider-gcp/exp/controllers/gcpmanagedcontrolplane_controller.go:174 +0x462
        sigs.k8s.io/cluster-api-provider-gcp/exp/controllers.(*GCPManagedControlPlaneReconciler).Reconcile(0xc000af52f0, {0x433cc70?, 0xc0011cb410?}, {{{0xc000ecc150?, 0x857b79?}, {0xc000a3f740?, 0x0?}}})
                sigs.k8s.io/cluster-api-provider-gcp/exp/controllers/gcpmanagedcontrolplane_controller.go:152 +0x6c9
        sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile(0xc000e33f40?, {0x433cc70?, 0xc0011cb410?}, {{{0xc000ecc150?, 0x0?}, {0xc000a3f740?, 0x0?}}})
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:119 +0xbf
        sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler(0x4364ee0, {0x433cca8, 0xc000788a50}, {{{0xc000ecc150, 0xd}, {0xc000a3f740, 0x1b}}}, 0x0)
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:334 +0x3ad
        sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem(0x4364ee0, {0x433cca8, 0xc000788a50})
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:294 +0x21e
        sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2()
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:255 +0x85
        created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2 in goroutine 210
                sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:251 +0x6b8
>
E0723 16:26:35.459466       1 controller.go:347] "Reconciler error" err="panic: runtime error: invalid memory address or nil pointer dereference [recovered]" controller="gcpmanagedcontrolplane" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="GCPManagedControlPlane" GCPManagedControlPlane="capi-clusters/capi-cluster1-control-plane" namespace="capi-clusters" name="capi-cluster1-control-plane" reconcileID="b6fecaff-9e43-48b7-8859-52d5d8899d07"
What did you expect to happen:
Not have nil pointers thrown
Have cluster created with private cluster options correctly enabled
Anything else you would like to add:
In reconcile.go:297 as referenced in the stacktrace, we find the setting of NetworkConfig.DefaultEnablePrivateNodes.
This was changed in 1.9.0:
this commit
from
cluster.PrivateClusterConfig.EnablePrivateNodes = cn.PrivateCluster.EnablePrivateNodesto
cluster.NetworkConfig.DefaultEnablePrivateNodes = &cn.PrivateCluster.EnablePrivateNodesHowever, cluster.NetworkConfig does NOT seem to be set by cluster var definition
but only by
a later step added for SNAT et al
So cluster.NetworkConfig is nil we think.
Environment:
- Cluster-api version: 1.10.0
 - Turtles version: 0.13.0
 - Kubernetes version: 1.32
 - OS: RHEL9
 
Metadata
Metadata
Assignees
Labels
area/gkeIssues or PRs related to GKEIssues or PRs related to GKEarea/provider/gcpIssues or PRs related to gcp providerIssues or PRs related to gcp providerkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.