Skip to content

Commit

Permalink
Fixed exec shell command used in 'restore'
Browse files Browse the repository at this point in the history
The wildcard expansion needs to happen in the pod's shell.

Signed-off-by: Ivan Sim <[email protected]>
  • Loading branch information
Ivan Sim committed Apr 30, 2021
1 parent 4f074d7 commit 4e92eac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)" ;\
5 changes: 1 addition & 4 deletions cli/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4e92eac

Please sign in to comment.