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

Samba-operator crashes when setting affinity in clustered samba server #330

Closed
FTS152 opened this issue Feb 29, 2024 · 1 comment · Fixed by #331
Closed

Samba-operator crashes when setting affinity in clustered samba server #330

FTS152 opened this issue Feb 29, 2024 · 1 comment · Fixed by #331

Comments

@FTS152
Copy link

FTS152 commented Feb 29, 2024

Reproduce:

  1. Open ctdb experimental feature
  2. Set affinity options in smbcommonconfig
podSettings:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
    ...
  1. Deploy smbshare and samba-operator crashes with the following logs:
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=0x8 pc=0x1593f0a]

goroutine 314 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:119 +0x1fa
panic({0x16f5040, 0x26e0e20})
 /usr/local/go/src/runtime/panic.go:884 +0x213
github.com/samba-in-kubernetes/samba-operator/internal/resources.buildOneSmbdPerNodeAffinity(0xc0000caf00, 0xc000409bc0?, {0x18fc6c8, 0x20})
 /workspace/internal/resources/statefulsets.go:89 +0x22a
github.com/samba-in-kubernetes/samba-operator/internal/resources.buildStatefulSet(0xc0000caf00, {0xc0001470e0, 0x11}, {0xc0009f20e0, 0x1d}, {0xc000147098, 0x15})
 /workspace/internal/resources/statefulsets.go:34 +0x30d
github.com/samba-in-kubernetes/samba-operator/internal/resources.(*SmbShareManager).getOrCreateStatefulSet(0xc00081fc90, {0x1b47760, 0xc000409ad0}, 0xc0000caf00, {0xc000147098, 0x15})
 /workspace/internal/resources/getters.go:406 +0xc6
github.com/samba-in-kubernetes/samba-operator/internal/resources.(*SmbShareManager).updateClusteredState(0xc00081fc90, {0x1b47760, 0xc000409ad0}, 0xc0000caf00)
 /workspace/internal/resources/smbshare.go:351 +0xee
github.com/samba-in-kubernetes/samba-operator/internal/resources.(*SmbShareManager).Update(0xc00081fc90, {0x1b47760, 0xc000409ad0}, 0xc0006a18c0)
 /workspace/internal/resources/smbshare.go:170 +0x366
github.com/samba-in-kubernetes/samba-operator/internal/resources.(*SmbShareManager).Process(0xc0003f7c90, {0x1b47760, 0xc000409ad0}, {{0xc000147098?, 0x14?}, {0xc000147080?, 0x0?}})
 /workspace/internal/resources/smbshare.go:102 +0x125
github.com/samba-in-kubernetes/samba-operator/controllers.(*SmbShareReconciler).Reconcile(0xc000406f00, {0x1b47760, 0xc000409ad0}, {{{0xc000147098, 0x15}, {0xc000147080, 0x17}}})
 /workspace/controllers/smbshare_controller.go:71 +0x253
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x1b47760?, {0x1b47760?, 0xc000409ad0?}, {{{0xc000147098?, 0x16776a0?}, {0xc000147080?, 0x0?}}})
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:122 +0xc8
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc00039f360, {0x1b476b8, 0xc0004db130}, {0x174c960?, 0xc0004ba480?})
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:323 +0x35f
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc00039f360, {0x1b476b8, 0xc0004db130})
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:274 +0x1d9
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:235 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
 /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.4/pkg/internal/controller/controller.go:231 +0x587

Causes:

According to the logs, samba-operator reports error at func buildOneSmbdPerNodeAffinity(). When affinity is set, affinity.PodAntiAffinity may still be null if this attribute is not set in smbcommonconfig. Currently a workaround is adding affinity.PodAntiAffinity with empty list in the yaml file.

podSettings:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution: []
synarete added a commit to synarete/samba-operator that referenced this issue Feb 29, 2024
Protect from case where user provided 'affinity' entry in podSettings of
smbcommonconfig but without 'podAntiAffinity' sub-entry. This in turn
would cause samba-operator a nil pointer dereference.

Fixes: samba-in-kubernetes#330

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
@synarete
Copy link
Collaborator

Try with this fix: #331

@mergify mergify bot closed this as completed in #331 Mar 4, 2024
mergify bot pushed a commit that referenced this issue Mar 4, 2024
Protect from case where user provided 'affinity' entry in podSettings of
smbcommonconfig but without 'podAntiAffinity' sub-entry. This in turn
would cause samba-operator a nil pointer dereference.

Fixes: #330

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants