diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index de6a6ade..ae776f23 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -82,10 +82,11 @@ jobs: image=moby/buildkit:v0.12.5 network=host - - name: Remove arm from goreleaser + - name: Configure goreleaser for amd64 linux only uses: mikefarah/yq@master with: - cmd: yq -i 'del(.dockers_v2.[].platforms[1])' .goreleaser.yaml + cmd: | + yq -i '.builds[].goos = ["linux"] | .builds[].goarch = ["amd64"] | .dockers_v2[].platforms = ["linux/amd64"]' .goreleaser.yaml - name: Create Snapshot id: goreleaser @@ -152,6 +153,12 @@ jobs: kubectl get --namespace test cronjob/test-cron -o json && exit 2 } + # Test StoreDebugInstances + kubectl apply -f examples/storedebuginstance.yaml --namespace test + kubectl wait --namespace test --for=jsonpath="{.status.state}"=wait --timeout=2m storedebuginstance/debug || { + kubectl get --namespace test storedebuginstance/debug -o json && exit 1 + } + # Test StoreSnapshotCreate resource echo "Testing StoreSnapshotCreate resource..." kubectl apply -f examples/snapshot_create.yaml --namespace test diff --git a/api/v1/storedebuginstance_types.go b/api/v1/storedebuginstance_types.go index 42e88d9c..f661efe9 100644 --- a/api/v1/storedebuginstance_types.go +++ b/api/v1/storedebuginstance_types.go @@ -37,6 +37,12 @@ type StoreDebugInstanceSpec struct { // ExtraContainerPorts is the extra ports to add to the debug instance // if it should be exposed to the outside world ExtraContainerPorts []corev1.ContainerPort `json:"extraContainerPorts,omitempty"` + // CustomImage allows overriding the container image from the store + // +optional + CustomImage string `json:"customImage,omitempty"` + // IgnoreStoreStatus allows the debug instance to start even if the store is not ready + // +optional + IgnoreStoreStatus bool `json:"ignoreStoreStatus,omitempty"` } // +kubebuilder:object:root=true diff --git a/examples/storedebuginstance.yaml b/examples/storedebuginstance.yaml new file mode 100644 index 00000000..31c52186 --- /dev/null +++ b/examples/storedebuginstance.yaml @@ -0,0 +1,10 @@ +apiVersion: shop.shopware.com/v1 +kind: StoreDebugInstance +metadata: + name: debug +spec: + duration: 1h + storeRef: test + ignoreStoreStatus: true + + diff --git a/internal/controller/storedebuginstance_controller.go b/internal/controller/storedebuginstance_controller.go index d17500fe..f22d7e0d 100644 --- a/internal/controller/storedebuginstance_controller.go +++ b/internal/controller/storedebuginstance_controller.go @@ -110,11 +110,17 @@ func (r *StoreDebugInstanceReconciler) Reconcile(ctx context.Context, req ctrl.R return rr, nil } - if !store.IsState(shopv1.StateReady) { + // Only check store readiness if not explicitly ignored + if !storeDebugInstance.Spec.IgnoreStoreStatus && !store.IsState(shopv1.StateReady) { log.Info("Skip reconcile, because store is not ready yet.", zap.Any("store", store.Status)) return rr, nil } + if storeDebugInstance.Spec.IgnoreStoreStatus { + log.Info("Ignoring store status check for debug instance", + zap.String("storeState", string(store.Status.State))) + } + log = log.With(zap.String("store", storeDebugInstance.Spec.StoreRef)) log.Info("Do reconcile on store debug instance") diff --git a/internal/pod/debug.go b/internal/pod/debug.go index 0bd55c1c..29444270 100644 --- a/internal/pod/debug.go +++ b/internal/pod/debug.go @@ -35,6 +35,12 @@ func DebugPod(store v1.Store, storeDebugInstance v1.StoreDebugInstance) *corev1. store.Spec.Container.Merge(store.Spec.StorefrontDeploymentContainer) + // Use custom image if provided, otherwise use store's image + containerImage := store.Spec.Container.Image + if storeDebugInstance.Spec.CustomImage != "" { + containerImage = storeDebugInstance.Spec.CustomImage + } + labels := util.GetDefaultStoreInstanceDebugLabels(store, storeDebugInstance) podSpec.Labels = labels @@ -51,7 +57,7 @@ func DebugPod(store v1.Store, storeDebugInstance v1.StoreDebugInstance) *corev1. containers := append(store.Spec.Container.ExtraContainers, corev1.Container{ Name: deployment.DEPLOYMENT_STOREFRONT_CONTAINER_NAME, // we don't need the liveness and readiness probe to make sure that the container always starts - Image: store.Spec.Container.Image, + Image: containerImage, // Use custom image if provided ImagePullPolicy: store.Spec.Container.ImagePullPolicy, Env: store.GetEnv(), VolumeMounts: store.Spec.Container.VolumeMounts,