-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
294 lines (263 loc) · 9.23 KB
/
taskfile.yaml
File metadata and controls
294 lines (263 loc) · 9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
version: '3'
run: when_changed
env:
CGO_ENABLED: "0"
GOARCH: '{{ default "amd64" .GOARCH }}'
GOOS: '{{ default "linux" .GOOS }}'
SUBMODULES: '{{ default "true" .SUBMODULES }}'
vars:
DPU_OPERATOR_TEMP_DIR: /tmp/dpu-operator-tmp
DPU_OPERATOR_GO_CACHE: /tmp/dpu-operator-cache
BINDIR: bin
BINDIR_ABS:
sh: if [[ "{{.BINDIR}}" = /* ]]; then echo "{{.BINDIR}}"; else echo "$(pwd)/{{.BINDIR}}"; fi
REGISTRY:
sh: hostname | sed 's/$/:5000/'
ENVTEST_K8S_VERSION: 1.31.0
KUSTOMIZE_VERSION: v5.6.0
GINKGO_VERSION:
sh: go list -m -f '{{"{{.Version}}"}}' github.com/onsi/ginkgo/v2 | sed 's/^v//'
CONTROLLER_TOOLS_VERSION: v0.19.0
SETUP_ENVTEST_VERSION: release-0.20
OPERATOR_SDK_VERSION: v1.41.0
OPM_VERSION: v1.23.0
KUBECONFIG_HOST: "/root/kubeconfig.ocpcluster"
KUBECONFIG_DPU: "/root/kubeconfig.microshift"
includes:
images:
taskfile: ./taskfiles/images.yaml
flatten: true
binaries:
taskfile: ./taskfiles/binaries.yaml
flatten: true
clusters:
taskfile: ./taskfiles/clusters.yaml
flatten: true
operator-sdk:
taskfile: ./taskfiles/operator-sdk.yaml
flatten: true
proto:
taskfile: ./taskfiles/proto.yaml
flatten: true
check:
taskfile: ./taskfiles/check.yaml
flatten: true
tasks:
bindir:
silent: true
cmds:
- echo "{{.BINDIR_ABS}}"
push-image-helper:
internal: true
vars:
SOURCE: '{{.SOURCE}}'
IMAGE: '{{.IMAGE}}'
cmds:
- buildah manifest push --all '{{.SOURCE}}-manifest' 'docker://{{.IMAGE}}'
undeploy-helper:
internal: true
deps:
- task: kustomize
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
status:
- NS=$(KUBECONFIG={{.KUBECONFIG}} oc get ns openshift-dpu-operator)
if [[ -n "$NS" ]]; then false else true fi
cmds:
# this will block untill everything is cleaned up and bringing system back into a clean state as if the operator was never installed
- KUBECONFIG={{.KUBECONFIG}} oc delete -f examples/config.yaml || true
- bin/kustomize build config/default | KUBECONFIG={{.KUBECONFIG}} oc delete --ignore-not-found=true -f -
- KUBECONFIG={{.KUBECONFIG}} oc wait --for=delete ns openshift-dpu-operator --timeout=300s
- echo "Namespace 'openshift-dpu-operator' has been removed."
undeploy:
deps:
- task: undeploy-helper
vars:
KUBECONFIG: '{{.KUBECONFIG_DPU}}'
- task: undeploy-helper
vars:
KUBECONFIG: '{{.KUBECONFIG_HOST}}'
undeploy-1c:
deps:
- task: undeploy-helper
vars:
KUBECONFIG: '{{.KUBECONFIG_HOST}}'
deploy-prep:
internal: true
deps:
- task: kustomize
cmds:
- >
go run ./tools/config/config.go
-registry-url {{.REGISTRY}}
-template-file config/dev/local-images-template.yaml
-output-file bin/local-images.yaml
- cp config/dev/kustomization.yaml bin
## Download envtest-setup locally if necessary
envtest:
status:
- test -s {{.BINDIR}}/setup-envtest
- ./{{.BINDIR}}/setup-envtest --help | head -1 | grep -q {{.SETUP_ENVTEST_VERSION}}
cmds:
- GOBIN={{.BINDIR_ABS}} GOFLAGS='' go install sigs.k8s.io/controller-runtime/tools/setup-envtest@{{.SETUP_ENVTEST_VERSION}}
deploy:
deps:
- task: deploy-prep
cmds:
- task: undeploy
vars:
KUBECONFIG_DPU: "{{.KUBECONFIG_DPU}}"
KUBECONFIG_HOST: "{{.KUBECONFIG_HOST}}"
- bin/kustomize build bin | KUBECONFIG="{{.KUBECONFIG_DPU}}" oc apply -f -
- bin/kustomize build bin | KUBECONFIG="{{.KUBECONFIG_HOST}}" oc apply -f -
- KUBECONFIG="{{.KUBECONFIG_DPU}}" oc -n openshift-dpu-operator wait --for=condition=Available deployment/dpu-operator-controller-manager --timeout=300s
- KUBECONFIG="{{.KUBECONFIG_HOST}}" oc -n openshift-dpu-operator wait --for=condition=Available deployment/dpu-operator-controller-manager --timeout=300s
- KUBECONFIG="{{.KUBECONFIG_DPU}}" oc -n openshift-dpu-operator wait --for=condition=ready pod --all --timeout=300s
- KUBECONFIG="{{.KUBECONFIG_HOST}}" oc -n openshift-dpu-operator wait --for=condition=ready pod --all --timeout=300s
- echo "DPU operator deployment complete - controller manager and webhook are ready"
deploy-1c:
deps:
- task: deploy-prep
cmds:
- task: undeploy-1c
vars:
KUBECONFIG_HOST: "{{.KUBECONFIG_HOST}}"
- bin/kustomize build bin | KUBECONFIG="{{.KUBECONFIG_HOST}}" oc apply -f -
- KUBECONFIG="{{.KUBECONFIG_HOST}}" oc -n openshift-dpu-operator wait --for=condition=Available deployment/dpu-operator-controller-manager --timeout=300s
- KUBECONFIG="{{.KUBECONFIG_HOST}}" oc -n openshift-dpu-operator wait --for=condition=ready pod --all --timeout=300s
prepare-e2e-test:
cmds:
- >
if [ "{{.SUBMODULES}}" = "true" ]; then
hack/prepare-submodules.sh
fi
hack/prepare-venv.sh
e2e-test:
deps:
- task: kustomize
cmds:
- task: deploy-2-clusters
- task: fast-e2e-test
e2e-test-1-cluster:
deps:
- task: kustomize
cmds:
- task: deploy-1-cluster
- task: fast-e2e-test-1c
fast-e2e-test:
cmds:
- task: redeploy
- KUBECONFIG_HOST={{.KUBECONFIG_HOST}} KUBECONFIG_DPU={{.KUBECONFIG_DPU}} go run tools/basic_setup/basic_setup.go
- task: run-e2e-test
fast-e2e-test-1c:
cmds:
- task: redeploy-1c
- KUBECONFIG_HOST={{.KUBECONFIG_HOST}} go run tools/basic_setup/basic_setup.go
- task: run-e2e-test
run-e2e-test:
deps:
- task: ginkgo
- task: envtest
cmds:
- >
FAST_TEST=true
KUBECONFIG_HOST={{.KUBECONFIG_HOST}}
KUBECONFIG_DPU={{.KUBECONFIG_DPU}}
REGISTRY={{.REGISTRY}}
NF_INGRESS_IP=10.20.30.2
EXTERNAL_CLIENT_DEV=eno12409
EXTERNAL_CLIENT_IP=10.20.30.100
KUBEBUILDER_ASSETS="$({{.BINDIR}}/setup-envtest use {{.ENVTEST_K8S_VERSION}} --bin-dir {{.BINDIR_ABS}} -p path)"
{{.BINDIR}}/ginkgo -coverprofile cover.out ./e2e_test/...
- KUBECONFIG_HOST={{.KUBECONFIG_HOST}} sh hack/traffic_flow_tests.sh
prepare-e2e-test:
cmds:
- >
if [ "{{.SUBMODULES}}" = "true" ]; then
hack/prepare-submodules.sh
fi
hack/prepare-venv.sh
redeploy:
cmds:
- task: build-image-all
- task: undeploy
- task: deploy
redeploy-1c:
cmds:
- task: build-image-all
- task: undeploy-1c
- task: deploy-1c
## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
manifests:
deps:
- task: controller-gen
cmds:
- GOFLAGS='' {{.BINDIR}}/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
bundle:
deps:
- task: manifests
- task: kustomize
- task: operator-sdk
cmds:
- "{{.BINDIR}}/operator-sdk generate kustomize manifests -q"
- cd config/manager && ../../{{.BINDIR}}/kustomize edit set image controller=${IMG:-controller:latest}
- "{{.BINDIR}}/kustomize build config/manifests | {{.BINDIR}}/operator-sdk generate bundle -q --overwrite --version ${VERSION:-4.21.0}"
- "{{.BINDIR}}/operator-sdk bundle validate ./bundle"
- cp bundle/manifests/* manifests/stable
## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate:
deps:
- task: controller-gen
cmds:
- GOFLAGS='' {{.BINDIR}}/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
fmt:
status:
- |
files=$(find . -name "*.go" -not -path "./vendor/*" -not -path "./dpu-api/vendor/*")
output=$(gofmt -d $files)
[ -z "$output" ]
cmds:
- go fmt ./...
- cd api && go fmt ./...
vet:
cmds:
- go vet ./...
## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
controller-gen:
status:
- test -s {{.BINDIR}}/controller-gen
- ./{{.BINDIR}}/controller-gen --version | grep -q {{.CONTROLLER_TOOLS_VERSION}}
cmds:
- GOBIN={{.BINDIR_ABS}} GOFLAGS='' go install sigs.k8s.io/controller-tools/cmd/controller-gen@{{.CONTROLLER_TOOLS_VERSION}}
test:
deps:
- task: podman-check
- task: manifests
- task: generate
- task: fmt
- task: vet
- task: envtest
- task: ginkgo
cmds:
- >
FAST_TEST=false
KUBEBUILDER_ASSETS="$({{.BINDIR}}/setup-envtest use {{.ENVTEST_K8S_VERSION}} --bin-dir {{.BINDIR_ABS}} -p path)"
timeout 30m {{.BINDIR}}/ginkgo --repeat 4 {{if .TEST_FOCUS}}-focus "{{.TEST_FOCUS}}" {{end}}-coverprofile cover.out ./internal/... ./pkgs/... ./api/v1/...
fast-test:
deps:
- task: envtest
- task: ginkgo
cmds:
- >
FAST_TEST=true
KUBEBUILDER_ASSETS="$({{.BINDIR}}/setup-envtest use {{.ENVTEST_K8S_VERSION}} --bin-dir {{.BINDIR_ABS}} -p path)"
{{.BINDIR}}/ginkgo {{if .TEST_FOCUS}}-focus "{{.TEST_FOCUS}}" {{end}}-coverprofile cover.out ./internal/... ./pkgs/... ./api/v1/...
vendor:
cmds:
- |
for d in . dpu-api api tools ; do
if [ "$d" = . ] ; then
(cd "$d" && go mod vendor) || exit $? ;
fi ;
(cd "$d" && go mod tidy) || exit $? ;
done