Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions api/v1/storedebuginstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions examples/storedebuginstance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: shop.shopware.com/v1
kind: StoreDebugInstance
metadata:
name: debug
spec:
duration: 1h
storeRef: test
ignoreStoreStatus: true


8 changes: 7 additions & 1 deletion internal/controller/storedebuginstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
8 changes: 7 additions & 1 deletion internal/pod/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Loading