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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ go.work.sum

# python virtual environment
.venv

# python test artifacts
.coverage
__pycache__/
*.pyc
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ PROCS?=$(shell expr $(shell nproc --ignore 2) / 2)
PROC_CMD = --procs ${PROCS}

.PHONY: test
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
test: manifests generate gowork fmt vet envtest ginkgo test-instanceha ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" \
OPERATOR_TEMPLATES="$(PWD)/templates" \
$(GINKGO) --trace --cover --coverpkg=./pkg/...,./internal/...,./apis/network/v1beta1/...,./apis/rabbitmq/v1beta1/... --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./test/... ./apis/network/... ./apis/rabbitmq/...

.PHONY: test-instanceha
test-instanceha: ## Run instanceha tests.
/bin/bash test/instanceha/run_tests.sh

##@ Build

.PHONY: build
Expand Down
19 changes: 14 additions & 5 deletions internal/controller/instanceha/instanceha_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
// all cert input checks out so report InputReady
instance.Status.Conditions.MarkTrue(condition.TLSInputReadyCondition, condition.InputReadyMessage)

configVarsHash, err := util.HashOfInputHashes(configVars)
if err != nil {
return ctrl.Result{}, err
}

// begin custom script inject
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel("instanceha"), map[string]string{})
envVars := make(map[string]env.Setter)
Expand All @@ -386,8 +381,22 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct
return ctrl.Result{}, err
}

// Add the script ConfigMap hash to configVars to trigger pod recreation on script changes
scriptConfigMapName := instance.Name + "-sh"
_, scriptConfigMapHash, err := configmap.GetConfigMapAndHashWithName(ctx, helper, scriptConfigMapName, instance.Namespace)
if err != nil {
return ctrl.Result{}, err
}
configVars[scriptConfigMapName] = env.SetValue(scriptConfigMapHash)

// end custom script inject

// Calculate the config hash AFTER adding the script ConfigMap hash
configVarsHash, err := util.HashOfInputHashes(configVars)
if err != nil {
return ctrl.Result{}, err
}

// Create netattachment
nadList := []networkv1.NetworkAttachmentDefinition{}
for _, netAtt := range instance.Spec.NetworkAttachments {
Expand Down
Loading