Skip to content

Commit

Permalink
fix(controller): Adds PNS_PRIVILEGED, fixed termination bug (argoproj…
Browse files Browse the repository at this point in the history
…#4983)

Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Feb 1, 2021
1 parent d324b43 commit b68d63e
Show file tree
Hide file tree
Showing 40 changed files with 566 additions and 556 deletions.
34 changes: 7 additions & 27 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,20 @@ jobs:
strategy:
fail-fast: false
matrix:
# this list can be used to run certain interesting suites of tests
test:
- smoke
- test-cli
- test-e2e
# `docker` is omitted from this list because we want to run the most thorough set of tests on it,
# but always offloading, all persistence related tests, and cron tests
- test-executor
containerRuntimeExecutor:
- docker
- k8sapi
- kubelet
- pns
profile: [ minimal ]
alwaysOffloadNodeStatus: [ "false" ]
include:
# run all test with docker - this is the most complete set of tests
- test: smoke
profile: mysql
containerRuntimeExecutor: docker
alwaysOffloadNodeStatus: "true"
- test: test-cli
profile: mysql
containerRuntimeExecutor: docker
alwaysOffloadNodeStatus: "true"
- test: test-e2e
profile: mysql
- test: test-functional
containerRuntimeExecutor: docker
alwaysOffloadNodeStatus: "true"
# test cron workflows
- test: test-e2e-cron
profile: minimal
containerRuntimeExecutor: docker
alwaysOffloadNodeStatus: "false"
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -114,23 +96,21 @@ jobs:
echo '127.0.0.1 mysql' | sudo tee -a /etc/hosts
mkdir -p /tmp/log/argo-e2e
git fetch --tags
KUBECONFIG=~/.kube/config make install PROFILE=${{matrix.profile}} E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} ALWAYS_OFFLOAD_NODE_STATUS=${{matrix.alwaysOffloadNodeStatus}} DEV_IMAGE=true STATIC_FILES=false
KUBECONFIG=~/.kube/config make start PROFILE=${{matrix.profile}} E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} ALWAYS_OFFLOAD_NODE_STATUS=${{matrix.alwaysOffloadNodeStatus}} DEV_IMAGE=true STATIC_FILES=false 2>&1 > /tmp/log/argo-e2e/argo.log &
- name: Install gotestsum
run: go install gotest.tools/gotestsum
KUBECONFIG=~/.kube/config make install PROFILE=mysql E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} ALWAYS_OFFLOAD_NODE_STATUS=true DEV_IMAGE=true STATIC_FILES=false
KUBECONFIG=~/.kube/config make start PROFILE=mysql E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} ALWAYS_OFFLOAD_NODE_STATUS=true DEV_IMAGE=true STATIC_FILES=false 2>&1 > /tmp/log/argo-e2e/argo.log &
- name: Wait for Argo Server to be ready
env:
GOPATH: /home/runner/go
run: make wait
- name: Run tests
env:
GOPATH: /home/runner/go
run: make ${{ matrix.test }} GOTEST='gotestsum --format testname --'
run: make ${{ matrix.test }}
- name: Upload logs
if: ${{ failure() }}
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.test }}-${{matrix.containerRuntimeExecutor}}-${{matrix.alwaysOffloadNodeStatus}}-${{ github.run_id }}-argo.log
name: ${{ matrix.test }}-${{matrix.containerRuntimeExecutor}}-${{ github.run_id }}-argo.log
path: /tmp/log/argo-e2e/argo.log

codegen:
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ run:
- api
- cli
- cron
- e2e
- smoke
- executor
- functional
linters:
enable:
- goimports
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ STATIC_BUILD ?= true
# should we build the static files?
STATIC_FILES ?= $(shell [ $(DEV_BRANCH) = true ] && echo false || echo true)
START_UI ?= $(shell [ "$(CI)" != "" ] && echo true || echo false)
GOTEST ?= go test
GOTEST ?= go test -v
PROFILE ?= minimal
# by keeping this short we speed up the tests
DEFAULT_REQUEUE_TIME ?= 2s
Expand Down Expand Up @@ -477,7 +477,7 @@ endif
sleep 10s
./hack/port-forward.sh
ifeq ($(RUN_MODE),local)
env DEFAULT_REQUEUE_TIME=$(DEFAULT_REQUEUE_TIME) SECURE=$(SECURE) ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) LOG_LEVEL=$(LOG_LEVEL) UPPERIO_DB_DEBUG=$(UPPERIO_DB_DEBUG) VERSION=$(VERSION) AUTH_MODE=$(AUTH_MODE) NAMESPACED=$(NAMESPACED) NAMESPACE=$(KUBE_NAMESPACE) $(GOPATH)/bin/goreman -set-ports=false -logtime=false start controller argo-server $(shell [ $(START_UI) = false ]&& echo ui || echo)
env DEFAULT_REQUEUE_TIME=$(DEFAULT_REQUEUE_TIME) SECURE=$(SECURE) ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) LOG_LEVEL=$(LOG_LEVEL) UPPERIO_DB_DEBUG=$(UPPERIO_DB_DEBUG) IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) VERSION=$(VERSION) AUTH_MODE=$(AUTH_MODE) NAMESPACED=$(NAMESPACED) NAMESPACE=$(KUBE_NAMESPACE) $(GOPATH)/bin/goreman -set-ports=false -logtime=false start controller argo-server $(shell [ $(START_UI) = false ]&& echo ui || echo)
endif

.PHONY: wait
Expand All @@ -495,23 +495,23 @@ postgres-cli:
mysql-cli:
kubectl exec -ti `kubectl get pod -l app=mysql -o name|cut -c 5-` -- mysql -u mysql -ppassword argo

.PHONY: test-e2e
test-e2e:
$(GOTEST) -timeout 15m -count 1 --tags e2e,api -p 1 ./test/e2e

.PHONY: test-cli
test-cli:
E2E_MODE=GRPC $(GOTEST) -timeout 15m -count 1 --tags cli -p 1 ./test/e2e
E2E_MODE=HTTP1 $(GOTEST) -timeout 15m -count 1 --tags cli -p 1 ./test/e2e
E2E_MODE=KUBE $(GOTEST) -timeout 15m -count 1 --tags cli -p 1 ./test/e2e
E2E_MODE=GRPC $(GOTEST) -timeout 5m -count 1 --tags cli -p 1 ./test/e2e
E2E_MODE=HTTP1 $(GOTEST) -timeout 5m -count 1 --tags cli -p 1 ./test/e2e
E2E_MODE=KUBE $(GOTEST) -timeout 5m -count 1 --tags cli -p 1 ./test/e2e

.PHONY: test-e2e-cron
test-e2e-cron:
$(GOTEST) -count 1 --tags cron -parallel 10 ./test/e2e

.PHONY: smoke
smoke:
$(GOTEST) -count 1 --tags smoke -p 1 ./test/e2e
.PHONY: test-executor
test-executor:
$(GOTEST) -timeout 5m -count 1 --tags executor -p 1 ./test/e2e

.PHONY: test-functional
test-functional:
$(GOTEST) -timeout 15m -count 1 --tags api,functional -p 1 ./test/e2e

# clean

Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
controller: DEFAULT_REQUEUE_TIME=${DEFAULT_REQUEUE_TIME} LEADER_ELECTION_IDENTITY=local ALWAYS_OFFLOAD_NODE_STATUS=${ALWAYS_OFFLOAD_NODE_STATUS} OFFLOAD_NODE_STATUS_TTL=30s WORKFLOW_GC_PERIOD=30s UPPERIO_DB_DEBUG=${UPPERIO_DB_DEBUG} ARCHIVED_WORKFLOW_GC_PERIOD=30s ./dist/workflow-controller --executor-image argoproj/argoexec:${VERSION} --namespaced=${NAMESPACED} --namespace ${NAMESPACE} --loglevel ${LOG_LEVEL}
controller: PNS_PRIVILEGED=true DEFAULT_REQUEUE_TIME=${DEFAULT_REQUEUE_TIME} LEADER_ELECTION_IDENTITY=local ALWAYS_OFFLOAD_NODE_STATUS=${ALWAYS_OFFLOAD_NODE_STATUS} OFFLOAD_NODE_STATUS_TTL=30s WORKFLOW_GC_PERIOD=30s UPPERIO_DB_DEBUG=${UPPERIO_DB_DEBUG} ARCHIVED_WORKFLOW_GC_PERIOD=30s ./dist/workflow-controller --executor-image ${IMAGE_NAMESPACE}/argoexec:${VERSION} --namespaced=${NAMESPACED} --namespace ${NAMESPACE} --loglevel ${LOG_LEVEL}
argo-server: UPPERIO_DB_DEBUG=${UPPERIO_DB_DEBUG} ./dist/argo --loglevel ${LOG_LEVEL} server --namespaced=${NAMESPACED} --namespace ${NAMESPACE} --auth-mode ${AUTH_MODE} --secure=$SECURE --x-frame-options=SAMEORIGIN
ui: yarn --cwd ui install && yarn --cwd ui start
155 changes: 155 additions & 0 deletions test/e2e/artifacts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// +build executor

package e2e

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

wfv1 "github.com/argoproj/argo/v2/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/v2/test/e2e/fixtures"
)

type ArtifactsSuite struct {
fixtures.E2ESuite
}

func (s *ArtifactsSuite) TestInputOnMount() {
s.Given().
Workflow("@testdata/input-on-mount-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func (s *ArtifactsSuite) TestOutputOnMount() {
s.Given().
Workflow("@testdata/output-on-mount-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func (s *ArtifactsSuite) TestOutputOnInput() {
s.Need(fixtures.BaseLayerArtifacts) // I believe this would work on both K8S and Kubelet, not validation does not allow it
s.Given().
Workflow("@testdata/output-on-input-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func (s *ArtifactsSuite) TestArtifactPassing() {
s.Need(fixtures.BaseLayerArtifacts)
s.Given().
Workflow("@smoke/artifact-passing.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func (s *ArtifactsSuite) TestDefaultParameterOutputs() {
s.Need(fixtures.BaseLayerArtifacts)
s.Need(fixtures.None(fixtures.PNS))
s.Given().
Workflow(`
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: default-params
labels:
argo-e2e: true
spec:
entrypoint: start
templates:
- name: start
steps:
- - name: generate-1
template: generate
- - name: generate-2
when: "True == False"
template: generate
outputs:
parameters:
- name: nested-out-parameter
valueFrom:
default: "Default value"
parameter: "{{steps.generate-2.outputs.parameters.out-parameter}}"
- name: generate
container:
image: argoproj/argosay:v2
args: [echo, my-output-parameter, /tmp/my-output-parameter.txt]
outputs:
parameters:
- name: out-parameter
valueFrom:
path: /tmp/my-output-parameter.txt
`).
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
assert.True(t, status.Nodes.Any(func(node wfv1.NodeStatus) bool {
if node.Outputs != nil {
for _, param := range node.Outputs.Parameters {
if param.Value != nil && param.Value.String() == "Default value" {
return true
}
}
}
return false
}))
})
}

func (s *ArtifactsSuite) TestSameInputOutputPathOptionalArtifact() {
s.Need(fixtures.BaseLayerArtifacts)
s.Given().
Workflow("@testdata/same-input-output-path-optional.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func (s *ArtifactsSuite) TestOutputArtifactS3BucketCreationEnabled() {
s.Need(fixtures.BaseLayerArtifacts)
s.Given().
Workflow("@testdata/output-artifact-with-s3-bucket-creation-enabled.yaml").
When().
SubmitWorkflow().
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
})
}

func TestArtifactsSuite(t *testing.T) {
suite.Run(t, new(ArtifactsSuite))
}
7 changes: 4 additions & 3 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,18 +1213,19 @@ func (s *CLISuite) TestRetryOmit() {
return node.Phase == wfv1.NodeOmitted
})
}), "any node omitted").
WaitForWorkflow(10*time.Second).
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
node := status.Nodes.FindByDisplayName("should-not-execute")
if assert.NotNil(t, node) {
assert.Equal(t, wfv1.NodeOmitted, node.Phase)
}
}).
RunCli([]string{"retry", "dag-diamond-8q7vp"}, func(t *testing.T, output string, err error) {
RunCli([]string{"retry", "@latest"}, func(t *testing.T, output string, err error) {
assert.NoError(t, err)
assert.Contains(t, output, "Status: Running")
}).When().
}).
When().
WaitForWorkflow()
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cluster_workflow_template_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build e2e
// +build functional

package e2e

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/estimated_duration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build e2e
// +build functional

package e2e

Expand Down
5 changes: 1 addition & 4 deletions test/e2e/fixtures/needs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ var (
return os.Getenv("CI") != "", "CI"
}
BaseLayerArtifacts Need = func(s *E2ESuite) (bool, string) {
// for base layer you need
// * docker
// * pns, but not on the CI system for some reason
met, _ := Any(Docker, All(None(CI), PNS))(s)
met, _ := None(K8SAPI, Kubelet)(s)
return met, "base layer artifact support"
}
Offloading Need = func(s *E2ESuite) (bool, string) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/functional/continue-on-failed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:

- name: whalesay
container:
image: argoproj/argosay:v1
image: argoproj/argosay:v2

- name: whalesplosion
container:
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/functional/custom_template_variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ spec:
parameters:
- name: message
container:
image: argoproj/argosay:v1
command: [cowsay]
args: ["{{custom.variable}}"]
image: argoproj/argosay:v2
args: [echo, "{{custom.variable}}"]
Loading

0 comments on commit b68d63e

Please sign in to comment.