From 4e92eac00b75218b5a424859798927dcf2758997 Mon Sep 17 00:00:00 2001 From: Ivan Sim Date: Thu, 29 Apr 2021 20:13:46 -0700 Subject: [PATCH] Fixed exec shell command used in 'restore' The wildcard expansion needs to happen in the pod's shell. Signed-off-by: Ivan Sim --- Makefile | 10 ++++++---- cli/cmd/restore.go | 5 +---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 897a4fb..79ce524 100644 --- a/Makefile +++ b/Makefile @@ -82,18 +82,20 @@ plugin: rm "$(TARGET_PLUGINS_DIR)/kubectl-promdump$${extension}" && \ shasum -a256 $(TARGET_PLUGINS_DIR)/kubectl-promdump-$(BUILD_OS)-$(BUILD_ARCH)-$(VERSION).tar.gz | awk '{print $$1}' > $(TARGET_PLUGINS_DIR)/kubectl-promdump-$(BUILD_OS)-$(BUILD_ARCH)-$(VERSION).tar.gz.sha256 -.PHONY: test -test/prometheus-repos: +.PHONY: hack/prometheus-repos +hack/prometheus-repos: helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics helm repo update -test/prometheus: +.PHONY: hack/prometheus +hack/prometheus: helm install prometheus prometheus-community/prometheus HACK_NAMESPACE ?= default HACK_DATA_DIR ?= /data -.PHONY: hack + +.PHONY: hack/deploy hack/deploy: pod="$$(kubectl get pods --namespace $(HACK_NAMESPACE) -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")" ;\ kubectl -n "$(HACK_NAMESPACE)" cp -c prometheus-server "$(TARGET_BIN_DIR)/promdump" "$${pod}:$(HACK_DATA_DIR)" ;\ diff --git a/cli/cmd/restore.go b/cli/cmd/restore.go index f40b9d5..637dbbc 100644 --- a/cli/cmd/restore.go +++ b/cli/cmd/restore.go @@ -55,10 +55,7 @@ func runRestore(config *config.Config, clientset *k8s.Clientset) error { } dataDir := config.GetString("data-dir") - execCmd := []string{"rm", "-rf", - fmt.Sprintf("%s/wal", dataDir), - fmt.Sprintf("%s/chunks_head", dataDir), - } + execCmd := []string{"sh", "-c", fmt.Sprintf("rm -rf %s/*", dataDir)} if err := clientset.ExecPod(execCmd, os.Stdin, os.Stdout, os.Stderr, false); err != nil { return err }