sync CCM<>CSI test cluster setup, add integration tests on schedule - #175
sync CCM<>CSI test cluster setup, add integration tests on schedule#175mweibel wants to merge 2 commits into
Conversation
15371c4 to
52e7726
Compare
6e224fc to
ffffb57
Compare
272b607 to
5b0d6ee
Compare
1c82f68 to
6f0ce8c
Compare
| # Copyright 2018 DigitalOcean | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
There was a problem hiding this comment.
Other inherited file keeps the notice: driver/*.go and main.go all use the
same two-line form:
# Copyright cloudscale.ch
# Copyright 2018 DigitalOcean
Can you restore it please restore it?
| RUN go mod download | ||
|
|
||
| # Copy all source code | ||
| COPY . . |
There was a problem hiding this comment.
While overall the new Dockerfile is definitely an improvement, I think we should explicitly COPY the files we require for the build rather than COPY . . + .dockerignore:
COPY Makefile ./
COPY driver/ driver/
COPY cmd/ cmd/Reasoning:
- Directories like
.idea/and similar is gitignored (on my machine) but not dockerignored, so it ships into every build. And breaks layer caching. - I had a stray
./test-venvwithtest-venv/.gitignorecontaining*. This was included in the COPY. But its links point to /opt/homebrew which means the build fails insbx.
A file I'd genuinely. gitignore is cmd/cloudscale-csi-plugin/cloudscale-csi-plugin from the old version of the Dockerfile. It's huge and included in every build.
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| FROM golang:1.27-alpine AS builder |
There was a problem hiding this comment.
There are a few things coming into play here:
-
First of all: in the
Makefilethere is now an unusedGO_VERSION := $(shell awk '/^go/ {print $$2}' go.mod). IMHO okay to remove it, but it's currently dead. That approach stopped working withGOTOOLCHAIN=localanyways. -
We should probably pin a patch version here and set
GOTOOLCHAIN=local. -
We should reconsider an earlier decision of ignoring patch versions for docker ecosystem in the dependabot config. Or not pin a patch version?
Happy to discuss :)
| @@ -1,130 +0,0 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
deploy/README.md should reflect the deletion of this file.
| To run the integration tests locally with your local CSI build: | ||
|
|
||
| ``` | ||
| $ export KUBECONFIG=$(pwd)/kubeconfig | ||
| ```bash | ||
| # 1. Build and export the CSI image | ||
| $ VERSION=dev make publish | ||
|
|
||
| # 2. Create a test cluster with CCM and CSI | ||
| $ export CLOUDSCALE_API_TOKEN=your-token | ||
| $ export IMAGE=quay.io/cloudscalech/cloudscale-csi-plugin:dev | ||
| $ helpers/run-in-test-cluster | ||
|
|
||
| # This will: | ||
| # - Create a Kubernetes cluster on cloudscale.ch | ||
| # - Deploy CCM from the latest official release | ||
| # - Deploy CSI from your local build | ||
|
|
||
| # 3. Run integration tests | ||
| $ export KUBECONFIG=$(pwd)/k8test/cluster/admin.conf | ||
| $ make test-integration | ||
|
|
||
| # Run a single test | ||
| $ TESTARGS='-run TestPod_Single_SSD_Volume' make test-integration | ||
|
|
||
| # 4. Clean up | ||
| $ helpers/cleanup |
There was a problem hiding this comment.
replace/merge/move to deploy/README.md (as noted elsewhere)
| echo "" | ||
|
|
||
| # Apply the manifest | ||
| kubectl apply -n kube-system -f "$manifest_file" |
There was a problem hiding this comment.
found while diffing against CCM:
# CCM original # CSI port
kubectl delete -f /tmp/ccm.yml \ kubectl apply -n kube-system -f "$manifest_file"
--ignore-not-found=true
kubectl apply -f /tmp/ccm.ymlI think that without the delete kubectl apply -n kube-system -f "$manifest_file"is a no-op.
| function build-image() { | ||
| k8test/playbooks/build-image.yml \ | ||
| -i k8test/cluster/inventory.yml \ | ||
| -e dockerfile=./Dockerfile \ | ||
| -e tag="$IMAGE" \ | ||
| -e extra='--build-arg=VERSION=test' \ | ||
| -l controls | ||
| } |
There was a problem hiding this comment.
this seems unused:
```bash
# CCM original # CSI port
if [[ ... == "build" ]]; then if [[ ... == "import" ]]; then
build-image import-image
else fi
import-image
fi
why did you choose not implement build-image?
| first_run=$(test ! -f k8test/cluster/inventory.yml && echo "yes" || echo "no") | ||
|
|
||
| ensure-k8test | ||
| ensure-cluster | ||
|
|
||
| # Deploy components on both new and existing clusters. For new clusters, | ||
| # this happens after the full cluster bootstrap (including Cilium) is done. | ||
| deploy-components |
There was a problem hiding this comment.
noticed while comparing with CCM version:
# CCM original # CSI port
first_run=$(...) first_run=$(...)
ensure-k8test ensure-k8test
ensure-cluster ensure-cluster
if [[ "$first_run" == "no" ]]; then deploy-components
update-ccm
fiI don't fully remember what first_run guards against in the CCM repo. Can you please research?
| // Kubernetes client | ||
| k8test, ok := os.LookupEnv("K8TEST_PATH") | ||
| if !ok { | ||
| log.Fatalf("could not find K8TEST_PATH environment variable\n") | ||
| } | ||
|
|
||
| // if you want to change override values or bind them to flags, there are | ||
| // methods to help you | ||
| configOverrides := &clientcmd.ConfigOverrides{} | ||
| path := filepath.Join(k8test, "cluster", "admin.conf") | ||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to read kubeconfig at path %q: %w", path, err) | ||
| } | ||
|
|
||
| kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) | ||
| var err error | ||
| config, err = kubeConfig.ClientConfig() | ||
| config, err = clientcmd.RESTConfigFromKubeConfig(data) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("failed to apply kubeconfig at path %q: %w", path, err) | ||
| } | ||
|
|
There was a problem hiding this comment.
Previously: make test-integration would run the test suite in whatever cluster KUBECONFIG was pointing at. Now, make test-integration hard-codes the k8test provisioned cluster.
I think this choice is good for CCM, but in the CSI repo I see use-cases for the opposite: running the test suite on a cluster provisioned some other way (e.g. Rancher, OpenShift) etc..
| # - Deploy CSI from your local build | ||
|
|
||
| # 3. Run integration tests | ||
| $ export KUBECONFIG=$(pwd)/k8test/cluster/admin.conf |
There was a problem hiding this comment.
contradicts test/kubernetes/integration_test.go (also noted there)
test-matrix has a few differences: