crossplane-contrib / provider-azure

Crossplane Azure Provider
Apache License 2.0
92 stars 64 forks source link

Provider crashes when creating Storage account without writeConnectionSecretToRef #335

Open sschne opened 2 years ago

sschne commented 2 years ago

What happened?

When trying to create a storage account without specified writeConnectionSecretToRef, the provider crashes

E0407 12:31:46.491459       1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 528 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x197dac0, 0x2997560)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/runtime/runtime.go:48 +0x86
panic(0x197dac0, 0x2997560)
        /opt/hostedtoolcache/go/1.16.10/x64/src/runtime/panic.go:965 +0x1b9
github.com/crossplane/crossplane-runtime/pkg/resource.ConnectionSecretFor(0x1e0d618, 0xc0005c5200, 0x1ba4f23, 0x1b, 0x1b8f247, 0x8, 0x18512bd, 0x7, 0xc00013eac0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/github.com/crossplane/crossplane-runtime@v0.14.0/pkg/resource/resource.go:134 +0x23b
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSecretUpdater).updatesecret(0xc0007cbdd0, 0x1de0640, 0xc0005c1d40, 0xc000756fc0, 0xc0005c5200, 0x0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:348 +0x74
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSyncbacker).syncback(0xc0007cbe00, 0x1de0640, 0xc0005c1d40, 0xc000756fc0, 0xc00035a360, 0x0, 0xc00035a330, 0xc000756fc0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:324 +0x3e3
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountCreateUpdater).update(0xc00060d450, 0x1de0640, 0xc0005c1d40, 0xc0005c1da0, 0x0, 0x0, 0x6fc23ac00, 0xc00054b2c0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:292 +0x97
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSyncDeleter).sync(0xc000814680, 0x1de0640, 0xc0005c1d40, 0xc0005c5200, 0xdf8475800, 0x1db4c70, 0xc000814680)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:227 +0x19d
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*Reconciler).Reconcile(0xc0002e9500, 0x1de0678, 0xc0005c1d40, 0x0, 0x0, 0xc0008c6490, 0xd, 0xc0007cb900, 0x0, 0x0, ...)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:125 +0x4b2
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc00073a640, 0x1de05d0, 0xc0003de000, 0x19e03e0, 0xc000678ce0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:293 +0x30d
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc00073a640, 0x1de05d0, 0xc0003de000, 0x7f76d6b1f200)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:248 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1(0x1de05d0, 0xc0003de000)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:211 +0x4a
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1()
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:185 +0x37
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000439750)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc001087f50, 0x1dac020, 0xc0007cb980, 0xc0003de001, 0xc0000923c0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:156 +0x9b
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000439750, 0x3b9aca00, 0x0, 0xc0002beb01, 0xc0000923c0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext(0x1de05d0, 0xc0003de000, 0xc0005bb3f0, 0x3b9aca00, 0x0, 0x1)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:185 +0xa6
k8s.io/apimachinery/pkg/util/wait.UntilWithContext(0x1de05d0, 0xc0003de000, 0xc0005bb3f0, 0x3b9aca00)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:99 +0x57
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:208 +0x49e
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x147115b]

goroutine 528 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/runtime/runtime.go:55 +0x109
panic(0x197dac0, 0x2997560)
        /opt/hostedtoolcache/go/1.16.10/x64/src/runtime/panic.go:965 +0x1b9
github.com/crossplane/crossplane-runtime/pkg/resource.ConnectionSecretFor(0x1e0d618, 0xc0005c5200, 0x1ba4f23, 0x1b, 0x1b8f247, 0x8, 0x18512bd, 0x7, 0xc00013eac0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/github.com/crossplane/crossplane-runtime@v0.14.0/pkg/resource/resource.go:134 +0x23b
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSecretUpdater).updatesecret(0xc0007cbdd0, 0x1de0640, 0xc0005c1d40, 0xc000756fc0, 0xc0005c5200, 0x0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:348 +0x74
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSyncbacker).syncback(0xc0007cbe00, 0x1de0640, 0xc0005c1d40, 0xc000756fc0, 0xc00035a360, 0x0, 0xc00035a330, 0xc000756fc0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:324 +0x3e3
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountCreateUpdater).update(0xc00060d450, 0x1de0640, 0xc0005c1d40, 0xc0005c1da0, 0x0, 0x0, 0x6fc23ac00, 0xc00054b2c0)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:292 +0x97
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*accountSyncDeleter).sync(0xc000814680, 0x1de0640, 0xc0005c1d40, 0xc0005c5200, 0xdf8475800, 0x1db4c70, 0xc000814680)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:227 +0x19d
github.com/crossplane/provider-azure/pkg/controller/storage/account.(*Reconciler).Reconcile(0xc0002e9500, 0x1de0678, 0xc0005c1d40, 0x0, 0x0, 0xc0008c6490, 0xd, 0xc0007cb900, 0x0, 0x0, ...)
        /home/runner/work/provider-azure/provider-azure/pkg/controller/storage/account/account.go:125 +0x4b2
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc00073a640, 0x1de05d0, 0xc0003de000, 0x19e03e0, 0xc000678ce0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:293 +0x30d
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc00073a640, 0x1de05d0, 0xc0003de000, 0x7f76d6b1f200)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:248 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1(0x1de05d0, 0xc0003de000)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:211 +0x4a
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1()
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:185 +0x37
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000439750)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc001087f50, 0x1dac020, 0xc0007cb980, 0xc0003de001, 0xc0000923c0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:156 +0x9b
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000439750, 0x3b9aca00, 0x0, 0xc0002beb01, 0xc0000923c0)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext(0x1de05d0, 0xc0003de000, 0xc0005bb3f0, 0x3b9aca00, 0x0, 0x1)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:185 +0xa6
k8s.io/apimachinery/pkg/util/wait.UntilWithContext(0x1de05d0, 0xc0003de000, 0xc0005bb3f0, 0x3b9aca00)
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/k8s.io/apimachinery@v0.20.1/pkg/util/wait/wait.go:99 +0x57
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1
        /home/runner/work/provider-azure/provider-azure/.work/pkg/pkg/mod/sigs.k8s.io/controller-runtime@v0.8.0/pkg/internal/controller/controller.go:208 +0x49e

How can we reproduce it?

Create a standard storage account without writeConnectionSecretToRef

apiVersion: storage.azure.crossplane.io/v1alpha3
kind: Account
metadata:
  name: crossplanetestsa
spec:
  providerConfigRef:
    name: example
  resourceGroupName: example-group
  storageAccountSpec:
    kind: Storage
    location: westeurope
    sku:
      name: Standard_LRS

What environment did it happen in?

Crossplane version: 1.7.0 Provider version: 226a6e71bb1bd1b5bd670a44f1ccc4c958ff1dbd

angelhvargas commented 2 years ago

Facing same issue with PublicIpAdress

kareem613 commented 2 years ago

Same issue. Tried to use publishConnectionDetailsTo instead of writeConnectionSecretToRef. I thought it was an issue with publishConnectionDetailsTo, but may very well be the lack of writeConnectionSecretToRef.