Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka cluster crashes provider-aws with nil pointer dereference when missing a non-required field #1391

Closed
mikansoro opened this issue Jul 26, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@mikansoro
Copy link

What happened?

Defining a Kafka cluster resource without a configurationInfo: section causes the provider-aws controller to panic with a nil pointer dereference, and strands the Kafka cluster deployment in the CannotInitializeManagedResource state. The configurationInfo block is also not marked as required on the CRD. MSK will use a default configuration for broker nodes if one is not defined per the aws docs and the terraform msk cluster resource from the aws terraform provider.

The code throwing the panic is here: kafka/cluster/setup.go#L131-134

Panic Log
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x3b2e12a]

goroutine 4315 [running]:
github.com/crossplane-contrib/provider-aws/pkg/controller/kafka/cluster.preCreate({0xc000910b40, 0xc000eb29f8}, 0xc000910b40, 0xc002573f20)
	/home/runner/work/provider-aws/provider-aws/pkg/controller/kafka/cluster/setup.go:132 +0x1ca
github.com/crossplane-contrib/provider-aws/pkg/controller/kafka/cluster.(*external).Create(0xc0005e4930, {0x6436db0, 0xc001819980}, {0x6514f60, 0xc000910b40})
	/home/runner/work/provider-aws/provider-aws/pkg/controller/kafka/cluster/zz_controller.go:109 +0x1dd
github.com/crossplane/crossplane-runtime/pkg/reconciler/managed.(*Reconciler).Reconcile(0xc0006960b0, {0x6436de8, 0xc0026b3ef0}, {{{0x0, 0x57c9740}, {0xc001d76348, 0x30}}})
	/home/runner/work/provider-aws/provider-aws/vendor/github.com/crossplane/crossplane-runtime/pkg/reconciler/managed/reconciler.go:886 +0x5fd7
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0xc000696160, {0x6436de8, 0xc0026b3e30}, {{{0x0, 0x57c9740}, {0xc001d76348, 0x413a94}}})
	/home/runner/work/provider-aws/provider-aws/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:114 +0x26f
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000696160, {0x6436d40, 0xc0005e17c0}, {0x5316980, 0xc00298e9a0})
	/home/runner/work/provider-aws/provider-aws/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:311 +0x33e
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000696160, {0x6436d40, 0xc0005e17c0})
	/home/runner/work/provider-aws/provider-aws/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
	/home/runner/work/provider-aws/provider-aws/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
	/home/runner/work/provider-aws/provider-aws/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:223 +0x357

How can we reproduce it?

Example manifest of a minimal deployment of a Kafka cluster that results in a panic for the controller added below.

Example Manifest:
apiVersion: kafka.aws.crossplane.io/v1alpha1
kind: Cluster
metadata:
  name: <cluster-name>
spec:
  providerConfigRef:
    name: provider-aws
  deletionPolicy: Delete
  forProvider:
    clientAuthentication:
      unauthenticated:
        enabled: true
    kafkaVersion: 3.2.0
    numberOfBrokerNodes: 2
    region: us-east-1
    brokerNodeGroupInfo:
      storageInfo:
        ebsStorageInfo:
          volumeSize: 128
      instanceType: "kafka.m5.large"
      clientSubnets:
        - <subnet-1>
        - <subnet-2>
      securityGroups:
        - <security-group-1>
    # configurationInfo:
      # arn: <configuration-arn>
      # revision: 1

What environment did it happen in?

Crossplane version: v1.5.0
Provider-Aws Version: v0.28.0
Kubernetes Version: 1.21
Platform: EKS

@mikansoro mikansoro added the bug Something isn't working label Jul 26, 2022
@haarchri
Copy link
Member

We have an open PR for this #1320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants