redhat-cop/group-sync-operator

Crash when sync from Azure encounters user with empty userNameAttribute

lbac-redhat opened this issue · 0 comments

Operator Version: v0.0.24

Attempting a sync with a GroupSync manifest that specifies the .spec.providers.azure.userNameAttributes field crashes if a user does not have that attribute (eg. mail) set.

Sample GroupSync Manifest:

apiVersion: redhatcop.redhat.io/v1alpha1
kind: GroupSync
metadata:
  name: azure-groupsync
spec:
  providers:
    - name: azure
      azure:
        credentialsSecret:
          name: azure-group-sync
          namespace: group-sync-operator
        userNameAttributes:
          - mail

Error message:

1.6786922097023299e+09 INFO    controllers.GroupSync        Beginning Sync {"groupsync": "group-sync-operator/azure-groupsync", "Provider": "azure"}

1.6786922424506514e+09 INFO    Observed a panic in reconciler: reflect: call of reflect.Value.Interface on zero Value     {"controller": "groupsync", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "GroupSync", "groupSync": {"name":"azure-groupsync","namespace":"group-sync-operator"}, "namespace": "group-sync-operator", "name": "azure-groupsync", "reconcileID": "48072399-cb22-4a64-aa49-dc7a593006fa"}

panic: reflect: call of reflect.Value.Interface on zero Value [recovered]

        panic: reflect: call of reflect.Value.Interface on zero Value

 

goroutine 352 [running]:

sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:118 +0x1f4

panic({0x37e2000, 0xc002d9f7b8})

/opt/hostedtoolcache/go/1.18.9/x64/src/runtime/panic.go:838 +0x207

reflect.valueInterface({0x0?, 0x0?, 0xc000b793a0?}, 0x0?)

/opt/hostedtoolcache/go/1.18.9/x64/src/reflect/value.go:1435 +0x10e

reflect.Value.Interface(...)

/opt/hostedtoolcache/go/1.18.9/x64/src/reflect/value.go:1430

github.com/redhat-cop/group-sync-operator/pkg/syncer.(*AzureSyncer).isUsernamePresent(0x0?, {0x4a54160?, 0xc00053f800?, 0x4510f4?}, {0xc00033f2c8, 0x4})

        /home/runner/work/group-sync-operator/group-sync-operator/pkg/syncer/azure.go:434 +0x10f

github.com/redhat-cop/group-sync-operator/pkg/syncer.(*AzureSyncer).getUsernameForUser(_, {{{0xc0026cc480, 0x0, 0xc0017e25c0}, 0x0}, 0x0, 0x0, {0x0, 0x0, 0x0}, ...})

        /home/runner/work/group-sync-operator/group-sync-operator/pkg/syncer/azure.go:418 +0x1ab

github.com/redhat-cop/group-sync-operator/pkg/syncer.(*AzureSyncer).listGroupMembers.func1({0x4a54160?, 0xc00040e800?})

        /home/runner/work/group-sync-operator/group-sync-operator/pkg/syncer/azure.go:392 +0xaa

github.com/microsoftgraph/msgraph-sdk-go-core.(*PageIterator).enumerate(0xc00053a6c0, 0xc000b7a488)

/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v0.30.1/page_iterator.go:177 +0xa6

github.com/microsoftgraph/msgraph-sdk-go-core.(*PageIterator).Iterate(0xc00053a6c0, {0x500d478, 0xc0000e01d0}, 0xc0000bc2d0?)

/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v0.30.1/page_iterator.go:85 +0x46

github.com/redhat-cop/group-sync-operator/pkg/syncer.(*AzureSyncer).listGroupMembers(0xc00050c000, 0xc000dbd750)

        /home/runner/work/group-sync-operator/group-sync-operator/pkg/syncer/azure.go:389 +0x5af

github.com/redhat-cop/group-sync-operator/pkg/syncer.(*AzureSyncer).Sync(0xc00050c000)

        /home/runner/work/group-sync-operator/group-sync-operator/pkg/syncer/azure.go:336 +0xb0c

github.com/redhat-cop/group-sync-operator/controllers.(*GroupSyncReconciler).Reconcile(0xc0001fe180, {0x500d4e8, 0xc0006b0db0}, {{{0xc0006c8b58, 0x13}, {0xc00033f2b0, 0xf}}})

        /home/runner/work/group-sync-operator/group-sync-operator/controllers/groupsync_controller.go:112 +0xc04

sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x500d440?, {0x500d4e8?, 0xc0006b0db0?}, {{{0xc0006c8b58?, 0x48ab880?}, {0xc00033f2b0?, 0x404bd4?}}})

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:121 +0xc8

sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc0001092c0, {0x500d440, 0xc0005a3200}, {0x3daa760?, 0xc0006c2bc0?})

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:320 +0x33c

sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc0001092c0, {0x500d440, 0xc0005a3200})

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:273 +0x1d9

sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:234 +0x85

created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2

        /home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/internal/controller/controller.go:230 +0x325