Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Tolerate deleted workflow when running argo delete. Fixes #2821 #2877

Merged
merged 21 commits into from Apr 30, 2020
37 changes: 28 additions & 9 deletions .circleci/config.yml
Expand Up @@ -17,12 +17,12 @@ commands:
- restore_cache:
name: Restore go mod cache
keys:
- go-mod-v2-{{ checksum "go.sum" }}-{{ .Environment.CIRCLE_JOB }}
- go-mod-v3-{{ checksum "go.sum" }}-{{ .Environment.CIRCLE_JOB }}
save_go_mod:
steps:
- save_cache:
name: Save go mod cache
key: go-mod-v2-{{ checksum "go.sum" }}-{{ .Environment.CIRCLE_JOB }}
key: go-mod-v3-{{ checksum "go.sum" }}-{{ .Environment.CIRCLE_JOB }}
paths:
- /home/circleci/.go_workspace/go/pkg/mod
when: always
Expand All @@ -39,7 +39,7 @@ commands:
steps:
- save_cache:
name: Save Golang cache
key: go-v6-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
key: go-v7-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
paths:
- /home/circleci/.cache/go-build
- /home/circleci/sdk/go1.13.4
Expand All @@ -49,20 +49,25 @@ commands:
- restore_cache:
name: Restore Golang cache
keys:
- go-v6-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- go-v6-master-{{ .Environment.CIRCLE_JOB }}
- go-v7-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- go-v7-master-{{ .Environment.CIRCLE_JOB }}
e2e:
steps:
- checkout
- maybe_skip_job
- install_kustomize
- run:
name: Preemptively pull images
command: make pull-build-images test-images
background: true
- run:
name: Install and start K3S v1.0.1
command: curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.0.1 INSTALL_K3S_EXEC=--docker K3S_KUBECONFIG_MODE=644 sh -
background: true
- restore_go_cache
- install_golang
- restore_go_mod
- run: go mod download
- run:
name: Create KUBECONFIG
# Copy kubeconfig file, and add a fake user for "argo --token xxx" testing
Expand Down Expand Up @@ -91,7 +96,7 @@ commands:
name: Run tests
command: |
trap 'make test-results/junit.xml' EXIT
make smoke test-e2e test-e2e-cron
make smoke $SUITE
- store_test_results:
path: test-results
when: always
Expand Down Expand Up @@ -131,8 +136,10 @@ jobs:
sudo find /usr/local/include -type d | xargs sudo chmod a+rx
rm -f $PROTOC_ZIP
ls /usr/local/include/google/protobuf/
- run: go mod download
- run: make codegen
- run: make manifests
- run: make lint
- run: git diff --exit-code
- save_go_cache
- save_go_mod
Expand All @@ -147,6 +154,7 @@ jobs:
- restore_go_cache
- install_golang
- restore_go_mod
- run: go mod download
- run:
name: Run tests
command: |
Expand All @@ -167,16 +175,24 @@ jobs:
path: test-results
destination: .
when: always
- run: make lint
- run: git diff --exit-code
- save_go_cache
- save_go_mod
e2e-cron:
working_directory: /home/circleci/.go_workspace/src/github.com/argoproj/argo
machine:
image: ubuntu-1604:201903-01
environment:
DB: mysql
SUITE: test-e2e-cron
steps:
- e2e
e2e-no-db:
working_directory: /home/circleci/.go_workspace/src/github.com/argoproj/argo
machine:
image: ubuntu-1604:201903-01
environment:
DB: no-db
SUITE: test-e2e
steps:
- e2e
e2e-postgres:
Expand All @@ -185,6 +201,7 @@ jobs:
image: ubuntu-1604:201903-01
environment:
DB: postgres
SUITE: test-e2e
steps:
- e2e
e2e-mysql:
Expand All @@ -193,6 +210,7 @@ jobs:
image: ubuntu-1604:201903-01
environment:
DB: mysql
SUITE: test-e2e
steps:
- e2e
docker-build:
Expand Down Expand Up @@ -233,7 +251,8 @@ workflows:
context: SonarCloud
- ui
- codegen
- e2e-cron
- e2e-mysql
- e2e-no-db
- e2e-postgres
- e2e-mysql
- docker-build
9 changes: 0 additions & 9 deletions Dockerfile
Expand Up @@ -40,15 +40,6 @@ RUN if [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "amd64" ]; then \
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \
rm docker.tgz

# Install dep
ENV DEP_VERSION=0.5.1
RUN if [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "amd64" ]; then \
wget https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -O /usr/local/bin/dep; \
elif [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "arm64" ]; then \
wget https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-arm64 -O /usr/local/bin/dep; \
fi && \
chmod +x /usr/local/bin/dep

####################################################################################################
# argoexec-base
# Used as the base for both the release and development version of argoexec
Expand Down
13 changes: 2 additions & 11 deletions Dockerfile.dev
Expand Up @@ -33,22 +33,13 @@ ENV DOCKER_CHANNEL stable
ENV DOCKER_VERSION 18.09.1

RUN if [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "amd64" ]; then \
wget -O docker.tgz https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz; \
wget -O docker.tgz https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz; \
elif [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "arm64" ]; then \
wget -O docker.tgz https://download.docker.com/linux/static/${DOCKER_CHANNEL}/aarch64/docker-${DOCKER_VERSION}.tgz; \
wget -O docker.tgz https://download.docker.com/linux/static/${DOCKER_CHANNEL}/aarch64/docker-${DOCKER_VERSION}.tgz; \
fi && \
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \
rm docker.tgz

# Install dep
ENV DEP_VERSION=0.5.1
RUN if [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "amd64" ]; then \
wget https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -O /usr/local/bin/dep; \
elif [ "${IMAGE_OS}" = "linux" -a "${IMAGE_ARCH}" = "arm64" ]; then \
wget https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-arm64 -O /usr/local/bin/dep; \
fi && \
chmod +x /usr/local/bin/dep

####################################################################################################
# argoexec-base
# Used as the base for both the release and development version of argoexec
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Expand Up @@ -240,10 +240,10 @@ mocks: $(HOME)/go/bin/mockery
./hack/update-mocks.sh $(MOCK_FILES)

.PHONY: codegen
codegen: status codegen-core swagger mocks docs
codegen: status proto swagger mocks docs

.PHONY: codegen-core
codegen-core:
.PHONY: proto
proto:
$(call backup_go_mod)
# We need the folder for compatibility
go mod vendor
Expand Down Expand Up @@ -332,6 +332,10 @@ else
endif
endif

.PHONY: pull-build-images
pull-build-images:
./hack/pull-build-images.sh

.PHONY: test-images
test-images: dist/cowsay-v1 dist/python-alpine3.6

Expand Down Expand Up @@ -466,7 +470,9 @@ pkg/apis/workflow/v1alpha1/openapi_generated.go:
pkg/apiclient/_.secondary.swagger.json: hack/secondaryswaggergen.go pkg/apis/workflow/v1alpha1/openapi_generated.go
go run ./hack secondaryswaggergen

api/openapi-spec/swagger.json: $(HOME)/go/bin/swagger pkg/apiclient/_.secondary.swagger.json $(SWAGGER_FILES) $(MANIFESTS_VERSION_FILE) hack/swaggify.sh
$(SWAGGER_FILES): pkg/apiclient/_.secondary.swagger.json proto

api/openapi-spec/swagger.json: $(HOME)/go/bin/swagger $(SWAGGER_FILES) $(MANIFESTS_VERSION_FILE) hack/swaggify.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix #2892?

swagger mixin -c 680 $(SWAGGER_FILES) | sed 's/VERSION/$(MANIFESTS_VERSION)/' | ./hack/swaggify.sh > api/openapi-spec/swagger.json

.PHONY: docs
Expand Down
3 changes: 0 additions & 3 deletions api/openapi-spec/swagger.json
Expand Up @@ -7104,9 +7104,6 @@
"io.argoproj.workflow.v1alpha1.WorkflowSubmitRequest": {
"type": "object",
"properties": {
"createOptions": {
"$ref": "#/definitions/io.k8s.api.core.v1.CreateOptions"
},
"namespace": {
"type": "string"
},
Expand Down
10 changes: 6 additions & 4 deletions cmd/argo/commands/delete.go
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/argoproj/pkg/errors"
argotime "github.com/argoproj/pkg/time"
"github.com/spf13/cobra"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/argoproj/argo/cmd/argo/commands/client"
Expand Down Expand Up @@ -69,10 +70,11 @@ func NewDeleteCommand() *cobra.Command {
}
}
for _, md := range workflowsToDelete {
_, err := serviceClient.DeleteWorkflow(ctx, &workflowpkg.WorkflowDeleteRequest{
Name: md.Name,
Namespace: md.Namespace,
})
_, err := serviceClient.DeleteWorkflow(ctx, &workflowpkg.WorkflowDeleteRequest{Name: md.Name, Namespace: md.Namespace})
if err != nil && apierr.IsNotFound(err) {
fmt.Printf("Workflow '%s' not found\n", md.Name)
continue
}
errors.CheckError(err)
fmt.Printf("Workflow '%s' deleted\n", md.Name)
}
Expand Down
4 changes: 4 additions & 0 deletions hack/pull-build-images.sh
@@ -0,0 +1,4 @@
#!/bin/bash
set -eu -o pipefail

grep FROM Dockerfile.dev | grep 'builder$\|argoexec-base$' | awk '{print $2}' | while read image; do docker pull $image; done