spinkube / spin-operator

Spin Operator is a Kubernetes operator that empowers platform engineers to deploy Spin applications as custom resources to their Kubernetes clusters
https://www.spinkube.dev/docs/overview/
Other
221 stars 24 forks source link

Unable to reconcile deployment: Duplicate value: http-app in an attempt to edit the deployment #327

Open Mossaka opened 1 month ago

Mossaka commented 1 month ago

Steps to repro:

  1. Follow the Running a local development environment section on README to prepare a k3d cluster.
  2. After apply the sample application, run kubectl edit deploy to change the port number from 80 to something else (i.e. 83).
  3. See the error from the terminal that's running spin-operator.
2024-10-14T06:58:10Z    ERROR   Unable to reconcile Deployment  {"controller": "spinapp", "controllerGroup": "core.spinoperator.dev", "controllerKind": "SpinApp", "SpinApp": {"name":"simple-spinapp","namespace":"default"}, "namespace": "default", "name": "simple-spinapp", "reconcileID": "72640040-ef1e-437c-accb-2815effe4d84", "deployment": "simple-spinapp", "error": "Deployment.apps \"simple-spinapp\" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: \"http-app\""}
github.com/spinkube/spin-operator/internal/logging.logrLogger.Error
        /home/mossaka/developer/spinkube/spin-operator-msk/internal/logging/logr_logger.go:72
github.com/spinkube/spin-operator/internal/controller.(*SpinAppReconciler).reconcileDeployment
        /home/mossaka/developer/spinkube/spin-operator-msk/internal/controller/spinapp_controller.go:337
github.com/spinkube/spin-operator/internal/controller.(*SpinAppReconciler).Reconcile
        /home/mossaka/developer/spinkube/spin-operator-msk/internal/controller/spinapp_controller.go:133
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
        /home/mossaka/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.18.4/pkg/internal/controller/controller.go:114
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /home/mossaka/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.18.4/pkg/internal/controller/controller.go:311
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /home/mossaka/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.18.4/pkg/internal/controller/controller.go:261
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /home/mossaka/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.18.4/pkg/internal/controller/controller.go:222
endocrimes commented 1 month ago

This is expected to some degree (changing fields managed by the operator isn't particularly supported), but i think we're running into a quirk of how patching works for lists: It tries to re-add the port 80 binding rather than overwriting the port 83 binding.

I'm not sure how we'd want to go about overwriting the external change there - without building out specific get/update logic instead of the simpler patching 🤔