Open rafaeltuelho opened 1 year ago
it looks like the path you are passing is wrong (the data
segment seems to be at the wrong place) and at the same time, the operator does not handle that situation gracefully.
Thanks for reporting this.
So, I enabled my KV using v2, so that's why it adds /data
to the mount point kv
. Does the Operator expect kv v1 (without versioning)?
I ran into another situation where the Operator crashes with panic error. This happens when it tries to read a secret that does not exist in the vault yet.
2023-11-30T21:19:41Z DEBUG reconcile {"controller": "secretenginemount", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "SecretEngineMount", "SecretEngineMount": {"name":"github","namespace":"vault-admin"}, "namespace": "vault-admin", "name": "github", "reconcileID": "42c56db7-0989-4a87-ac90-60da4b9ec9a8", "instance": {"apiVersion": "redhatcop.redhat.io/v1alpha1", "kind": "SecretEngineMount", "namespace": "vault-admin", "name": "github"}}
2023-11-30T21:19:41Z ERROR unable to retrieve vault secret {"controller": "quaysecretengineconfig", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "QuaySecretEngineConfig", "QuaySecretEngineConfig": {"name":"quay","namespace":"vault-admin"}, "namespace": "vault-admin", "name": "quay", "reconcileID": "1bfca365-fab9-4923-aa8e-7faca0920e8f", "instance": {"apiVersion": "redhatcop.redhat.io/v1alpha1", "kind": "QuaySecretEngineConfig", "namespace": "vault-admin", "name": "quay"}, "error": "secret not found"}
github.com/redhat-cop/vault-config-operator/api/v1alpha1.(*QuaySecretEngineConfig).setInternalCredentials
/home/runner/work/vault-config-operator/vault-config-operator/api/v1alpha1/quaysecretengineconfig_types.go:138
github.com/redhat-cop/vault-config-operator/api/v1alpha1.(*QuaySecretEngineConfig).PrepareInternalValues
/home/runner/work/vault-config-operator/vault-config-operator/api/v1alpha1/quaysecretengineconfig_types.go:81
github.com/redhat-cop/vault-config-operator/controllers/vaultresourcecontroller.(*VaultResource).manageReconcileLogic
/home/runner/work/vault-config-operator/vault-config-operator/controllers/vaultresourcecontroller/vaultresourcereconciler.go:93
github.com/redhat-cop/vault-config-operator/controllers/vaultresourcecontroller.(*VaultResource).Reconcile
/home/runner/work/vault-config-operator/vault-config-operator/controllers/vaultresourcecontroller/vaultresourcereconciler.go:65
github.com/redhat-cop/vault-config-operator/controllers.(*QuaySecretEngineConfigReconciler).Reconcile
/home/runner/work/vault-config-operator/vault-config-operator/controllers/quaysecretengineconfig_controller.go:76
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:118
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:314
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:265
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:226
2023-11-30T21:19:41Z ERROR unable to prepare internal values {"controller": "quaysecretengineconfig", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "QuaySecretEngineConfig", "QuaySecretEngineConfig": {"name":"quay","namespace":"vault-admin"}, "namespace": "vault-admin", "name": "quay", "reconcileID": "1bfca365-fab9-4923-aa8e-7faca0920e8f", "instance": {"apiVersion": "redhatcop.redhat.io/v1alpha1", "kind": "QuaySecretEngineConfig", "namespace": "vault-admin", "name": "quay"}, "error": "secret not found"}
github.com/redhat-cop/vault-config-operator/controllers/vaultresourcecontroller.(*VaultResource).manageReconcileLogic
/home/runner/work/vault-config-operator/vault-config-operator/controllers/vaultresourcecontroller/vaultresourcereconciler.go:95
github.com/redhat-cop/vault-config-operator/controllers/vaultresourcecontroller.(*VaultResource).Reconcile
/home/runner/work/vault-config-operator/vault-config-operator/controllers/vaultresourcecontroller/vaultresourcereconciler.go:65
github.com/redhat-cop/vault-config-operator/controllers.(*QuaySecretEngineConfigReconciler).Reconcile
/home/runner/work/vault-config-operator/vault-config-operator/controllers/quaysecretengineconfig_controller.go:76
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:118
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:314
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:265
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:226
I believe in such cases, the Controller should handle the error, log it, and move on.
the first one is a bug, we should in fact check for the key key
to exist and not panic.
The second does not seem to be an error. the operator does what you said: reports an error and move on.
In both cases the errors occur because the secrets are not populated (yet).
Yeah, in the second scenario I ran into the Operator POD crashed and stayed unrecovered. Yes, the secret was not populated yet in Vault. So, I think the operator should not crash and just ignore and keep trying to check the secret in vault.
Here is my CRD:
I see this error on vault-admin operator pod:
And here is the secret path on vault:
It seems the errors happens at this line: https://github.com/redhat-cop/vault-config-operator/blob/a0f03904af92e0a7be7a8dcee6e715189df3bea2/api/v1alpha1/githubsecretengineconfig_types.go#L156