From 8585b148991fc75e7aef79a597e2dfa1dab10182 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Tue, 12 Dec 2023 21:59:27 +0530 Subject: [PATCH 01/32] Update Chart.yaml and Makefile to v0.8.0 (#82) --- Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2a371178..84003984 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v0.7.0 +VERSION ?= v0.8.0 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index a5fbff95..28f85fc7 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.0 +version: 0.8.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.7.0 +appVersion: v0.8.0 From 43b62ef4941ea329140ef2b0c739dcf9f215a11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suraj=20Banakar=28=E0=A4=AC=E0=A4=BE=E0=A4=A8=E0=A4=95?= =?UTF-8?q?=E0=A4=B0=29=20=7C=20=E3=82=B9=E3=83=A9=E3=82=B8?= Date: Thu, 14 Dec 2023 20:54:00 +0530 Subject: [PATCH 02/32] fix: nil ptr err and update Chart.yaml to v0.8.1 (#86) --- Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 ++-- charts/warm-metal-csi-driver/templates/nodeplugin.yaml | 3 +++ charts/warm-metal-csi-driver/values.yaml | 1 + cmd/plugin/node_server.go | 8 ++++---- pkg/pullexecutor/pullexecutor.go | 3 +-- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 84003984..a31f1fa9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v0.8.0 +VERSION ?= v0.8.1 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index 28f85fc7..ad462dcf 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.0 +version: 0.8.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.8.0 +appVersion: v0.8.1 diff --git a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml index d7fdc37d..c7f8d9da 100644 --- a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml +++ b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml @@ -70,6 +70,9 @@ spec: {{- if .Values.enableDaemonImageCredentialCache }} - --enable-daemon-image-credential-cache {{- end }} + {{- if .Values.enableAsyncPullMount }} + - --async-pull-mount=true + {{- end }} - "-v={{ .Values.logLevel }}" - "--mode=node" env: diff --git a/charts/warm-metal-csi-driver/values.yaml b/charts/warm-metal-csi-driver/values.yaml index fc6678f8..de0e6256 100644 --- a/charts/warm-metal-csi-driver/values.yaml +++ b/charts/warm-metal-csi-driver/values.yaml @@ -5,6 +5,7 @@ kubeletRoot: /var/lib/kubelet snapshotRoot: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs logLevel: 4 enableDaemonImageCredentialCache: +enableAsyncPullMount: false pullImageSecretForDaemonset: csiPlugin: diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index 108de79c..a3f3f7f0 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -141,7 +141,7 @@ func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishV } if e := n.pullExecutor.WaitForPull(po); e != nil { - err = status.Errorf(codes.DeadlineExceeded, err.Error()) + err = status.Errorf(codes.DeadlineExceeded, e.Error()) return } @@ -158,13 +158,13 @@ func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishV ReadOnly: req.Readonly, } - if err = n.mountExecutor.StartMounting(o); err != nil { - err = status.Error(codes.Internal, err.Error()) + if e := n.mountExecutor.StartMounting(o); e != nil { + err = status.Error(codes.Internal, e.Error()) return } if e := n.mountExecutor.WaitForMount(o); e != nil { - err = status.Errorf(codes.DeadlineExceeded, err.Error()) + err = status.Errorf(codes.DeadlineExceeded, e.Error()) return } diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index 1fe9e589..6412837e 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -111,9 +111,8 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { m.asyncErrs[o.NamedRef] = fmt.Errorf("unable to pull image %q: %s", o.Image, err) return } - pullstatus.Update(o.NamedRef, pullstatus.Pulled) - } + pullstatus.Update(o.NamedRef, pullstatus.Pulled) } }() From 203c39a08876b35c743d173b66488da904b7e1cf Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Fri, 15 Dec 2023 14:26:28 +0530 Subject: [PATCH 03/32] feat: Build and push docker images via GitHub Actions (#88) Signed-off-by: Mriyam Tamuli --- .github/workflows/images.yaml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/images.yaml diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml new file mode 100644 index 00000000..68868096 --- /dev/null +++ b/.github/workflows/images.yaml @@ -0,0 +1,39 @@ +name: Create and publish the container image. + +on: + push: + branches: [master] + tags: + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + warmmetal/csi-image + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + # set image tag based on GitHub release tag + type=semver,pattern={{version}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From ac6f2dd62b7ca5e6fd7582e46431bbf375a28ad9 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Fri, 15 Dec 2023 15:11:25 +0530 Subject: [PATCH 04/32] fix: Broken workflow for pushing images(#89) Signed-off-by: Mriyam Tamuli --- .github/workflows/images.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 68868096..f7ae14e4 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -3,7 +3,7 @@ name: Create and publish the container image. on: push: branches: [master] - tags: + tags: jobs: build-and-push-image: From 6061d3a5e4a0a673e35790a29d42aa616c68ee49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suraj=20Banakar=28=E0=A4=AC=E0=A4=BE=E0=A4=A8=E0=A4=95?= =?UTF-8?q?=E0=A4=B0=29=20=7C=20=E3=82=B9=E3=83=A9=E3=82=B8?= Date: Wed, 20 Dec 2023 19:24:55 +0530 Subject: [PATCH 05/32] fix: single PV mounted on multiple pods as read-only erroring (#99) * fix: two pods reading from same read-only volume fails * refactor: remove redundant code * refactor: remove debug code * refactor: remove arch specific go flags * refactor: remove debug code * refactor: remove extra newline * refactor: remove debug code changes * fix: refactor `run_test_job` to accept multiple jobs - to fix failing test in CI/CD (one of the manifests has multiple job templates) * test: fix typo for job name --- Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 +- hack/lib/utils.sh | 25 ++++-- pkg/mountexecutor/mountexecutor.go | 18 ++-- .../manifests/two-readonly-single-pv.yaml | 85 +++++++++++++++++++ 5 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 test/integration/manifests/two-readonly-single-pv.yaml diff --git a/Makefile b/Makefile index a31f1fa9..d6ada2e7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v0.8.1 +VERSION ?= v0.8.2 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index ad462dcf..88430946 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.1 +version: 0.8.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.8.1 +appVersion: v0.8.2 diff --git a/hack/lib/utils.sh b/hack/lib/utils.sh index 4bbed71f..78db92e8 100755 --- a/hack/lib/utils.sh +++ b/hack/lib/utils.sh @@ -24,17 +24,30 @@ function lib::run_test_job() { local manifest=$1 echo "Start job $(basename $manifest)" + local total_failed=0 kubectl delete --ignore-not-found -f "$manifest" kubectl apply -f "$manifest" - local job=$(kubectl get -f "$manifest" --no-headers -o=custom-columns=:metadata.name,:.kind | grep Job | awk '{ print $1 }') - while [ "$job" == "" ]; do + jobs="$(kubectl get -f "$manifest" --no-headers -o=custom-columns=:metadata.name,:.kind | grep Job | awk '{ print $1 }')" + while [ "$jobs" == "" ]; do sleep 1 - job=$(kubectl get -f "$manifest" --no-headers -o=custom-columns=:metadata.name,:.kind | grep Job | awk '{ print $1 }') + jobs="$(kubectl get -f "$manifest" --no-headers -o=custom-columns=:metadata.name,:.kind | grep Job | awk '{ print $1 }')" done - kubectl wait --timeout=5m --for=condition=complete job/$job - succeeded=$(kubectl get --no-headers -ocustom-columns=:.status.succeeded job/$job) - [[ succeeded -eq 1 ]] && kubectl delete -f "$manifest" + + while read job + do + kubectl wait --timeout=5m --for=condition=complete job/$job + succeeded=$(kubectl get --no-headers -ocustom-columns=:.status.succeeded job/$job) + + if [[ "${succeeded}" != "1" ]]; then + echo "Test failed for job/$job" + total_failed=$(($total_failed+1)) + fi + done <<< "$jobs" # this is done because ` | while read job` creates a subshell + # because of which increment in `total_failed` is never reflected outside the loop + # more info: https://unix.stackexchange.com/questions/402750/modify-global-variable-in-while-loop + + [[ total_failed -eq 0 ]] && kubectl delete -f "$manifest" } function lib::run_failed_test_job() { diff --git a/pkg/mountexecutor/mountexecutor.go b/pkg/mountexecutor/mountexecutor.go index 5d2e42fd..be5b5d2d 100644 --- a/pkg/mountexecutor/mountexecutor.go +++ b/pkg/mountexecutor/mountexecutor.go @@ -58,10 +58,10 @@ func NewMountExecutor(o *MountExecutorOptions) *MountExecutor { // StartMounting starts the mounting func (m *MountExecutor) StartMounting(o *MountOptions) error { - if pullstatus.Get(o.NamedRef) != pullstatus.Pulled || mountstatus.Get(o.VolumeId) == mountstatus.StillMounting { + if pullstatus.Get(o.NamedRef) != pullstatus.Pulled || mountstatus.Get(o.TargetPath) == mountstatus.StillMounting { klog.Infof("image '%s' hasn't been pulled yet (status: %s) or volume is still mounting (status: %s)", o.NamedRef.Name(), - pullstatus.Get(o.NamedRef), mountstatus.Get(o.VolumeId)) + pullstatus.Get(o.NamedRef), mountstatus.Get(o.TargetPath)) return nil } @@ -70,12 +70,12 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { o.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY if !m.asyncMount { - mountstatus.Update(o.VolumeId, mountstatus.StillMounting) + mountstatus.Update(o.TargetPath, mountstatus.StillMounting) if err := m.mounter.Mount(o.Context, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { - mountstatus.Update(o.VolumeId, mountstatus.Errored) + mountstatus.Update(o.TargetPath, mountstatus.Errored) return err } - mountstatus.Update(o.VolumeId, mountstatus.Mounted) + mountstatus.Update(o.TargetPath, mountstatus.Mounted) return nil } @@ -85,14 +85,14 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { ctx, cancel := context.WithTimeout(context.Background(), mountCtxTimeout) defer cancel() - mountstatus.Update(o.VolumeId, mountstatus.StillMounting) + mountstatus.Update(o.TargetPath, mountstatus.StillMounting) if err := m.mounter.Mount(ctx, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { klog.Errorf("mount err: %v", err.Error()) - mountstatus.Update(o.VolumeId, mountstatus.Errored) + mountstatus.Update(o.TargetPath, mountstatus.Errored) m.asyncErrs[o.NamedRef] = fmt.Errorf("err: %v: %v", err, m.asyncErrs[o.NamedRef]) return } - mountstatus.Update(o.VolumeId, mountstatus.Mounted) + mountstatus.Update(o.TargetPath, mountstatus.Mounted) }() return nil @@ -109,7 +109,7 @@ func (m *MountExecutor) WaitForMount(o *MountOptions) error { } mountCondFn := func() (done bool, err error) { - if mountstatus.Get(o.VolumeId) == mountstatus.Mounted { + if mountstatus.Get(o.TargetPath) == mountstatus.Mounted { return true, nil } if m.asyncErrs[o.NamedRef] != nil { diff --git a/test/integration/manifests/two-readonly-single-pv.yaml b/test/integration/manifests/two-readonly-single-pv.yaml new file mode 100644 index 00000000..84211668 --- /dev/null +++ b/test/integration/manifests/two-readonly-single-pv.yaml @@ -0,0 +1,85 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-test-multi-read-simple-fs +spec: + storageClassName: csi-image.warm-metal.tech + capacity: + storage: 5Mi + accessModes: + - ReadOnlyMany # does not force volume to be mounted read only + persistentVolumeReclaimPolicy: Delete + csi: + driver: csi-image.warm-metal.tech + volumeHandle: "docker.io/warmmetal/csi-image-test:simple-fs" + volumeAttributes: + pullAlways: "true" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pv-test-multi-read-simple-fs +spec: + storageClassName: csi-image.warm-metal.tech + accessModes: + - ReadOnlyMany + resources: + requests: + storage: 5Mi + volumeName: pv-test-multi-read-simple-fs +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: two-ro-single-pv-read-only-true +spec: + template: + metadata: + name: two-ro-single-pv-read-only-true + spec: + containers: + - name: two-ro-single-pv-read-only-true + image: docker.io/warmmetal/csi-image-test:check-fs + env: + - name: TARGET + value: /target1 + - name: CHECK_RO + value: "true" + volumeMounts: + - mountPath: /target1 + readOnly: true + name: target1 + restartPolicy: Never + volumes: + - name: target1 + persistentVolumeClaim: + claimName: pv-test-multi-read-simple-fs + backoffLimit: 0 +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: two-ro-single-pv-read-only-false +spec: + template: + metadata: + name: two-ro-single-pv-read-only-false + spec: + containers: + - name: two-ro-single-pv-read-only-false + image: docker.io/warmmetal/csi-image-test:check-fs + env: + - name: TARGET + value: /target1 + - name: CHECK_RO + value: "true" + volumeMounts: + - mountPath: /target1 + name: target1 + restartPolicy: Never + volumes: + - name: target1 + persistentVolumeClaim: + claimName: pv-test-multi-read-simple-fs + backoffLimit: 0 \ No newline at end of file From 8c0cf34022bcf020d94c00d64c97b40b0e672a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suraj=20Banakar=28=E0=A4=AC=E0=A4=BE=E0=A4=A8=E0=A4=95?= =?UTF-8?q?=E0=A4=B0=29=20=7C=20=E3=82=B9=E3=83=A9=E3=82=B8?= Date: Wed, 20 Dec 2023 19:55:58 +0530 Subject: [PATCH 06/32] feat: add pull mount histogram metrics (#79) * feat: wip add histogram and counter metrics for pull and mount operations * refactor: move registering metrics and starting metrics server to a separate fn - so that it is easier to use in tests - fix bug where `err` is used instead of `e` - remove metric for mount and pull wait timeout (never really recorded because kubelet timeout exhausts before) * test: wip test for metrics * test: add e2e test - hook it into cicd - finish up unit tests - fix nil ptr error for async errors - * refactor: remove debug statement - not needed anymore * fix: metrics test gha step name for * chore: rename metrics test job `error-compatible-ephemeral-volume` -> `error-ephemeral-volume` * debug: add ssh action * fix: ci/cd test failing - because the script assumes warm metal driver is deployed in `default` namespace (it is deployed in `kube-system` namespace) * docs: fix typo in code comments * chore: bump release version to `v0.9.0` --- .github/workflows/metrics.yaml | 37 ++++ Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 +- .../templates/nodeplugin.yaml | 3 + .../templates/podmonitor.yaml | 9 + cmd/plugin/main.go | 2 + cmd/plugin/node_server.go | 3 + cmd/plugin/node_server_test.go | 166 +++++++++++++++++- pkg/metrics/metrics.go | 61 +++++++ pkg/mountexecutor/mountexecutor.go | 7 + pkg/pullexecutor/pullexecutor.go | 9 + .../error-ephemeral-volume.yaml | 31 ++++ .../no-error-ephemeral-volume.yaml | 31 ++++ .../metrics-manifests/rendered-test.yaml | 25 +++ test/integration/metrics-manifests/test.yaml | 25 +++ test/integration/test-metrics.sh | 19 ++ 16 files changed, 429 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/metrics.yaml create mode 100644 pkg/metrics/metrics.go create mode 100644 test/integration/metrics-manifests/error-ephemeral-volume.yaml create mode 100644 test/integration/metrics-manifests/no-error-ephemeral-volume.yaml create mode 100644 test/integration/metrics-manifests/rendered-test.yaml create mode 100644 test/integration/metrics-manifests/test.yaml create mode 100755 test/integration/test-metrics.sh diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml new file mode 100644 index 00000000..f5000526 --- /dev/null +++ b/.github/workflows/metrics.yaml @@ -0,0 +1,37 @@ +name: test-metrics-5m +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: +jobs: + integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Start a kind cluster with containerd + uses: helm/kind-action@v1.4.0 + with: + cluster_name: kind-${{ github.run_id }} + kubectl_version: "v1.25.2" + config: ./hack/ci/containerd-cluster-conf.yaml + - name: Build image + run: ./hack/ci/build.sh + - name: Set image version + run: | + echo "VALUE_FILE=charts/warm-metal-csi-driver/values.yaml" >> "$GITHUB_ENV" + echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" + echo "HELM_NAME=wm-csi-integration-tests" >> "$GITHUB_ENV" + - name: Install the CSI Driver + run: | + trap "kubectl -n kube-system describe po" ERR + helm install ${HELM_NAME} charts/warm-metal-csi-driver -n kube-system \ + -f ${VALUE_FILE} \ + --set csiPlugin.image.tag=${IMAGE_TAG} \ + --wait \ + --debug + - name: Test metrics + run: ./test/integration/test-metrics.sh + - name: Uninstall the CSI Driver + run: helm uninstall -n kube-system ${HELM_NAME} --wait \ No newline at end of file diff --git a/Makefile b/Makefile index d6ada2e7..0d868df6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v0.8.2 +VERSION ?= v0.9.0 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index 88430946..3d26c907 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.2 +version: 0.9.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.8.2 +appVersion: v0.9.0 diff --git a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml index c7f8d9da..d125159f 100644 --- a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml +++ b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml @@ -95,6 +95,9 @@ spec: - containerPort: 9809 name: metrics protocol: TCP + - containerPort: 8080 + name: metrics2 + protocol: TCP livenessProbe: {{- toYaml .Values.csiPlugin.livenessProbe | nindent 12}} securityContext: diff --git a/charts/warm-metal-csi-driver/templates/podmonitor.yaml b/charts/warm-metal-csi-driver/templates/podmonitor.yaml index 9a29a464..15081591 100644 --- a/charts/warm-metal-csi-driver/templates/podmonitor.yaml +++ b/charts/warm-metal-csi-driver/templates/podmonitor.yaml @@ -15,6 +15,15 @@ spec: {{- if .Values.podMonitor.timeout }} scrapeTimeout: {{ .Values.podMonitor.timeout }} {{- end }} + - path: /metrics + port: metrics2 + scheme: http + {{- if .Values.podMonitor.interval }} + interval: {{ .Values.podMonitor.interval }} + {{- end }} + {{- if .Values.podMonitor.timeout }} + scrapeTimeout: {{ .Values.podMonitor.timeout }} + {{- end }} jobLabel: {{ include "warm-metal-csi-driver.fullname" . }} namespaceSelector: matchNames: diff --git a/cmd/plugin/main.go b/cmd/plugin/main.go index 550b889f..4dbbdd37 100644 --- a/cmd/plugin/main.go +++ b/cmd/plugin/main.go @@ -12,6 +12,7 @@ import ( "github.com/warm-metal/csi-driver-image/pkg/backend/containerd" "github.com/warm-metal/csi-driver-image/pkg/backend/crio" "github.com/warm-metal/csi-driver-image/pkg/cri" + "github.com/warm-metal/csi-driver-image/pkg/metrics" "github.com/warm-metal/csi-driver-image/pkg/secret" "github.com/warm-metal/csi-driver-image/pkg/watcher" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" @@ -145,5 +146,6 @@ func main() { ) } + metrics.StartMetricsServer(metrics.RegisterMetrics()) server.Wait() } diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index a3f3f7f0..621fee15 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -8,6 +8,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/containerd/containerd/reference/docker" "github.com/warm-metal/csi-driver-image/pkg/backend" + "github.com/warm-metal/csi-driver-image/pkg/metrics" "github.com/warm-metal/csi-driver-image/pkg/mountexecutor" "github.com/warm-metal/csi-driver-image/pkg/mountstatus" "github.com/warm-metal/csi-driver-image/pkg/pullexecutor" @@ -189,6 +190,8 @@ func (n NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpubl } if err = n.mounter.Unmount(ctx, req.VolumeId, backend.MountTarget(req.TargetPath)); err != nil { + // TODO(vadasambar): move this to mountexecutor once mountexecutor has `StartUnmounting` function + metrics.OperationErrorsCount.WithLabelValues("StartUnmounting").Inc() err = status.Error(codes.Internal, err.Error()) return } diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index 12ae09d6..3ada9613 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -3,7 +3,9 @@ package main import ( "context" "fmt" + "io" "net" + "net/http" "net/url" "os" "strings" @@ -17,6 +19,7 @@ import ( "github.com/warm-metal/csi-driver-image/pkg/backend" "github.com/warm-metal/csi-driver-image/pkg/backend/containerd" "github.com/warm-metal/csi-driver-image/pkg/cri" + "github.com/warm-metal/csi-driver-image/pkg/metrics" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc" "k8s.io/apimachinery/pkg/util/wait" @@ -43,7 +46,7 @@ func TestNodePublishVolumeAsync(t *testing.T) { asyncImagePulls := true ns := NewNodeServer(driver, mounter, criClient, &testSecretStore{}, asyncImagePulls) - // based on kubelet's csi mounter pluginc ode + // based on kubelet's csi mounter plugin code // check https://github.com/kubernetes/kubernetes/blob/b06a31b87235784bad2858be62115049b6eb6bcd/pkg/volume/csi/csi_mounter.go#L111-L112 timeout := 100 * time.Millisecond @@ -166,7 +169,7 @@ func TestNodePublishVolumeSync(t *testing.T) { asyncImagePulls := false ns := NewNodeServer(driver, mounter, criClient, &testSecretStore{}, asyncImagePulls) - // based on kubelet's csi mounter pluginc ode + // based on kubelet's csi mounter plugin code // check https://github.com/kubernetes/kubernetes/blob/b06a31b87235784bad2858be62115049b6eb6bcd/pkg/volume/csi/csi_mounter.go#L111-L112 timeout := 100 * time.Millisecond @@ -273,6 +276,165 @@ func TestNodePublishVolumeSync(t *testing.T) { assert.ErrorContains(t, err, "not found") } +// Check test/integration/node-server/README.md for how to run this test correctly +func TestMetrics(t *testing.T) { + socketAddr := "unix:///run/containerd/containerd.sock" + addr, err := url.Parse(socketAddr) + assert.NoError(t, err) + + criClient, err := cri.NewRemoteImageService(socketAddr, time.Minute) + assert.NoError(t, err) + assert.NotNil(t, criClient) + + mounter := containerd.NewMounter(addr.Path) + assert.NotNil(t, mounter) + + driver := csicommon.NewCSIDriver(driverName, driverVersion, "fake-node") + assert.NotNil(t, driver) + + asyncImagePulls := true + ns := NewNodeServer(driver, mounter, criClient, &testSecretStore{}, asyncImagePulls) + + // based on kubelet's csi mounter plugin code + // check https://github.com/kubernetes/kubernetes/blob/b06a31b87235784bad2858be62115049b6eb6bcd/pkg/volume/csi/csi_mounter.go#L111-L112 + timeout := 10 * time.Second + + server := csicommon.NewNonBlockingGRPCServer() + + addr, err = url.Parse(*endpoint) + assert.NoError(t, err) + + os.Remove("/csi/csi.sock") + + // automatically deleted when the server is stopped + f, err := os.Create("/csi/csi.sock") + assert.NoError(t, err) + assert.NotNil(t, f) + + var wg sync.WaitGroup + wg.Add(1) + go func() { + metrics.StartMetricsServer(metrics.RegisterMetrics()) + + server.Start(*endpoint, + nil, + nil, + ns) + // wait for the GRPC server to start + wg.Done() + server.Wait() + }() + + // give some time for server to start + time.Sleep(2 * time.Second) + defer func() { + klog.Info("server was stopped") + server.Stop() + }() + + wg.Wait() + var conn *grpc.ClientConn + + conn, err = grpc.Dial( + addr.Path, + grpc.WithInsecure(), + grpc.WithContextDialer(func(ctx context.Context, targetPath string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, "unix", targetPath) + }), + ) + + if err != nil { + panic(err) + } + + assert.NoError(t, err) + assert.NotNil(t, conn) + + nodeClient := csipbv1.NewNodeClient(conn) + assert.NotNil(t, nodeClient) + + ctx, cancel := context.WithTimeout(context.Background(), 3*timeout) + defer cancel() + // wrong image id + wrongVolId := "docker.io-doesnt-exist/library/redis-doesnt-exist:latest" + wrongTargetPath := "wrong-test-path" + wrongReq := &csi.NodePublishVolumeRequest{ + VolumeId: wrongVolId, + TargetPath: wrongTargetPath, + VolumeContext: map[string]string{ + // so that the test would always attempt to pull an image + ctxKeyPullAlways: "true", + }, + VolumeCapability: &csi.VolumeCapability{ + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY, + }, + }, + } + + r, err := nodeClient.NodePublishVolume(ctx, wrongReq) + assert.Error(t, err) + assert.Nil(t, r) + + volId := "docker.io/library/redis:latest" + targetPath := "test-path" + req := &csi.NodePublishVolumeRequest{ + VolumeId: volId, + TargetPath: targetPath, + VolumeContext: map[string]string{ + // so that the test would always attempt to pull an image + ctxKeyPullAlways: "true", + }, + VolumeCapability: &csi.VolumeCapability{ + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY, + }, + }, + } + + condFn := func() (done bool, err error) { + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + resp, err := nodeClient.NodePublishVolume(ctx, req) + if err != nil && strings.Contains(err.Error(), context.DeadlineExceeded.Error()) { + klog.Errorf("context deadline exceeded; retrying: %v", err) + return false, nil + } + if resp != nil { + return true, nil + } + return false, fmt.Errorf("response from `NodePublishVolume` is nil") + } + + err = wait.PollImmediate( + timeout, + 30*time.Second, + condFn) + assert.NoError(t, err) + + resp, err := http.Get("http://:8080/metrics") + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.Equal(t, http.StatusOK, resp.StatusCode) + + b1, err := io.ReadAll(resp.Body) + assert.NoError(t, err) + respBody := string(b1) + assert.Contains(t, respBody, metrics.ImagePullTimeKey) + assert.Contains(t, respBody, metrics.ImageMountTimeKey) + assert.Contains(t, respBody, metrics.OperationErrorsCountKey) + + // give some time before stopping the server + time.Sleep(5 * time.Second) + + // unmount if the volume is already mounted + c, ca := context.WithTimeout(context.Background(), time.Second*10) + defer ca() + + err = mounter.Unmount(c, volId, backend.MountTarget(targetPath)) + assert.NoError(t, err) +} + type testSecretStore struct { } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go new file mode 100644 index 00000000..c4104ad8 --- /dev/null +++ b/pkg/metrics/metrics.go @@ -0,0 +1,61 @@ +package metrics + +import ( + "net/http" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" + "k8s.io/klog/v2" +) + +const Async = "async" +const Sync = "sync" +const ImagePullTimeKey = "pull_duration_seconds" +const ImageMountTimeKey = "mount_duration_seconds" +const OperationErrorsCountKey = "operation_errors_total" + +var ImagePullTime = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Subsystem: "warm_metal", + Name: ImagePullTimeKey, + Help: "The time it took to pull an image", + Buckets: []float64{0, 1, 5, 10, 15, 30, 60, 120, 180}, + }, + []string{"operation_type"}, +) + +var ImageMountTime = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Subsystem: "warm_metal", + Name: ImageMountTimeKey, + Help: "The time it took to mount an image", + Buckets: []float64{0, 1, 5, 10, 15, 30, 60, 120, 180}, + }, + []string{"operation_type"}, +) + +var OperationErrorsCount = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Subsystem: "warm_metal", + Name: OperationErrorsCountKey, + Help: "Cumulative number of operation (pull,mount,unmount) errors in the driver", + }, + []string{"operation_type"}, +) + +func RegisterMetrics() *prometheus.Registry { + reg := prometheus.NewRegistry() + reg.MustRegister(ImagePullTime) + reg.MustRegister(ImageMountTime) + reg.MustRegister(OperationErrorsCount) + + return reg +} + +func StartMetricsServer(reg *prometheus.Registry) { + go func() { + http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg})) + klog.Info("serving internal metrics at port 8080") + klog.Fatal(http.ListenAndServe(":8080", nil)) + }() +} diff --git a/pkg/mountexecutor/mountexecutor.go b/pkg/mountexecutor/mountexecutor.go index be5b5d2d..64621878 100644 --- a/pkg/mountexecutor/mountexecutor.go +++ b/pkg/mountexecutor/mountexecutor.go @@ -9,6 +9,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/containerd/containerd/reference/docker" "github.com/warm-metal/csi-driver-image/pkg/backend" + "github.com/warm-metal/csi-driver-image/pkg/metrics" "github.com/warm-metal/csi-driver-image/pkg/mountstatus" "github.com/warm-metal/csi-driver-image/pkg/pullstatus" "k8s.io/apimachinery/pkg/util/wait" @@ -71,10 +72,13 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { if !m.asyncMount { mountstatus.Update(o.TargetPath, mountstatus.StillMounting) + startTime := time.Now() if err := m.mounter.Mount(o.Context, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { + metrics.OperationErrorsCount.WithLabelValues("StartMounting").Inc() mountstatus.Update(o.TargetPath, mountstatus.Errored) return err } + metrics.ImageMountTime.WithLabelValues(metrics.Sync).Observe(time.Since(startTime).Seconds()) mountstatus.Update(o.TargetPath, mountstatus.Mounted) return nil } @@ -86,12 +90,15 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { defer cancel() mountstatus.Update(o.TargetPath, mountstatus.StillMounting) + startTime := time.Now() if err := m.mounter.Mount(ctx, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { klog.Errorf("mount err: %v", err.Error()) + metrics.OperationErrorsCount.WithLabelValues("StartMounting").Inc() mountstatus.Update(o.TargetPath, mountstatus.Errored) m.asyncErrs[o.NamedRef] = fmt.Errorf("err: %v: %v", err, m.asyncErrs[o.NamedRef]) return } + metrics.ImageMountTime.WithLabelValues(metrics.Async).Observe(time.Since(startTime).Seconds()) mountstatus.Update(o.TargetPath, mountstatus.Mounted) }() diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index 6412837e..f24eab2d 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -9,6 +9,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/pkg/errors" "github.com/warm-metal/csi-driver-image/pkg/backend" + "github.com/warm-metal/csi-driver-image/pkg/metrics" "github.com/warm-metal/csi-driver-image/pkg/pullstatus" "github.com/warm-metal/csi-driver-image/pkg/remoteimage" "github.com/warm-metal/csi-driver-image/pkg/secret" @@ -59,6 +60,7 @@ func NewPullExecutor(o *PullExecutorOptions) *PullExecutor { imageSvcClient: o.ImageServiceClient, secretStore: o.SecretStore, mounter: o.Mounter, + asyncErrs: make(map[docker.Named]error), } } @@ -76,10 +78,13 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { if shouldPull { klog.Infof("pull image %q ", o.Image) pullstatus.Update(o.NamedRef, pullstatus.StillPulling) + startTime := time.Now() if err = puller.Pull(o.Context); err != nil { pullstatus.Update(o.NamedRef, pullstatus.Errored) + metrics.OperationErrorsCount.WithLabelValues("StartPulling").Inc() return errors.Errorf("unable to pull image %q: %s", o.NamedRef, err) } + metrics.ImagePullTime.WithLabelValues(metrics.Sync).Observe(time.Since(startTime).Seconds()) } pullstatus.Update(o.NamedRef, pullstatus.Pulled) return nil @@ -106,11 +111,15 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { if shouldPull { klog.Infof("pull image %q ", o.Image) pullstatus.Update(o.NamedRef, pullstatus.StillPulling) + startTime := time.Now() + if err = puller.Pull(c); err != nil { pullstatus.Update(o.NamedRef, pullstatus.Errored) + metrics.OperationErrorsCount.WithLabelValues("StartPulling").Inc() m.asyncErrs[o.NamedRef] = fmt.Errorf("unable to pull image %q: %s", o.Image, err) return } + metrics.ImagePullTime.WithLabelValues(metrics.Async).Observe(time.Since(startTime).Seconds()) } pullstatus.Update(o.NamedRef, pullstatus.Pulled) } diff --git a/test/integration/metrics-manifests/error-ephemeral-volume.yaml b/test/integration/metrics-manifests/error-ephemeral-volume.yaml new file mode 100644 index 00000000..05ba37cc --- /dev/null +++ b/test/integration/metrics-manifests/error-ephemeral-volume.yaml @@ -0,0 +1,31 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: error-ephemeral-volume +spec: + template: + metadata: + name: error-ephemeral-volume + spec: + containers: + - name: error-ephemeral-volume + image: docker.io/warmmetal/csi-image-test:check-fs + env: + - name: TARGET + value: /target + volumeMounts: + - mountPath: /target + name: target + restartPolicy: Never + volumes: + - name: target + csi: + driver: csi-image.warm-metal.tech + volumeAttributes: + image: "docker.io/warmmetal/csi-image-test:simple-fs-doesnt-exist" + # # set pullAlways if you want to ignore local images + # pullAlways: "true" + # # set secret if the image is private + # secret: "name of the ImagePullSecret" + # secretNamespace: "namespace of the secret" + backoffLimit: 0 \ No newline at end of file diff --git a/test/integration/metrics-manifests/no-error-ephemeral-volume.yaml b/test/integration/metrics-manifests/no-error-ephemeral-volume.yaml new file mode 100644 index 00000000..e600900e --- /dev/null +++ b/test/integration/metrics-manifests/no-error-ephemeral-volume.yaml @@ -0,0 +1,31 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: no-error-compatible-ephemeral-volume +spec: + template: + metadata: + name: no-error-compatible-ephemeral-volume + spec: + containers: + - name: no-error-compatible-ephemeral-volume + image: docker.io/warmmetal/csi-image-test:check-fs + env: + - name: TARGET + value: /target + volumeMounts: + - mountPath: /target + name: target + restartPolicy: Never + volumes: + - name: target + csi: + driver: csi-image.warm-metal.tech + volumeAttributes: + image: "docker.io/warmmetal/csi-image-test:simple-fs" + # # set pullAlways if you want to ignore local images + # pullAlways: "true" + # # set secret if the image is private + # secret: "name of the ImagePullSecret" + # secretNamespace: "namespace of the secret" + backoffLimit: 0 \ No newline at end of file diff --git a/test/integration/metrics-manifests/rendered-test.yaml b/test/integration/metrics-manifests/rendered-test.yaml new file mode 100644 index 00000000..03d3d446 --- /dev/null +++ b/test/integration/metrics-manifests/rendered-test.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: test-metrics +spec: + template: + metadata: + name: test-metrics + spec: + containers: + - name: test-metrics + # official curl iamge taken from https://github.com/curl/curl-container + image: quay.io/curl/curl:latest + command: + - /bin/sh + - -c + - | + (curl $IP:8080/metrics | grep warm_metal_pull_duration_seconds) && \ + (curl $IP:8080/metrics | grep warm_metal_mount_duration_seconds) && \ + (curl $IP:8080/metrics | grep warm_metal_operation_errors_total) + env: + - name: IP + value: 172.18.0.2 + restartPolicy: Never + backoffLimit: 0 diff --git a/test/integration/metrics-manifests/test.yaml b/test/integration/metrics-manifests/test.yaml new file mode 100644 index 00000000..75e90b01 --- /dev/null +++ b/test/integration/metrics-manifests/test.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: test-metrics +spec: + template: + metadata: + name: test-metrics + spec: + containers: + - name: test-metrics + # official curl iamge taken from https://github.com/curl/curl-container + image: quay.io/curl/curl:latest + command: + - /bin/sh + - -c + - | + (curl $IP:8080/metrics | grep warm_metal_pull_duration_seconds) && \ + (curl $IP:8080/metrics | grep warm_metal_mount_duration_seconds) && \ + (curl $IP:8080/metrics | grep warm_metal_operation_errors_total) + env: + - name: IP + value: %IP + restartPolicy: Never + backoffLimit: 0 diff --git a/test/integration/test-metrics.sh b/test/integration/test-metrics.sh new file mode 100755 index 00000000..24a2b921 --- /dev/null +++ b/test/integration/test-metrics.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +source $(dirname "${BASH_SOURCE[0]}")/../../hack/lib/utils.sh + +set -e + +TestBase=$(dirname "${BASH_SOURCE[0]}") +kubectl apply -f "${TestBase}/metrics-manifests/error-ephemeral-volume.yaml" +lib::run_test_job "${TestBase}/metrics-manifests/no-error-ephemeral-volume.yaml" + + +ip="$(kubectl get po -n kube-system -l=component=nodeplugin -ojsonpath='{.items[*].status.podIP}')" +cat "${TestBase}/metrics-manifests/test.yaml" | sed "s|%IP|$ip|g" > "${TestBase}/metrics-manifests/rendered-test.yaml" + +lib::run_test_job "${TestBase}/metrics-manifests/rendered-test.yaml" + +kubectl delete -f "${TestBase}/metrics-manifests/error-ephemeral-volume.yaml" + +set +e \ No newline at end of file From 96099381801b4a94099ca1c717ebc22e0d4d85c9 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Wed, 20 Dec 2023 22:14:24 +0530 Subject: [PATCH 07/32] Add csi-maintainers team in GitHub CODEOWNERS (#98) --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..25db42cf --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @warm-metal/csi-maintainers From 568db360ef24d4c6ef72374e507207347d122bd6 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Tue, 2 Jan 2024 15:14:34 +0530 Subject: [PATCH 08/32] Use CRI v1 instead of v1alpha2 (#97) * Fix imports * Update README with compatibility matrix --- README.md | 14 ++++++++++++++ cmd/install/cri.go | 2 +- cmd/plugin/node_server.go | 2 +- cmd/plugin/node_server_test.go | 5 ++--- .../kind-node-image/Dockerfile | 2 +- pkg/cri/client.go | 2 +- pkg/pullexecutor/pullexecutor.go | 2 +- pkg/remoteimage/pull.go | 2 +- pkg/remoteimage/pull_test.go | 6 +++--- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 84efed24..47f23da2 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,20 @@ then mounts images via the snapshot/storage service of the runtime. * [Pre-provisioned PV](#pre-provisioned-pv) * [Private Image](#private-image) +## Compatibility matrix +Tested changes on below mentioned versions - + +| warm-metal | k8s version | containerd | crio | +|------------|-------------|------------|---------| +| 0.6.x | v1.25 | 1.6.8 | v1.20.9 | +| 0.7.x | v1.25 | 1.6.8 | v1.20.9 | +| 0.8.x | v1.25 | 1.6.8 | v1.20.9 | +| 1.0.x | v1.25 | 1.6.8 | v1.25.2 | + +#### References: +* containerd [releases](https://containerd.io/releases/#kubernetes-support) +* cri-o [releases](https://github.com/cri-o/cri-o/releases) + ## Installation The driver requires to mount various host paths for different container runtimes. diff --git a/cmd/install/cri.go b/cmd/install/cri.go index 6dc6a660..56b4013f 100644 --- a/cmd/install/cri.go +++ b/cmd/install/cri.go @@ -15,7 +15,7 @@ import ( "github.com/BurntSushi/toml" "google.golang.org/grpc" corev1 "k8s.io/api/core/v1" - criapis "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + criapis "k8s.io/cri-api/pkg/apis/runtime/v1" ) var typeDir = corev1.HostPathDirectory diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index 621fee15..55047ed6 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -16,7 +16,7 @@ import ( csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - cri "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + cri "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/klog/v2" k8smount "k8s.io/mount-utils" ) diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index 3ada9613..f5f550ce 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -14,7 +14,6 @@ import ( "time" "github.com/container-storage-interface/spec/lib/go/csi" - csipbv1 "github.com/container-storage-interface/spec/lib/go/csi" "github.com/stretchr/testify/assert" "github.com/warm-metal/csi-driver-image/pkg/backend" "github.com/warm-metal/csi-driver-image/pkg/backend/containerd" @@ -116,7 +115,7 @@ func TestNodePublishVolumeAsync(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, conn) - nodeClient := csipbv1.NewNodeClient(conn) + nodeClient := csi.NewNodeClient(conn) assert.NotNil(t, nodeClient) condFn := func() (done bool, err error) { @@ -239,7 +238,7 @@ func TestNodePublishVolumeSync(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, conn) - nodeClient := csipbv1.NewNodeClient(conn) + nodeClient := csi.NewNodeClient(conn) assert.NotNil(t, nodeClient) condFn := func() (done bool, err error) { diff --git a/hack/integration-test-image/kind-node-image/Dockerfile b/hack/integration-test-image/kind-node-image/Dockerfile index 74b98e81..a63b68fb 100644 --- a/hack/integration-test-image/kind-node-image/Dockerfile +++ b/hack/integration-test-image/kind-node-image/Dockerfile @@ -1,2 +1,2 @@ -FROM docker.io/warmmetal/kindest-node-crio:v1.25.2 +FROM docker.io/warmmetal/kindest-node-crio:v1.25.2-updated COPY crio.conf /etc/crio/crio.conf diff --git a/pkg/cri/client.go b/pkg/cri/client.go index c10b19d2..12ee6f6e 100644 --- a/pkg/cri/client.go +++ b/pkg/cri/client.go @@ -5,7 +5,7 @@ import ( "time" "google.golang.org/grpc" - cri "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + cri "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/klog/v2" "k8s.io/kubernetes/pkg/kubelet/util" ) diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index f24eab2d..f72149c5 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -14,7 +14,7 @@ import ( "github.com/warm-metal/csi-driver-image/pkg/remoteimage" "github.com/warm-metal/csi-driver-image/pkg/secret" "k8s.io/apimachinery/pkg/util/wait" - cri "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + cri "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/klog/v2" ) diff --git a/pkg/remoteimage/pull.go b/pkg/remoteimage/pull.go index 9df21da2..721515c1 100644 --- a/pkg/remoteimage/pull.go +++ b/pkg/remoteimage/pull.go @@ -5,7 +5,7 @@ import ( "github.com/containerd/containerd/reference/docker" utilerrors "k8s.io/apimachinery/pkg/util/errors" - cri "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + cri "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/kubernetes/pkg/credentialprovider" ) diff --git a/pkg/remoteimage/pull_test.go b/pkg/remoteimage/pull_test.go index 52a1d18f..0d8809ff 100644 --- a/pkg/remoteimage/pull_test.go +++ b/pkg/remoteimage/pull_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/warm-metal/csi-driver-image/pkg/cri" - "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + v1 "k8s.io/cri-api/pkg/apis/runtime/v1" ) // Check test/integration/node-server/README.md for how to run this test correctly @@ -20,8 +20,8 @@ func TestPull(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, criClient) - r, err := criClient.PullImage(context.Background(), &v1alpha2.PullImageRequest{ - Image: &v1alpha2.ImageSpec{ + r, err := criClient.PullImage(context.Background(), &v1.PullImageRequest{ + Image: &v1.ImageSpec{ Image: testImage, }, }) From 6fb217caf00f1ba38c14a83c7843b1b488a0a096 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Wed, 3 Jan 2024 17:18:04 +0530 Subject: [PATCH 09/32] fix: failing integration tests (#103) * Disable cache * Disable cache in install-util step * Revert "Disable cache in install-util step" * Revert "Disable cache" --- cmd/plugin/node_server_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index f5f550ce..e3ee73df 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -80,7 +80,6 @@ func TestNodePublishVolumeAsync(t *testing.T) { var wg sync.WaitGroup wg.Add(1) go func() { - server.Start(*endpoint, nil, nil, @@ -203,7 +202,6 @@ func TestNodePublishVolumeSync(t *testing.T) { var wg sync.WaitGroup wg.Add(1) go func() { - server.Start(*endpoint, nil, nil, @@ -349,7 +347,7 @@ func TestMetrics(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, conn) - nodeClient := csipbv1.NewNodeClient(conn) + nodeClient := csi.NewNodeClient(conn) assert.NotNil(t, nodeClient) ctx, cancel := context.WithTimeout(context.Background(), 3*timeout) @@ -434,8 +432,7 @@ func TestMetrics(t *testing.T) { assert.NoError(t, err) } -type testSecretStore struct { -} +type testSecretStore struct{} func (t *testSecretStore) GetDockerKeyring(ctx context.Context, secrets map[string]string) (credentialprovider.DockerKeyring, error) { return credentialprovider.UnionDockerKeyring{credentialprovider.NewDockerKeyring()}, nil From c350f34d60bc1a2d1cee25e0fb4cf9940fd8077f Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Wed, 3 Jan 2024 17:26:19 +0530 Subject: [PATCH 10/32] Update Chart.yaml and Makefile to v1.0.0 (#104) --- Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0d868df6..f6cc1d5b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v0.9.0 +VERSION ?= v1.0.0 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index 3d26c907..614fd6fa 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.9.0 +version: 1.0.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.9.0 +appVersion: v1.0.0 From 2da2ca151d87ff37f33ccc6752fab4b853376082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suraj=20Banakar=28=E0=A4=AC=E0=A4=BE=E0=A4=A8=E0=A4=95?= =?UTF-8?q?=E0=A4=B0=29=20=7C=20=E3=82=B9=E3=83=A9=E3=82=B8?= Date: Fri, 12 Jan 2024 21:15:23 +0530 Subject: [PATCH 11/32] feat: make `hostNetwork` configurable (#107) * disable it by default (fixes port conflict issue on the node if another port is trying to acquire the same port) * chore: update `VERSION` in the `Makefile` * chore: replace `hostNetwork: true` with `hostNetwork: false` * fix: template substituion for `hostNetwork` --- Makefile | 2 +- charts/warm-metal-csi-driver/Chart.yaml | 4 ++-- charts/warm-metal-csi-driver/templates/nodeplugin.yaml | 2 +- charts/warm-metal-csi-driver/values.yaml | 1 + cmd/install/main.go | 2 +- pkg/pullexecutor/pullexecutor.go | 3 ++- sample/install/cri-o.yaml | 2 +- sample/install/k3s-containerd.yaml | 2 +- sample/install/minikube-containerd.yaml | 2 +- sample/install/snap-microk8s-containerd.yaml | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f6cc1d5b..db60d809 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v1.0.0 +VERSION ?= v1.0.1 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index 614fd6fa..46b2106a 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.0 +version: 1.0.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v1.0.0 +appVersion: v1.0.1 diff --git a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml index d125159f..9918a5a1 100644 --- a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml +++ b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml @@ -122,7 +122,7 @@ spec: - mountPath: {{ .Values.crioMountProgram }} name: crio-mount-program {{- end }} - hostNetwork: true + hostNetwork: {{.Values.csiPlugin.hostNetwork}} serviceAccountName: {{ include "warm-metal-csi-driver.fullname" . }}-nodeplugin volumes: - hostPath: diff --git a/charts/warm-metal-csi-driver/values.yaml b/charts/warm-metal-csi-driver/values.yaml index de0e6256..cf577ff6 100644 --- a/charts/warm-metal-csi-driver/values.yaml +++ b/charts/warm-metal-csi-driver/values.yaml @@ -9,6 +9,7 @@ enableAsyncPullMount: false pullImageSecretForDaemonset: csiPlugin: + hostNetwork: false resources: {} image: tag: "" diff --git a/cmd/install/main.go b/cmd/install/main.go index 8b66de87..2c82a624 100644 --- a/cmd/install/main.go +++ b/cmd/install/main.go @@ -278,7 +278,7 @@ spec: labels: app: csi-image-warm-metal spec: - hostNetwork: true + hostNetwork: false serviceAccountName: csi-image-warm-metal containers: - name: node-driver-registrar diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index f72149c5..945e32d6 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -102,7 +102,8 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { c, cancel := context.WithTimeout(context.Background(), pullCtxTimeout) defer cancel() - if pullstatus.Get(o.NamedRef) == pullstatus.StillPulling { + if pullstatus.Get(o.NamedRef) == pullstatus.StillPulling || + pullstatus.Get(o.NamedRef) == pullstatus.Pulled { return } diff --git a/sample/install/cri-o.yaml b/sample/install/cri-o.yaml index 15a75c45..a6fe4d49 100644 --- a/sample/install/cri-o.yaml +++ b/sample/install/cri-o.yaml @@ -126,7 +126,7 @@ spec: - mountPath: /run/containers/storage mountPropagation: Bidirectional name: crio-run-root - hostNetwork: true + hostNetwork: false serviceAccountName: csi-image-warm-metal volumes: - hostPath: diff --git a/sample/install/k3s-containerd.yaml b/sample/install/k3s-containerd.yaml index 9580348b..65416d92 100644 --- a/sample/install/k3s-containerd.yaml +++ b/sample/install/k3s-containerd.yaml @@ -117,7 +117,7 @@ spec: - mountPath: /var/lib/rancher/k3s/agent/containerd/io.containerd.snapshotter.v1.overlayfs mountPropagation: Bidirectional name: snapshot-root-0 - hostNetwork: true + hostNetwork: false serviceAccountName: csi-image-warm-metal volumes: - hostPath: diff --git a/sample/install/minikube-containerd.yaml b/sample/install/minikube-containerd.yaml index e3b469e7..ea2c4aff 100644 --- a/sample/install/minikube-containerd.yaml +++ b/sample/install/minikube-containerd.yaml @@ -123,7 +123,7 @@ spec: - mountPath: /mnt/vda1/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs mountPropagation: Bidirectional name: snapshot-root-0 - hostNetwork: true + hostNetwork: false serviceAccountName: csi-image-warm-metal volumes: - hostPath: diff --git a/sample/install/snap-microk8s-containerd.yaml b/sample/install/snap-microk8s-containerd.yaml index 230fa679..70472fc5 100644 --- a/sample/install/snap-microk8s-containerd.yaml +++ b/sample/install/snap-microk8s-containerd.yaml @@ -117,7 +117,7 @@ spec: - mountPath: /var/snap/microk8s/common/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs mountPropagation: Bidirectional name: snapshot-root-0 - hostNetwork: true + hostNetwork: false serviceAccountName: csi-image-warm-metal volumes: - hostPath: From 1d90ef48e78657989aa988a3c2ee22671a5bcb09 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Sat, 13 Jan 2024 21:39:21 +0530 Subject: [PATCH 12/32] feat: Build images for forks (#108) Signed-off-by: Mriyam Tamuli --- .github/dependabot.yml | 7 +++ .github/workflows/images-build-and-push.yaml | 60 ++++++++++++++++++++ .github/workflows/images-cleanup.yaml | 27 +++++++++ .github/workflows/images.yaml | 39 ------------- 4 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/images-build-and-push.yaml create mode 100644 .github/workflows/images-cleanup.yaml delete mode 100644 .github/workflows/images.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..2c7d1708 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/images-build-and-push.yaml b/.github/workflows/images-build-and-push.yaml new file mode 100644 index 00000000..e7221310 --- /dev/null +++ b/.github/workflows/images-build-and-push.yaml @@ -0,0 +1,60 @@ +name: Create and publish the container image. + +on: + push: + branches: + tags: + +env: + BASE_REPOSITORY: warmmetal/csi-driver-image + BASE_DEFAULT_BRANCH: master + BASE_IMAGE_NAME: warmmetal/csi-image + FORK_IMAGE_NAME: ghcr.io/${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: github.repository == env.BASE_REPOSITORY + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Log in to the GitHub Container registry + uses: docker/login-action@v3 + if: github.repository != env.BASE_REPOSITORY + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + name=${{ env.BASE_IMAGE_NAME }},enable=${{ github.repository == env.BASE_REPOSITORY }} + name=${{ env.FORK_IMAGE_NAME }},enable=${{ github.repository != env.BASE_REPOSITORY }} + tags: | + # set 'latest' tag for default branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', env.BASE_DEFAULT_BRANCH) }} + # set image tag based on GitHub release tag + type=semver,pattern={{version}},prefix=v + # set the image tag based on the branch + # https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 + type=ref,event=branch,enable=${{ github.ref_name != env.BASE_DEFAULT_BRANCH }} + flavor: | + latest=false + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/images-cleanup.yaml b/.github/workflows/images-cleanup.yaml new file mode 100644 index 00000000..e9437519 --- /dev/null +++ b/.github/workflows/images-cleanup.yaml @@ -0,0 +1,27 @@ +name: Delete old container images + +on: + schedule: + - cron: "0 0 * * *" # Source: https://crontab.guru/every-day + +permissions: + packages: write + +env: + BASE_REPOSITORY: warmmetal/csi-driver-image + +jobs: + clean-ghcr: + name: Delete old unused container images + runs-on: ubuntu-latest + steps: + - uses: actions/delete-package-versions@v4 + if: github.repository != env.BASE_REPOSITORY + with: + owner: ${{ github.repository_owner }} + package-name: ${{ github.event.repository.name }} + package-type: 'container' + min-versions-to-keep: 1 + # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + # Ignore any semver or 'latest' + ignore-versions: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?|latest$' diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml deleted file mode 100644 index f7ae14e4..00000000 --- a/.github/workflows/images.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Create and publish the container image. - -on: - push: - branches: [master] - tags: - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: | - warmmetal/csi-image - tags: | - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - # set image tag based on GitHub release tag - type=semver,pattern={{version}} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} From 028df5937de37ad9efc393fb56b4b37637d85407 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Sun, 14 Jan 2024 00:59:54 +0530 Subject: [PATCH 13/32] fix: Issue with workflow behaviour (#113) Signed-off-by: Mriyam Tamuli --- .github/workflows/images-build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/images-build-and-push.yaml b/.github/workflows/images-build-and-push.yaml index e7221310..a34e9915 100644 --- a/.github/workflows/images-build-and-push.yaml +++ b/.github/workflows/images-build-and-push.yaml @@ -6,7 +6,7 @@ on: tags: env: - BASE_REPOSITORY: warmmetal/csi-driver-image + BASE_REPOSITORY: warm-metal/csi-driver-image BASE_DEFAULT_BRANCH: master BASE_IMAGE_NAME: warmmetal/csi-image FORK_IMAGE_NAME: ghcr.io/${{ github.repository }} From 63ba8b7a67e7e4d2981644d423526e2c4dd67346 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Mon, 15 Jan 2024 11:56:09 +0530 Subject: [PATCH 14/32] ci: Address outdated issues and PRs (#114) Signed-off-by: Mriyam Tamuli --- .github/workflows/images-build-and-push.yaml | 2 +- .github/workflows/images-cleanup.yaml | 2 +- .github/workflows/stale.yaml | 43 ++++++++++++++++++++ docs/automation.md | 28 +++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/stale.yaml create mode 100644 docs/automation.md diff --git a/.github/workflows/images-build-and-push.yaml b/.github/workflows/images-build-and-push.yaml index a34e9915..2be8b1c2 100644 --- a/.github/workflows/images-build-and-push.yaml +++ b/.github/workflows/images-build-and-push.yaml @@ -1,4 +1,4 @@ -name: Create and publish the container image. +name: Create and publish the container image on: push: diff --git a/.github/workflows/images-cleanup.yaml b/.github/workflows/images-cleanup.yaml index e9437519..e692c417 100644 --- a/.github/workflows/images-cleanup.yaml +++ b/.github/workflows/images-cleanup.yaml @@ -8,7 +8,7 @@ permissions: packages: write env: - BASE_REPOSITORY: warmmetal/csi-driver-image + BASE_REPOSITORY: warm-metal/csi-driver-image jobs: clean-ghcr: diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml new file mode 100644 index 00000000..45ac43af --- /dev/null +++ b/.github/workflows/stale.yaml @@ -0,0 +1,43 @@ +name: Close stale issues and PRs + +on: + push: + paths: + - .github/workflows/stale.yml + branches-ignore: + - dependabot/** + - releases/** + schedule: + # Once every day at midnight UTC. Source: https://crontab.guru/every-day + - cron: '0 0 * * *' + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + # Setting this variable to 'true' will cause the + # action to run in a dry-run mode + debug-only: ${{ vars.DEBUG_ONLY == 'true' }} + stale-issue-message: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed in 7 days if no further activity occurs. + close-issue-message: > + Closing this issue after a prolonged period of inactivity. If this + issue is still present in the latest release, please feel free to + create a new issue with up-to-date information. + stale-pr-message: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed in 7 days if no further activity occurs. + close-pr-message: > + Closing this PR after a prolonged period of inactivity. Please create a new PR + if the changes of the PR are still relevant. + exempt-issue-labels: 'awaiting-approval,work-in-progress,help-wanted' + exempt-pr-labels: 'awaiting-approval,work-in-progress,help-wanted' + days-before-stale: 30 + days-before-close: 7 diff --git a/docs/automation.md b/docs/automation.md new file mode 100644 index 00000000..109bf95b --- /dev/null +++ b/docs/automation.md @@ -0,0 +1,28 @@ +# Automation + +There are a few [GitHub Workflows](https://docs.github.com/en/actions/using-workflows/about-workflows#about-workflows) that run on this repository. + +## Build +- [![Create and publish the container image.](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-build-and-push.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-build-and-push.yaml) + - On the main repository - `warm-metal/csi-driver-image`, builds and pushes the container image to Docker Hub [`warmmetal/csi-image`](https://hub.docker.com/r/warmmetal/csi-image) + - On any forks, builds and pushes the container image to `ghcr.io/` + +## Tests + +- [![backward-compatibility-5mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/backward-compatibility.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/backward-compatibility.yaml) +- [![containerd-11mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml) +- [![cri-o-10mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml) +- [![restart-ds-containerd-5mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-containerd.yaml) +- [![restart-ds-crio-8mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-crio.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-crio.yaml) +- [![test-metrics-5m](https://github.com/warm-metal/csi-driver-image/actions/workflows/metrics.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/metrics.yaml) + +## Maintenance + +- [![Delete old container images](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-cleanup.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-cleanup.yaml) + - Deletes all `ghcr.io/` image tags, expect `latest` or any semver tags. This workflow will run on forks only. +- [![Close stale issues and PRs](https://github.com/warm-metal/csi-driver-image/actions/workflows/stale.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/stale.yaml) + - [Create a repository variable](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) `DEBUG_ONLY` with value `true` to run the action in dry-run mode. + - Marks issues or PRs as stale after 30 days and closes them after 7 days, except those labeled with any of of the following + - `awaiting-approval` + - `work-in-progress` + - `help-wanted` From c1787b4f72fa0c0b53caf80fe96b77ebca84692c Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 17 Jan 2024 04:57:15 -0500 Subject: [PATCH 15/32] Added improved logging (#101) * added image size unit * fixed structured logging * fixed label in image-size log * added image size note in readme * update tag in Makefile and Chart.yaml Co-authored-by: Edgar Sarkisian Co-authored-by: Mugdha Adhav Co-authored-by: Mriyam Tamuli --- Makefile | 2 +- README.md | 3 +++ charts/warm-metal-csi-driver/Chart.yaml | 4 ++-- cmd/plugin/node_server.go | 6 +++++- cmd/plugin/node_server_test.go | 16 ++++++++++++++++ pkg/mountexecutor/mountexecutor.go | 20 ++++++++++++++------ pkg/pullexecutor/pullexecutor.go | 18 ++++++++++++++---- pkg/remoteimage/pull.go | 11 +++++++++++ 8 files changed, 66 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index db60d809..5c6c6472 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v1.0.1 +VERSION ?= v1.1.0 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx diff --git a/README.md b/README.md index 47f23da2..892adfd2 100644 --- a/README.md +++ b/README.md @@ -174,3 +174,6 @@ See [test/sanity](https://github.com/warm-metal/csi-driver-image/tree/master/tes ### E2E test See [test/e2e](https://github.com/warm-metal/csi-driver-image/tree/master/test/e2e). + +## Note on logging image size +Image sizes are logged after they finish pulling. We've noticed that for smaller images, usually under 1KiB, containerd may report an incorrect image size. An issue has been raised in the containerd github repository: https://github.com/containerd/containerd/issues/9641. diff --git a/charts/warm-metal-csi-driver/Chart.yaml b/charts/warm-metal-csi-driver/Chart.yaml index 46b2106a..c9418412 100644 --- a/charts/warm-metal-csi-driver/Chart.yaml +++ b/charts/warm-metal-csi-driver/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.1 +version: 1.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v1.0.1 +appVersion: v1.1.0 diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index 55047ed6..a134a817 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -7,6 +7,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/containerd/containerd/reference/docker" + "github.com/google/uuid" "github.com/warm-metal/csi-driver-image/pkg/backend" "github.com/warm-metal/csi-driver-image/pkg/metrics" "github.com/warm-metal/csi-driver-image/pkg/mountexecutor" @@ -59,7 +60,8 @@ type NodeServer struct { } func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (resp *csi.NodePublishVolumeResponse, err error) { - klog.Infof("mount request: %s", req.String()) + valuesLogger := klog.LoggerWithValues(klog.NewKlogr(), "pod-name", req.VolumeContext["pod-name"], "namespace", req.VolumeContext["namespace"], "uid", req.VolumeContext["uid"], "request-id", uuid.NewString()) + valuesLogger.Info("Incoming NodePublishVolume request", "request string", req.String()) if len(req.VolumeId) == 0 { err = status.Error(codes.InvalidArgument, "VolumeId is missing") return @@ -134,6 +136,7 @@ func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishV PullAlways: pullAlways, Image: image, PullSecrets: req.Secrets, + Logger: valuesLogger, } if e := n.pullExecutor.StartPulling(po); e != nil { @@ -157,6 +160,7 @@ func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishV TargetPath: req.TargetPath, VolumeCapability: req.VolumeCapability, ReadOnly: req.Readonly, + Logger: valuesLogger, } if e := n.mountExecutor.StartMounting(o); e != nil { diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index e3ee73df..c27ef4ce 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -57,6 +57,10 @@ func TestNodePublishVolumeAsync(t *testing.T) { VolumeContext: map[string]string{ // so that the test would always attempt to pull an image ctxKeyPullAlways: "true", + // to see improved logs + "pod-name": "test-pod", + "namespace": "test-namespace", + "uid": "test-uid", }, VolumeCapability: &csi.VolumeCapability{ AccessMode: &csi.VolumeCapability_AccessMode{ @@ -179,6 +183,10 @@ func TestNodePublishVolumeSync(t *testing.T) { VolumeContext: map[string]string{ // so that the test would always attempt to pull an image ctxKeyPullAlways: "true", + // to see improved logs + "pod-name": "test-pod", + "namespace": "test-namespace", + "uid": "test-uid", }, VolumeCapability: &csi.VolumeCapability{ AccessMode: &csi.VolumeCapability_AccessMode{ @@ -361,6 +369,10 @@ func TestMetrics(t *testing.T) { VolumeContext: map[string]string{ // so that the test would always attempt to pull an image ctxKeyPullAlways: "true", + // to see improved logs + "pod-name": "test-pod", + "namespace": "test-namespace", + "uid": "test-uid", }, VolumeCapability: &csi.VolumeCapability{ AccessMode: &csi.VolumeCapability_AccessMode{ @@ -381,6 +393,10 @@ func TestMetrics(t *testing.T) { VolumeContext: map[string]string{ // so that the test would always attempt to pull an image ctxKeyPullAlways: "true", + // to see improved logs + "pod-name": "test-pod", + "namespace": "test-namespace", + "uid": "test-uid", }, VolumeCapability: &csi.VolumeCapability{ AccessMode: &csi.VolumeCapability_AccessMode{ diff --git a/pkg/mountexecutor/mountexecutor.go b/pkg/mountexecutor/mountexecutor.go index 64621878..62548af1 100644 --- a/pkg/mountexecutor/mountexecutor.go +++ b/pkg/mountexecutor/mountexecutor.go @@ -37,6 +37,7 @@ type MountOptions struct { TargetPath string VolumeCapability *csi.VolumeCapability ReadOnly bool + Logger klog.Logger } // MountExecutor executes mount @@ -59,10 +60,12 @@ func NewMountExecutor(o *MountExecutorOptions) *MountExecutor { // StartMounting starts the mounting func (m *MountExecutor) StartMounting(o *MountOptions) error { + o.Logger.Info("Mounting image", "image", o.NamedRef.Name()) if pullstatus.Get(o.NamedRef) != pullstatus.Pulled || mountstatus.Get(o.TargetPath) == mountstatus.StillMounting { - klog.Infof("image '%s' hasn't been pulled yet (status: %s) or volume is still mounting (status: %s)", - o.NamedRef.Name(), - pullstatus.Get(o.NamedRef), mountstatus.Get(o.TargetPath)) + o.Logger.Info("Could not mount image because image hasn't finshed pulling or volume is still mounting", + "image", o.NamedRef.Name(), + "pull-status", pullstatus.Get(o.NamedRef), + "mount-status", mountstatus.Get(o.TargetPath)) return nil } @@ -74,11 +77,14 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { mountstatus.Update(o.TargetPath, mountstatus.StillMounting) startTime := time.Now() if err := m.mounter.Mount(o.Context, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { + o.Logger.Error(err, "mount error") metrics.OperationErrorsCount.WithLabelValues("StartMounting").Inc() mountstatus.Update(o.TargetPath, mountstatus.Errored) return err } - metrics.ImageMountTime.WithLabelValues(metrics.Sync).Observe(time.Since(startTime).Seconds()) + elapsed := time.Since(startTime) + metrics.ImageMountTime.WithLabelValues(metrics.Sync).Observe(elapsed.Seconds()) + o.Logger.Info("Finished mounting", "image", o.NamedRef.Name(), "mount-duration", elapsed) mountstatus.Update(o.TargetPath, mountstatus.Mounted) return nil } @@ -92,13 +98,15 @@ func (m *MountExecutor) StartMounting(o *MountOptions) error { mountstatus.Update(o.TargetPath, mountstatus.StillMounting) startTime := time.Now() if err := m.mounter.Mount(ctx, o.VolumeId, backend.MountTarget(o.TargetPath), o.NamedRef, ro); err != nil { - klog.Errorf("mount err: %v", err.Error()) + o.Logger.Error(err, "mount error") metrics.OperationErrorsCount.WithLabelValues("StartMounting").Inc() mountstatus.Update(o.TargetPath, mountstatus.Errored) m.asyncErrs[o.NamedRef] = fmt.Errorf("err: %v: %v", err, m.asyncErrs[o.NamedRef]) return } - metrics.ImageMountTime.WithLabelValues(metrics.Async).Observe(time.Since(startTime).Seconds()) + elapsed := time.Since(startTime) + metrics.ImageMountTime.WithLabelValues(metrics.Async).Observe(elapsed.Seconds()) + o.Logger.Info("Finished mounting", "image", o.NamedRef.Name(), "mount-duration", elapsed) mountstatus.Update(o.TargetPath, mountstatus.Mounted) }() diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index 945e32d6..301e2167 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -40,6 +40,7 @@ type PullOptions struct { PullAlways bool PullSecrets map[string]string Image string + Logger klog.Logger } // PullExecutor executes the pulls @@ -76,15 +77,19 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { puller := remoteimage.NewPuller(m.imageSvcClient, o.NamedRef, keyring) shouldPull := o.PullAlways || !m.mounter.ImageExists(o.Context, o.NamedRef) if shouldPull { - klog.Infof("pull image %q ", o.Image) + o.Logger.Info("Pulling image", "image", o.Image) pullstatus.Update(o.NamedRef, pullstatus.StillPulling) startTime := time.Now() if err = puller.Pull(o.Context); err != nil { pullstatus.Update(o.NamedRef, pullstatus.Errored) metrics.OperationErrorsCount.WithLabelValues("StartPulling").Inc() + o.Logger.Error(err, "Unable to pull image", "image", o.NamedRef) return errors.Errorf("unable to pull image %q: %s", o.NamedRef, err) } - metrics.ImagePullTime.WithLabelValues(metrics.Sync).Observe(time.Since(startTime).Seconds()) + elapsed := time.Since(startTime) + metrics.ImagePullTime.WithLabelValues(metrics.Sync).Observe(elapsed.Seconds()) + size := puller.ImageSize(o.Context) + o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "image-size", fmt.Sprintf("%.2f MiB", float64(size)/(1024.0*1024.0))) } pullstatus.Update(o.NamedRef, pullstatus.Pulled) return nil @@ -110,17 +115,22 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error { puller := remoteimage.NewPuller(m.imageSvcClient, o.NamedRef, keyring) shouldPull := o.PullAlways || !m.mounter.ImageExists(o.Context, o.NamedRef) if shouldPull { - klog.Infof("pull image %q ", o.Image) + o.Logger.Info("Pulling image asynchronously", "image", o.Image) pullstatus.Update(o.NamedRef, pullstatus.StillPulling) startTime := time.Now() if err = puller.Pull(c); err != nil { pullstatus.Update(o.NamedRef, pullstatus.Errored) metrics.OperationErrorsCount.WithLabelValues("StartPulling").Inc() + o.Logger.Error(err, "Unable to pull image", "image", o.Image) m.asyncErrs[o.NamedRef] = fmt.Errorf("unable to pull image %q: %s", o.Image, err) return } - metrics.ImagePullTime.WithLabelValues(metrics.Async).Observe(time.Since(startTime).Seconds()) + elapsed := time.Since(startTime) + metrics.ImagePullTime.WithLabelValues(metrics.Async).Observe(elapsed.Seconds()) + size := puller.ImageSize(o.Context) + o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "image-size", fmt.Sprintf("%.2f MiB", float64(size)/(1024.0*1024.0))) + } pullstatus.Update(o.NamedRef, pullstatus.Pulled) } diff --git a/pkg/remoteimage/pull.go b/pkg/remoteimage/pull.go index 721515c1..7ca29d5a 100644 --- a/pkg/remoteimage/pull.go +++ b/pkg/remoteimage/pull.go @@ -11,6 +11,7 @@ import ( type Puller interface { Pull(context.Context) error + ImageSize(context.Context) int } func NewPuller(imageSvc cri.ImageServiceClient, image docker.Named, @@ -28,6 +29,16 @@ type puller struct { keyring credentialprovider.DockerKeyring } +// Returns the compressed size of the image that was pulled in bytes +// see https://github.com/containerd/containerd/issues/9261 +func (p puller) ImageSize(ctx context.Context) int { + imageSpec := &cri.ImageSpec{Image: p.image.String()} + imageStatusResponse, _ := p.imageSvc.ImageStatus(ctx, &cri.ImageStatusRequest{ + Image: imageSpec, + }) + return int(imageStatusResponse.Image.Size_) +} + func (p puller) Pull(ctx context.Context) (err error) { repo := p.image.Name() imageSpec := &cri.ImageSpec{Image: p.image.String()} From 7f61789a944b546d38f1b66e5a3844e38385b1ed Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Thu, 18 Jan 2024 16:27:45 +0530 Subject: [PATCH 16/32] docs: add community meetings section in the README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 892adfd2..19c0d3d0 100644 --- a/README.md +++ b/README.md @@ -177,3 +177,10 @@ See [test/e2e](https://github.com/warm-metal/csi-driver-image/tree/master/test/e ## Note on logging image size Image sizes are logged after they finish pulling. We've noticed that for smaller images, usually under 1KiB, containerd may report an incorrect image size. An issue has been raised in the containerd github repository: https://github.com/containerd/containerd/issues/9641. + +## Community meetings +We host online meetings every other week on Thursday's at 15:30 UTC. + +Feel free to join us on [this](https://acquia.zoom.us/j/3839666297?omn=96846917396) link, and refer [Google sheet](https://docs.google.com/document/d/1nDiRtj85ZpWMH57joUmbtGG3aLkfeqFt6OWdkf8_Aaw/edit?usp=sharing) for MoMs. + +**Note:** Anyone interested in the meeting but isn't able to attend can still start a discussion under `Discussions/queries/suggestions` section in the above mentioned sheet. From 1c2651fdcf6f53a99f72be14935318805cff5fdf Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Fri, 19 Jan 2024 23:16:00 +0530 Subject: [PATCH 17/32] ci: Skip CI with dependabot updates (#120) Signed-off-by: Mriyam Tamuli --- .github/dependabot.yml | 3 +++ docs/automation.md | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c7d1708..d10e4d03 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,6 @@ updates: directory: "/" schedule: interval: "daily" + commit-message: + prefix: "[skip ci]" + include: "scope" diff --git a/docs/automation.md b/docs/automation.md index 109bf95b..89e80d87 100644 --- a/docs/automation.md +++ b/docs/automation.md @@ -26,3 +26,4 @@ There are a few [GitHub Workflows](https://docs.github.com/en/actions/using-work - `awaiting-approval` - `work-in-progress` - `help-wanted` +- [Dependabot](../.github/dependabot.yml) - [Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide#about-dependabot) is currently being used to [keep the GitHub Actions up to date](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) From 6962c65c01b5a6461daa59e51a897960a784a70b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:16:24 +0530 Subject: [PATCH 18/32] Bump actions/checkout from 2 to 4 (#109) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/backward-compatibility.yaml | 2 +- .github/workflows/containerd.yaml | 2 +- .github/workflows/cri-o.yaml | 2 +- .github/workflows/docker-containerd.yaml | 2 +- .github/workflows/metrics.yaml | 2 +- .github/workflows/restart-ds-containerd.yaml | 2 +- .github/workflows/restart-ds-crio.yaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backward-compatibility.yaml b/.github/workflows/backward-compatibility.yaml index b0bf8e16..168c96a8 100644 --- a/.github/workflows/backward-compatibility.yaml +++ b/.github/workflows/backward-compatibility.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with containerd uses: helm/kind-action@v1.4.0 with: diff --git a/.github/workflows/containerd.yaml b/.github/workflows/containerd.yaml index 9c0af184..03910a0f 100644 --- a/.github/workflows/containerd.yaml +++ b/.github/workflows/containerd.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with containerd uses: helm/kind-action@v1.4.0 with: diff --git a/.github/workflows/cri-o.yaml b/.github/workflows/cri-o.yaml index 5302ea90..0865d29f 100644 --- a/.github/workflows/cri-o.yaml +++ b/.github/workflows/cri-o.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with crio uses: helm/kind-action@v1.4.0 with: diff --git a/.github/workflows/docker-containerd.yaml b/.github/workflows/docker-containerd.yaml index 59fdb5df..4e906a32 100644 --- a/.github/workflows/docker-containerd.yaml +++ b/.github/workflows/docker-containerd.yaml @@ -5,7 +5,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: opsgang/ga-setup-minikube@v0.1.2 with: minikube-version: '1.20.0' diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index f5000526..863d812f 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with containerd uses: helm/kind-action@v1.4.0 with: diff --git a/.github/workflows/restart-ds-containerd.yaml b/.github/workflows/restart-ds-containerd.yaml index da9e7469..6e9edac5 100644 --- a/.github/workflows/restart-ds-containerd.yaml +++ b/.github/workflows/restart-ds-containerd.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with containerd uses: helm/kind-action@v1.4.0 with: diff --git a/.github/workflows/restart-ds-crio.yaml b/.github/workflows/restart-ds-crio.yaml index 89f621d0..67f73200 100644 --- a/.github/workflows/restart-ds-crio.yaml +++ b/.github/workflows/restart-ds-crio.yaml @@ -9,7 +9,7 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Start a kind cluster with crio uses: helm/kind-action@v1.4.0 with: From 1fb572f70c2de16c4258dc720e539ba74198b23e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:17:47 +0530 Subject: [PATCH 19/32] Bump helm/kind-action from 1.4.0 to 1.8.0 (#110) Bumps [helm/kind-action](https://github.com/helm/kind-action) from 1.4.0 to 1.8.0. - [Release notes](https://github.com/helm/kind-action/releases) - [Commits](https://github.com/helm/kind-action/compare/v1.4.0...v1.8.0) --- updated-dependencies: - dependency-name: helm/kind-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/backward-compatibility.yaml | 2 +- .github/workflows/containerd.yaml | 2 +- .github/workflows/cri-o.yaml | 2 +- .github/workflows/metrics.yaml | 2 +- .github/workflows/restart-ds-containerd.yaml | 2 +- .github/workflows/restart-ds-crio.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backward-compatibility.yaml b/.github/workflows/backward-compatibility.yaml index 168c96a8..c1cc5308 100644 --- a/.github/workflows/backward-compatibility.yaml +++ b/.github/workflows/backward-compatibility.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with containerd - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" diff --git a/.github/workflows/containerd.yaml b/.github/workflows/containerd.yaml index 03910a0f..73dd69f5 100644 --- a/.github/workflows/containerd.yaml +++ b/.github/workflows/containerd.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with containerd - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" diff --git a/.github/workflows/cri-o.yaml b/.github/workflows/cri-o.yaml index 0865d29f..6ee4c986 100644 --- a/.github/workflows/cri-o.yaml +++ b/.github/workflows/cri-o.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with crio - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index 863d812f..348ddb01 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with containerd - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" diff --git a/.github/workflows/restart-ds-containerd.yaml b/.github/workflows/restart-ds-containerd.yaml index 6e9edac5..bed1c56c 100644 --- a/.github/workflows/restart-ds-containerd.yaml +++ b/.github/workflows/restart-ds-containerd.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with containerd - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" diff --git a/.github/workflows/restart-ds-crio.yaml b/.github/workflows/restart-ds-crio.yaml index 67f73200..65a1021c 100644 --- a/.github/workflows/restart-ds-crio.yaml +++ b/.github/workflows/restart-ds-crio.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start a kind cluster with crio - uses: helm/kind-action@v1.4.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" From cb16287de27818619290a41d8ad52eb9c1e56f72 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Sun, 21 Jan 2024 15:05:34 +0530 Subject: [PATCH 20/32] chore: update stalebot configurations (#122) * Skip adding stale label on any issues/PRs with any milestone * Add issue/PR specific days before stale/close values * Update exempt labels * Update dependabot.yaml [skip ci] --- .github/dependabot.yml | 2 +- .github/workflows/stale.yaml | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d10e4d03..4ef387ba 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,5 +6,5 @@ updates: schedule: interval: "daily" commit-message: - prefix: "[skip ci]" + prefix: "chore: [skip ci]" include: "scope" diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 45ac43af..c9c2b0dd 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -37,7 +37,10 @@ jobs: close-pr-message: > Closing this PR after a prolonged period of inactivity. Please create a new PR if the changes of the PR are still relevant. - exempt-issue-labels: 'awaiting-approval,work-in-progress,help-wanted' - exempt-pr-labels: 'awaiting-approval,work-in-progress,help-wanted' - days-before-stale: 30 - days-before-close: 7 + exempt-all-milestones: true + exempt-issue-labels: 'awaiting-inputs,work-in-progress,help-wanted' + exempt-pr-labels: 'awaiting-inputs,work-in-progress,help-wanted' + days-before-issue-stale: 90 + days-before-issue-close: 15 + days-before-pr-stale: 30 + days-before-pr-close: 7 From a2e26ec4c89837d672e8e638eab5c39eb056df0f Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Sun, 21 Jan 2024 15:18:21 +0530 Subject: [PATCH 21/32] docs: add maintainer workflow (#123) Co-authored-by: Mriyam Tamuli --- docs/maintainer-workflow.md | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 docs/maintainer-workflow.md diff --git a/docs/maintainer-workflow.md b/docs/maintainer-workflow.md new file mode 100644 index 00000000..c666fc76 --- /dev/null +++ b/docs/maintainer-workflow.md @@ -0,0 +1,71 @@ +# Maintainer guide + +Welcome to the maintainer guide for our project! +As a project maintainer, you play a crucial role in ensuring the success and health of the project. +Below are key responsibilities and guidelines to help you manage the project effectively. + +## Key responsibilities + +### Manage Issues +1. Issue Triage + - Establish a regular schedule for reviewing and triaging open issues. + - Close irrelevant issues, and categorize and prioritize others using milestones. + +1. Acknowledging an Issue + - Review new issues promptly to address major blockers. + - Leave a comment on the issue to show appreciation for the creator's time and efforts. + - Request additional details if the issue description is unclear. + +1. Labelling Issues + - Add appropriate labels to convey the status of each issue. + - Stalebot ignores issues labeled `awaiting-inputs`, `work-in-progress`, and `help-wanted`. See [automation docs](docs/automation.md) + - Guidelines for specific labels: + - `help-wanted`: Use for issues that we want to work on but haven't been picked up. + - `work-in-progress`: Indicate ongoing work without a corresponding pull request. + - `wontfix`/`invalid`: Always add with a clear explanation. + +1. Assigning an Issue + - Assign issues to contributors who show interest or agree to work on them. + - If someone has started working on an issue, assign it to them for visibility. + +### Manage Pull Requests (PRs) +1. PR review + - Hold off on reviewing until the contributor indicates readiness, unless explicitly asked otherwise. + - Label PRs with `awaiting-inputs` if help is needed to understand the changes. + - Ensure that new features or changes are properly documented. + - Ensure that adequate tests are added (or already exists), create a separate issue if required. + +1. PR approval and merge + - Contributors cannot merge PRs, assist them in the merging process. + - Ensure Continuous Integration (CI) passes before merging, except for non-code/test changes. + - [Approve CI builds for first time contributors](https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks#approving-workflow-runs-on-a-pull-request-from-a-public-fork). + +1. Labeling PRs + - Stalebot ignores PRs labeled `awaiting-inputs`, `work-in-progress`, and `help-wanted`. + - It's a good practice to add appropriate labels on PRs. + +### Manage Releases +- Choose the correct tag based on major, minor, or patch fixes using [semver versioning](https://semver.org/). +- Aim to create releases promptly to minimize user wait times. +- If possible, update releases with informative release notes highlighting breaking changes, major features, and bug fixes. + +### Arrange and Drive Community Meetings +- Attend community meetings to engage with contributors and users. +- Promptly address action items from meeting notes. +- Foster a welcoming, open-minded, respectful, and friendly environment. + +### Ensure Code of Conduct Compliance +- Familiarize yourself with the [CNCF code of conduct](https://www.cncf.io/conduct/). +- Enforce the code of conduct among contributors and maintainers, taking necessary actions when required. + +### Keeping the Repository Up to Date +- Periodically review documentation and create issues for any missing pieces. +- Implement automation to reduce inconsistencies and enhance productivity. + +## Reading materials +For further insights, refer to these valuable resources: +- [Best practices for maintainers](https://opensource.guide/best-practices) +- [Practical skills for maintainers](https://www.freecodecamp.org/news/practical-skills-for-open-source-maintainers) +- [Becoming an open source maintainer](https://kentcdodds.com/blog/becoming-an-open-source-project-maintainer) + +**Thank you for your dedication to maintaining our project!** From 46df7e8f35aa22412e2e906c37687bc8d0ff0e8a Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Sun, 21 Jan 2024 22:03:40 +0530 Subject: [PATCH 22/32] build: Add devcontainer (#117) Signed-off-by: Mriyam Tamuli --- .devcontainer/devcontainer.json | 12 +++++ .devcontainer/welcome.txt | 7 +++ .github/.devcontainer/devcontainer.json | 40 +++++++++++++++ .../devcontainer-build-and-push.yaml | 39 +++++++++++++++ docs/running-locally.md | 49 +++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/welcome.txt create mode 100644 .github/.devcontainer/devcontainer.json create mode 100644 .github/workflows/devcontainer-build-and-push.yaml create mode 100644 docs/running-locally.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..169a22c7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,12 @@ +// For format details, see https://containers.dev +{ + "name": "csi-driver-image dev container", + "image": "ghcr.io/warm-metal/csi-driver-image/devcontainer:latest", + + // Setup the go environment and mount into the dev container at the expected location + "workspaceFolder": "/go/src/github.com/warm-metal/csi-driver-image", + "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/warm-metal/csi-driver-image,type=bind,consistency=cached", + + // Copy over welcome message + "postCreateCommand": "sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt" +} diff --git a/.devcontainer/welcome.txt b/.devcontainer/welcome.txt new file mode 100644 index 00000000..7ba0b745 --- /dev/null +++ b/.devcontainer/welcome.txt @@ -0,0 +1,7 @@ +👋 Welcome to your development environment for CSI Driver Image! + +This debian dev container image contains all tools needed for development. + +Get started right away! 🚀 + +Check out the guide in docs/running-locally.md diff --git a/.github/.devcontainer/devcontainer.json b/.github/.devcontainer/devcontainer.json new file mode 100644 index 00000000..ce3721e4 --- /dev/null +++ b/.github/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// For format details, see https://containers.dev +{ + "name": "csi-driver-image dev container", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + + "otherPortsAttributes": { + "onAutoForward": "silent" + }, + + "features": { + "ghcr.io/devcontainers/features/go:1": { + "version": "1.19" + }, + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { + "version": "latest", + "helm": "latest", + "minikube": "none" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "dockerDashComposeVersion": "v2" + }, + "ghcr.io/devcontainers-contrib/features/kind:1": {} + }, + + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "zsh", + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "zsh" + } + } + }, + "extensions": [ + "golang.go" + ] + } + } +} diff --git a/.github/workflows/devcontainer-build-and-push.yaml b/.github/workflows/devcontainer-build-and-push.yaml new file mode 100644 index 00000000..2600588e --- /dev/null +++ b/.github/workflows/devcontainer-build-and-push.yaml @@ -0,0 +1,39 @@ +name: Dev Container Build and Push Image + +on: + push: + branches: + master + paths: + - .github/workflows/devcontainer-build-and-push.yml + - '.github/.devcontainer/**' + pull_request: + paths: + - .github/workflows/devcontainer-build-and-push.yml + - '.github/.devcontainer/**' + +permissions: + contents: read + packages: write + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the GitHub Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pre-build dev container image + uses: devcontainers/ci@v0.3 + with: + subFolder: .github + imageName: ghcr.io/${{ github.repository }}/devcontainer + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: always diff --git a/docs/running-locally.md b/docs/running-locally.md new file mode 100644 index 00000000..cc8bccb9 --- /dev/null +++ b/docs/running-locally.md @@ -0,0 +1,49 @@ +# Running Locally + +You have two options: + +1. Use the [Dev Container](#development-container). This is the recommended approach. This can be used with VSCode, the `devcontainer` CLI, or GitHub Codespaces. +1. Install the [requirements](#requirements) on your computer manually. + +## Development Container + +The development container contains all the tools necessary to work with csi-driver-image. + +You can use the development container in a few different ways: + +1. [Visual Studio Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). Open the local clone of `csi-driver-image` folder in VSCode and it should offer to use the development container automatically. +1. [`devcontainer` CLI](https://github.com/devcontainers/cli). Once installed, the local clone of `csi-driver-image` folder and run `devcontainer up --workspace-folder .` followed by `devcontainer exec --workspace-folder . /bin/bash` to get a shell where you can build the code. You can use any editor outside the container to edit code; any changes will be mirrored inside the container. +1. [GitHub Codespaces](https://github.com/codespaces). You can start editing as soon as VSCode is open. + +Once you have entered the container, continue to [Developing Locally](#developing-locally). + +## Requirements + +To build on your own machine without using the Dev Container you will need: + +* A local clone of this repository. +* [Go](https://golang.org/dl/) +* A local Kubernetes cluster ([`k3d`](https://k3d.io/#quick-start), [`kind`](https://kind.sigs.k8s.io/docs/user/quick-start/#installation), or [`minikube`](https://minikube.sigs.k8s.io/docs/start/)) +* [`helm`](https://helm.sh/docs/intro/install/) + +## Developing locally + +_**Note:** Unless specified otherwise, you need to run all commands after changing your working directory to this repository - `cd /path/to/csi-driver-image-repository`_ + +1. First, make sure you can connect to the Kubernetes cluster by following the quickstart guide of your chosen local Kubernetes cluster provider. + ``` + $ kubectl get nodes + ``` + Make sure you don't see any errors in your terminal. If do get error(s), please check the quickstart guide or the local Kubernetes cluster provider's documentation on how to get started. + +1. Install the csi-driver-image using the helm chart. + ``` + helm upgrade --install wm-csi \ + charts/warm-metal-csi-driver \ + --wait + ``` + +1. You can submit an example for testing using `kubectl`: + ```bash + kubectl create -f sample/ephemeral-volume.yaml + ``` From 2d603590baec6610db611e68e0098433c7fb20ac Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Sun, 21 Jan 2024 22:11:48 +0530 Subject: [PATCH 23/32] docs: update README * Add repository name change notice. * Update community meetings link and description. --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19c0d3d0..cbbcfd9e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,15 @@ [![cri-o](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml) ![Docker Pulls](https://img.shields.io/docker/pulls/warmmetal/csi-image?color=brightgreen&logo=docker&logoColor=lightgrey&labelColor=black) +# :construction_worker_man: :wrench: :construction: RENAMING THE REPOSITORY :construction: :wrench: :construction_worker_man: + +We are currently in the process of [changing the repository name](https://github.com/warm-metal/csi-driver-image/issues/105). This alteration may potentially introduce issues during Continuous Integration (CI) runs or while building packages locally. If you encounter any problems, we encourage you to promptly create an issue so that we can assist you in resolving them. + +### Note for Forked Repositories: +If you have forked this repository before January 21, 2024, we kindly request that you follow the steps outlined in the [GitHub documentation](https://docs.github.com/en/repositories/creating-and-managing-repositories/renaming-a-repository) to update your remote. This ensures that your fork remains synchronized with the latest changes and avoids any disruption to your workflow. + +We appreciate your cooperation and understanding as we work to improve our repository. + # csi-driver-image This is a CSI driver for mounting images as PVs or ephemeral volumes. @@ -179,8 +188,8 @@ See [test/e2e](https://github.com/warm-metal/csi-driver-image/tree/master/test/e Image sizes are logged after they finish pulling. We've noticed that for smaller images, usually under 1KiB, containerd may report an incorrect image size. An issue has been raised in the containerd github repository: https://github.com/containerd/containerd/issues/9641. ## Community meetings -We host online meetings every other week on Thursday's at 15:30 UTC. +We conduct online meetings every 1st, 3rd, and 5th week of the month on Thursdays at 15:30 UTC. -Feel free to join us on [this](https://acquia.zoom.us/j/3839666297?omn=96846917396) link, and refer [Google sheet](https://docs.google.com/document/d/1nDiRtj85ZpWMH57joUmbtGG3aLkfeqFt6OWdkf8_Aaw/edit?usp=sharing) for MoMs. +Feel free to join us through [this Zoom link](https://acquia.zoom.us/j/94346685583) and refer to the [Google document](https://docs.google.com/document/d/1nDiRtj85ZpWMH57joUmbtGG3aLkfeqFt6OWdkf8_Aaw/edit?usp=sharing) for Minutes of Meetings (MoMs). -**Note:** Anyone interested in the meeting but isn't able to attend can still start a discussion under `Discussions/queries/suggestions` section in the above mentioned sheet. +Note: If you are unable to attend the meeting but still interested, you can initiate a discussion under Discussions/Queries/Suggestions in the aforementioned Google document. From 8487a8b6a493a186804d72dffbf35f981742fe72 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Sun, 21 Jan 2024 22:22:48 +0530 Subject: [PATCH 24/32] docs: update README with branch change instructions --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index cbbcfd9e..5189c15c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,14 @@ We are currently in the process of [changing the repository name](https://github ### Note for Forked Repositories: If you have forked this repository before January 21, 2024, we kindly request that you follow the steps outlined in the [GitHub documentation](https://docs.github.com/en/repositories/creating-and-managing-repositories/renaming-a-repository) to update your remote. This ensures that your fork remains synchronized with the latest changes and avoids any disruption to your workflow. +Also the default branch has been updated to `main` from `master`. Please run below commands for updating your local setup. +``` +git branch -m master main +git fetch origin +git branch -u main main +git remote set-head origin -a +``` + We appreciate your cooperation and understanding as we work to improve our repository. # csi-driver-image From 03636ae3e6487d9096794f5f441ac4a168633a93 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Mon, 22 Jan 2024 15:00:00 +0530 Subject: [PATCH 25/32] build: Update workflows to accommodate repository name and default branch changes (#126) Signed-off-by: Mriyam Tamuli --- .github/workflows/backward-compatibility.yaml | 4 ++-- .github/workflows/containerd.yaml | 4 ++-- .github/workflows/cri-o.yaml | 4 ++-- .github/workflows/devcontainer-build-and-push.yaml | 3 +-- .github/workflows/images-build-and-push.yaml | 9 +++++++-- .github/workflows/images-cleanup.yaml | 2 +- .github/workflows/metrics.yaml | 6 +++--- .github/workflows/restart-ds-containerd.yaml | 4 ++-- .github/workflows/restart-ds-crio.yaml | 4 ++-- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/backward-compatibility.yaml b/.github/workflows/backward-compatibility.yaml index c1cc5308..382f432b 100644 --- a/.github/workflows/backward-compatibility.yaml +++ b/.github/workflows/backward-compatibility.yaml @@ -1,9 +1,9 @@ name: backward-compatibility-5mins on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: diff --git a/.github/workflows/containerd.yaml b/.github/workflows/containerd.yaml index 73dd69f5..082e8c91 100644 --- a/.github/workflows/containerd.yaml +++ b/.github/workflows/containerd.yaml @@ -1,9 +1,9 @@ name: containerd-11mins on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: diff --git a/.github/workflows/cri-o.yaml b/.github/workflows/cri-o.yaml index 6ee4c986..ef32298f 100644 --- a/.github/workflows/cri-o.yaml +++ b/.github/workflows/cri-o.yaml @@ -1,9 +1,9 @@ name: cri-o-10mins on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: diff --git a/.github/workflows/devcontainer-build-and-push.yaml b/.github/workflows/devcontainer-build-and-push.yaml index 2600588e..4d6c408d 100644 --- a/.github/workflows/devcontainer-build-and-push.yaml +++ b/.github/workflows/devcontainer-build-and-push.yaml @@ -2,8 +2,7 @@ name: Dev Container Build and Push Image on: push: - branches: - master + branches: [main] paths: - .github/workflows/devcontainer-build-and-push.yml - '.github/.devcontainer/**' diff --git a/.github/workflows/images-build-and-push.yaml b/.github/workflows/images-build-and-push.yaml index 2be8b1c2..a6123fcb 100644 --- a/.github/workflows/images-build-and-push.yaml +++ b/.github/workflows/images-build-and-push.yaml @@ -3,14 +3,19 @@ name: Create and publish the container image on: push: branches: + - '*' tags: + - 'v*' env: - BASE_REPOSITORY: warm-metal/csi-driver-image - BASE_DEFAULT_BRANCH: master + BASE_REPOSITORY: warm-metal/container-image-csi-driver + BASE_DEFAULT_BRANCH: main BASE_IMAGE_NAME: warmmetal/csi-image FORK_IMAGE_NAME: ghcr.io/${{ github.repository }} +permissions: + packages: write + jobs: build-and-push-image: runs-on: ubuntu-latest diff --git a/.github/workflows/images-cleanup.yaml b/.github/workflows/images-cleanup.yaml index e692c417..2b699f51 100644 --- a/.github/workflows/images-cleanup.yaml +++ b/.github/workflows/images-cleanup.yaml @@ -8,7 +8,7 @@ permissions: packages: write env: - BASE_REPOSITORY: warm-metal/csi-driver-image + BASE_REPOSITORY: warm-metal/container-image-csi-driver jobs: clean-ghcr: diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml index 348ddb01..4b84bd49 100644 --- a/.github/workflows/metrics.yaml +++ b/.github/workflows/metrics.yaml @@ -1,9 +1,9 @@ name: test-metrics-5m on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: @@ -34,4 +34,4 @@ jobs: - name: Test metrics run: ./test/integration/test-metrics.sh - name: Uninstall the CSI Driver - run: helm uninstall -n kube-system ${HELM_NAME} --wait \ No newline at end of file + run: helm uninstall -n kube-system ${HELM_NAME} --wait diff --git a/.github/workflows/restart-ds-containerd.yaml b/.github/workflows/restart-ds-containerd.yaml index bed1c56c..8cf26202 100644 --- a/.github/workflows/restart-ds-containerd.yaml +++ b/.github/workflows/restart-ds-containerd.yaml @@ -1,9 +1,9 @@ name: restart-ds-containerd-5mins on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: diff --git a/.github/workflows/restart-ds-crio.yaml b/.github/workflows/restart-ds-crio.yaml index 65a1021c..ab99760c 100644 --- a/.github/workflows/restart-ds-crio.yaml +++ b/.github/workflows/restart-ds-crio.yaml @@ -1,9 +1,9 @@ name: restart-ds-crio-8mins on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] workflow_dispatch: jobs: integration: From 282bd48f70f036ad4972b2d5b677bb7b715f2a5b Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Mon, 22 Jan 2024 19:26:04 +0530 Subject: [PATCH 26/32] chore: update go references for old repository name (#127) * Update go.mod * Update package imports * Update Dockerfiles * Update docs * Update scripts * Update README Co-authored-by: Mriyam Tamuli --- Dockerfile | 6 ++--- README.md | 30 +++++++++++----------- cmd/plugin/controller_server.go | 2 +- cmd/plugin/main.go | 17 ++++++------ cmd/plugin/node_server.go | 14 +++++----- cmd/plugin/node_server_test.go | 8 +++--- docs/automation.md | 20 +++++++-------- docs/running-locally.md | 10 ++++---- go.mod | 6 ++--- pkg/backend/containerd/containerd.go | 2 +- pkg/backend/crio/crio.go | 3 +-- pkg/mountexecutor/mountexecutor.go | 9 +++---- pkg/pullexecutor/pullexecutor.go | 11 ++++---- pkg/remoteimage/pull_test.go | 2 +- test/e2e/Dockerfile | 4 +-- test/integration/backward-compatability.sh | 6 ++--- test/integration/node-server/README.md | 12 ++++----- test/sanity/Dockerfile | 4 +-- 18 files changed, 81 insertions(+), 85 deletions(-) diff --git a/Dockerfile b/Dockerfile index a91ae276..d4ea9ffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/library/golang:1.20.4-alpine3.17 as builder RUN apk add --no-cache btrfs-progs-dev lvm2-dev make build-base -WORKDIR /go/src/csi-driver-image +WORKDIR /go/src/container-image-csi-driver COPY go.mod go.sum ./ RUN go mod download COPY cmd ./cmd @@ -10,10 +10,10 @@ RUN make build RUN make install-util FROM scratch as install-util -COPY --from=builder /go/src/csi-driver-image/_output/warm-metal-csi-image-install / +COPY --from=builder /go/src/container-image-csi-driver/_output/warm-metal-csi-image-install / FROM alpine:3.17 RUN apk add --no-cache btrfs-progs-dev lvm2-dev WORKDIR / -COPY --from=builder /go/src/csi-driver-image/_output/csi-image-plugin /usr/bin/ +COPY --from=builder /go/src/container-image-csi-driver/_output/csi-image-plugin /usr/bin/ ENTRYPOINT ["csi-image-plugin"] diff --git a/README.md b/README.md index 5189c15c..b275a9b1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -[![containerd](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml) -[![docker-containerd](https://github.com/warm-metal/csi-driver-image/actions/workflows/docker-containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/docker-containerd.yaml) -[![cri-o](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml) +[![containerd](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml) +[![docker-containerd](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/docker-containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/docker-containerd.yaml) +[![cri-o](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml) ![Docker Pulls](https://img.shields.io/docker/pulls/warmmetal/csi-image?color=brightgreen&logo=docker&logoColor=lightgrey&labelColor=black) # :construction_worker_man: :wrench: :construction: RENAMING THE REPOSITORY :construction: :wrench: :construction_worker_man: -We are currently in the process of [changing the repository name](https://github.com/warm-metal/csi-driver-image/issues/105). This alteration may potentially introduce issues during Continuous Integration (CI) runs or while building packages locally. If you encounter any problems, we encourage you to promptly create an issue so that we can assist you in resolving them. +We are currently in the process of [changing the repository name](https://github.com/warm-metal/container-image-csi-driver/issues/105). This alteration may potentially introduce issues during Continuous Integration (CI) runs or while building packages locally. If you encounter any problems, we encourage you to promptly create an issue so that we can assist you in resolving them. ### Note for Forked Repositories: If you have forked this repository before January 21, 2024, we kindly request that you follow the steps outlined in the [GitHub documentation](https://docs.github.com/en/repositories/creating-and-managing-repositories/renaming-a-repository) to update your remote. This ensures that your fork remains synchronized with the latest changes and avoids any disruption to your workflow. @@ -20,11 +20,11 @@ git remote set-head origin -a We appreciate your cooperation and understanding as we work to improve our repository. -# csi-driver-image +# container-image-csi-driver (previously csi-driver-image) This is a CSI driver for mounting images as PVs or ephemeral volumes. -It pulls images via CRI and shares the image store with the container runtime, +It pulls images via CRI and shares the image store with the container runtime, then mounts images via the snapshot/storage service of the runtime. **Read-Only** volumes of the same image share the same snapshot. **Read-Write** volumes keep their own snapshot and changes until pod deletion. @@ -55,7 +55,7 @@ The driver requires to mount various host paths for different container runtimes So, I build a binary utility, `warm-metal-csi-image-install`, to reduce the installation complexity. It supports kubernetes, microk8s and k3s clusters with container runtime **cri-o**, **containerd** or **docker**. Users can run this utility on any nodes in their clusters to generate proper manifests to install the driver. -The download link is available on the [release page](https://github.com/warm-metal/csi-driver-image/releases). +The download link is available on the [release page](https://github.com/warm-metal/container-image-csi-driver/releases). ```shell script # To print manifests @@ -74,13 +74,13 @@ warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo --enable-daemon-image-credential-cache=false ``` -You can found some installation manifests as samples in [examples](https://github.com/warm-metal/csi-driver-image/tree/master/sample). +You can found some installation manifests as samples in [examples](https://github.com/warm-metal/container-image-csi-driver/tree/master/sample). #### Notice for docker Until Docker migrates its [image and snapshot store](https://github.com/moby/moby/issues/38043) to containerd, I recommend you use containerd instead. Otherwise, the driver can't use images managed by Docker daemon. -If your container runtime can't be migrated, you can enable the CRI plugin by clearing +If your container runtime can't be migrated, you can enable the CRI plugin by clearing the containerd config file `/etc/containerd/config.toml`, then restarting the containerd. @@ -152,14 +152,14 @@ spec: # pullAlways: "true" ``` -See all [examples](https://github.com/warm-metal/csi-driver-image/tree/master/sample). +See all [examples](https://github.com/warm-metal/container-image-csi-driver/tree/master/sample). #### Private Image -There are several ways to configure credentials for private image pulling. +There are several ways to configure credentials for private image pulling. If your clusters are in cloud, the credential provider are enabled automatically. -If your cloud provider provides a credential provider plugin instead, you can enable it by adding +If your cloud provider provides a credential provider plugin instead, you can enable it by adding both `--image-credential-provider-config` and `--image-credential-provider-bin-dir` flags to the driver. See [credential provider plugin](https://kubernetes.io/docs/tasks/kubelet-credential-provider/kubelet-credential-provider/). @@ -176,7 +176,7 @@ then restart the driver daemon pod. Users can run `warm-metal-csi-image-install` warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo --pull-image-secret-for-daemonset=bar ``` -If the secret works only for particular workloads, you can set via the `nodePublishSecretRef` attribute of ephemeral volumes. +If the secret works only for particular workloads, you can set via the `nodePublishSecretRef` attribute of ephemeral volumes. See the above sample manifest, and notice that secrets and workloads must in the same namespace. (Since version v0.5.1, pulling private images using the ImagePullSecrets which attached to workload service accounts is no longer supported for security reasons.) @@ -186,11 +186,11 @@ You can also set the secret to a PV, then share the PV with multiple workloads. ### Sanity test -See [test/sanity](https://github.com/warm-metal/csi-driver-image/tree/master/test/sanity). +See [test/sanity](https://github.com/warm-metal/container-image-csi-driver/tree/master/test/sanity). ### E2E test -See [test/e2e](https://github.com/warm-metal/csi-driver-image/tree/master/test/e2e). +See [test/e2e](https://github.com/warm-metal/container-image-csi-driver/tree/master/test/e2e). ## Note on logging image size Image sizes are logged after they finish pulling. We've noticed that for smaller images, usually under 1KiB, containerd may report an incorrect image size. An issue has been raised in the containerd github repository: https://github.com/containerd/containerd/issues/9641. diff --git a/cmd/plugin/controller_server.go b/cmd/plugin/controller_server.go index d72b9793..e8e52dc9 100644 --- a/cmd/plugin/controller_server.go +++ b/cmd/plugin/controller_server.go @@ -5,7 +5,7 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/pkg/errors" - "github.com/warm-metal/csi-driver-image/pkg/watcher" + "github.com/warm-metal/container-image-csi-driver/pkg/watcher" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/cmd/plugin/main.go b/cmd/plugin/main.go index 4dbbdd37..28b5e4ee 100644 --- a/cmd/plugin/main.go +++ b/cmd/plugin/main.go @@ -5,20 +5,19 @@ import ( goflag "flag" "fmt" "net/url" + "time" "github.com/container-storage-interface/spec/lib/go/csi" flag "github.com/spf13/pflag" - "github.com/warm-metal/csi-driver-image/pkg/backend" - "github.com/warm-metal/csi-driver-image/pkg/backend/containerd" - "github.com/warm-metal/csi-driver-image/pkg/backend/crio" - "github.com/warm-metal/csi-driver-image/pkg/cri" - "github.com/warm-metal/csi-driver-image/pkg/metrics" - "github.com/warm-metal/csi-driver-image/pkg/secret" - "github.com/warm-metal/csi-driver-image/pkg/watcher" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/backend/containerd" + "github.com/warm-metal/container-image-csi-driver/pkg/backend/crio" + "github.com/warm-metal/container-image-csi-driver/pkg/cri" + "github.com/warm-metal/container-image-csi-driver/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/secret" + "github.com/warm-metal/container-image-csi-driver/pkg/watcher" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "k8s.io/klog/v2" - - "time" ) const ( diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index a134a817..84baf1ab 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -8,12 +8,12 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/containerd/containerd/reference/docker" "github.com/google/uuid" - "github.com/warm-metal/csi-driver-image/pkg/backend" - "github.com/warm-metal/csi-driver-image/pkg/metrics" - "github.com/warm-metal/csi-driver-image/pkg/mountexecutor" - "github.com/warm-metal/csi-driver-image/pkg/mountstatus" - "github.com/warm-metal/csi-driver-image/pkg/pullexecutor" - "github.com/warm-metal/csi-driver-image/pkg/secret" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/mountexecutor" + "github.com/warm-metal/container-image-csi-driver/pkg/mountstatus" + "github.com/warm-metal/container-image-csi-driver/pkg/pullexecutor" + "github.com/warm-metal/container-image-csi-driver/pkg/secret" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -101,7 +101,7 @@ func (n NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishV return } - if err = os.MkdirAll(req.TargetPath, 0755); err != nil { + if err = os.MkdirAll(req.TargetPath, 0o755); err != nil { err = status.Error(codes.Internal, err.Error()) return } diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index c27ef4ce..e6aca0bb 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -15,10 +15,10 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/stretchr/testify/assert" - "github.com/warm-metal/csi-driver-image/pkg/backend" - "github.com/warm-metal/csi-driver-image/pkg/backend/containerd" - "github.com/warm-metal/csi-driver-image/pkg/cri" - "github.com/warm-metal/csi-driver-image/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/backend/containerd" + "github.com/warm-metal/container-image-csi-driver/pkg/cri" + "github.com/warm-metal/container-image-csi-driver/pkg/metrics" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc" "k8s.io/apimachinery/pkg/util/wait" diff --git a/docs/automation.md b/docs/automation.md index 89e80d87..12babf34 100644 --- a/docs/automation.md +++ b/docs/automation.md @@ -3,24 +3,24 @@ There are a few [GitHub Workflows](https://docs.github.com/en/actions/using-workflows/about-workflows#about-workflows) that run on this repository. ## Build -- [![Create and publish the container image.](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-build-and-push.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-build-and-push.yaml) - - On the main repository - `warm-metal/csi-driver-image`, builds and pushes the container image to Docker Hub [`warmmetal/csi-image`](https://hub.docker.com/r/warmmetal/csi-image) +- [![Create and publish the container image.](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-build-and-push.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-build-and-push.yaml) + - On the main repository - `warm-metal/container-image-csi-driver`, builds and pushes the container image to Docker Hub [`warmmetal/csi-image`](https://hub.docker.com/r/warmmetal/csi-image) - On any forks, builds and pushes the container image to `ghcr.io/` ## Tests -- [![backward-compatibility-5mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/backward-compatibility.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/backward-compatibility.yaml) -- [![containerd-11mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/containerd.yaml) -- [![cri-o-10mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/cri-o.yaml) -- [![restart-ds-containerd-5mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-containerd.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-containerd.yaml) -- [![restart-ds-crio-8mins](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-crio.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/restart-ds-crio.yaml) -- [![test-metrics-5m](https://github.com/warm-metal/csi-driver-image/actions/workflows/metrics.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/metrics.yaml) +- [![backward-compatibility-5mins](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/backward-compatibility.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/backward-compatibility.yaml) +- [![containerd-11mins](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml) +- [![cri-o-10mins](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml) +- [![restart-ds-containerd-5mins](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/restart-ds-containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/restart-ds-containerd.yaml) +- [![restart-ds-crio-8mins](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/restart-ds-crio.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/restart-ds-crio.yaml) +- [![test-metrics-5m](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/metrics.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/metrics.yaml) ## Maintenance -- [![Delete old container images](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-cleanup.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/images-cleanup.yaml) +- [![Delete old container images](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-cleanup.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-cleanup.yaml) - Deletes all `ghcr.io/` image tags, expect `latest` or any semver tags. This workflow will run on forks only. -- [![Close stale issues and PRs](https://github.com/warm-metal/csi-driver-image/actions/workflows/stale.yaml/badge.svg)](https://github.com/warm-metal/csi-driver-image/actions/workflows/stale.yaml) +- [![Close stale issues and PRs](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/stale.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/stale.yaml) - [Create a repository variable](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) `DEBUG_ONLY` with value `true` to run the action in dry-run mode. - Marks issues or PRs as stale after 30 days and closes them after 7 days, except those labeled with any of of the following - `awaiting-approval` diff --git a/docs/running-locally.md b/docs/running-locally.md index cc8bccb9..2bfbbc6a 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -7,12 +7,12 @@ You have two options: ## Development Container -The development container contains all the tools necessary to work with csi-driver-image. +The development container contains all the tools necessary to work with container-image-csi-driver. You can use the development container in a few different ways: -1. [Visual Studio Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). Open the local clone of `csi-driver-image` folder in VSCode and it should offer to use the development container automatically. -1. [`devcontainer` CLI](https://github.com/devcontainers/cli). Once installed, the local clone of `csi-driver-image` folder and run `devcontainer up --workspace-folder .` followed by `devcontainer exec --workspace-folder . /bin/bash` to get a shell where you can build the code. You can use any editor outside the container to edit code; any changes will be mirrored inside the container. +1. [Visual Studio Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). Open the local clone of `container-image-csi-driver` folder in VSCode and it should offer to use the development container automatically. +1. [`devcontainer` CLI](https://github.com/devcontainers/cli). Once installed, the local clone of `container-image-csi-driver` folder and run `devcontainer up --workspace-folder .` followed by `devcontainer exec --workspace-folder . /bin/bash` to get a shell where you can build the code. You can use any editor outside the container to edit code; any changes will be mirrored inside the container. 1. [GitHub Codespaces](https://github.com/codespaces). You can start editing as soon as VSCode is open. Once you have entered the container, continue to [Developing Locally](#developing-locally). @@ -28,7 +28,7 @@ To build on your own machine without using the Dev Container you will need: ## Developing locally -_**Note:** Unless specified otherwise, you need to run all commands after changing your working directory to this repository - `cd /path/to/csi-driver-image-repository`_ +_**Note:** Unless specified otherwise, you need to run all commands after changing your working directory to this repository - `cd /path/to/container-image-csi-driver-repository`_ 1. First, make sure you can connect to the Kubernetes cluster by following the quickstart guide of your chosen local Kubernetes cluster provider. ``` @@ -36,7 +36,7 @@ _**Note:** Unless specified otherwise, you need to run all commands after changi ``` Make sure you don't see any errors in your terminal. If do get error(s), please check the quickstart guide or the local Kubernetes cluster provider's documentation on how to get started. -1. Install the csi-driver-image using the helm chart. +1. Install the container-image-csi-driver using the helm chart. ``` helm upgrade --install wm-csi \ charts/warm-metal-csi-driver \ diff --git a/go.mod b/go.mod index 3b5fb756..d93901d2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/warm-metal/csi-driver-image +module github.com/warm-metal/container-image-csi-driver go 1.19 @@ -8,9 +8,11 @@ require ( github.com/containerd/containerd v1.6.8 github.com/containers/storage v1.43.0 github.com/golang/protobuf v1.5.2 + github.com/google/uuid v1.2.0 github.com/mitchellh/go-ps v1.0.0 github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 + github.com/prometheus/client_golang v1.12.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.0 github.com/warm-metal/csi-drivers v0.5.0-alpha.0.0.20210404173852-9ec9cb097dd2 @@ -67,7 +69,6 @@ require ( github.com/google/go-cmp v0.5.8 // indirect github.com/google/go-intervals v0.0.2 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.2.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/imdario/mergo v0.3.12 // indirect @@ -93,7 +94,6 @@ require ( github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect diff --git a/pkg/backend/containerd/containerd.go b/pkg/backend/containerd/containerd.go index 6227aaf0..7b154632 100644 --- a/pkg/backend/containerd/containerd.go +++ b/pkg/backend/containerd/containerd.go @@ -13,7 +13,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/containerd/containerd/snapshots" "github.com/opencontainers/image-spec/identity" - "github.com/warm-metal/csi-driver-image/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" "k8s.io/klog/v2" ) diff --git a/pkg/backend/crio/crio.go b/pkg/backend/crio/crio.go index 6c7e3a4d..f7bb9b23 100644 --- a/pkg/backend/crio/crio.go +++ b/pkg/backend/crio/crio.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "net" "net/http" "reflect" @@ -14,7 +13,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/containers/storage" "github.com/containers/storage/types" - "github.com/warm-metal/csi-driver-image/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" "k8s.io/klog/v2" k8smount "k8s.io/utils/mount" ) diff --git a/pkg/mountexecutor/mountexecutor.go b/pkg/mountexecutor/mountexecutor.go index 62548af1..540b8b6f 100644 --- a/pkg/mountexecutor/mountexecutor.go +++ b/pkg/mountexecutor/mountexecutor.go @@ -8,10 +8,10 @@ import ( "github.com/container-storage-interface/spec/lib/go/csi" "github.com/containerd/containerd/reference/docker" - "github.com/warm-metal/csi-driver-image/pkg/backend" - "github.com/warm-metal/csi-driver-image/pkg/metrics" - "github.com/warm-metal/csi-driver-image/pkg/mountstatus" - "github.com/warm-metal/csi-driver-image/pkg/pullstatus" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/mountstatus" + "github.com/warm-metal/container-image-csi-driver/pkg/pullstatus" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" ) @@ -59,7 +59,6 @@ func NewMountExecutor(o *MountExecutorOptions) *MountExecutor { // StartMounting starts the mounting func (m *MountExecutor) StartMounting(o *MountOptions) error { - o.Logger.Info("Mounting image", "image", o.NamedRef.Name()) if pullstatus.Get(o.NamedRef) != pullstatus.Pulled || mountstatus.Get(o.TargetPath) == mountstatus.StillMounting { o.Logger.Info("Could not mount image because image hasn't finshed pulling or volume is still mounting", diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index 301e2167..8ca0f73a 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -8,11 +8,11 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/pkg/errors" - "github.com/warm-metal/csi-driver-image/pkg/backend" - "github.com/warm-metal/csi-driver-image/pkg/metrics" - "github.com/warm-metal/csi-driver-image/pkg/pullstatus" - "github.com/warm-metal/csi-driver-image/pkg/remoteimage" - "github.com/warm-metal/csi-driver-image/pkg/secret" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "github.com/warm-metal/container-image-csi-driver/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/pullstatus" + "github.com/warm-metal/container-image-csi-driver/pkg/remoteimage" + "github.com/warm-metal/container-image-csi-driver/pkg/secret" "k8s.io/apimachinery/pkg/util/wait" cri "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/klog/v2" @@ -67,7 +67,6 @@ func NewPullExecutor(o *PullExecutorOptions) *PullExecutor { // StartPulling starts pulling the image func (m *PullExecutor) StartPulling(o *PullOptions) error { - keyring, err := m.secretStore.GetDockerKeyring(o.Context, o.PullSecrets) if err != nil { return errors.Errorf("unable to fetch keyring: %s", err) diff --git a/pkg/remoteimage/pull_test.go b/pkg/remoteimage/pull_test.go index 0d8809ff..d9b38321 100644 --- a/pkg/remoteimage/pull_test.go +++ b/pkg/remoteimage/pull_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/warm-metal/csi-driver-image/pkg/cri" + "github.com/warm-metal/container-image-csi-driver/pkg/cri" v1 "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/test/e2e/Dockerfile b/test/e2e/Dockerfile index e9cd0b07..a9a026da 100644 --- a/test/e2e/Dockerfile +++ b/test/e2e/Dockerfile @@ -1,6 +1,6 @@ FROM docker.io/library/golang:1.16 -WORKDIR /go/src/csi-driver-image +WORKDIR /go/src/container-image-csi-driver COPY go.mod go.sum ./ RUN go mod download @@ -11,4 +11,4 @@ COPY id_rsa* /root/.ssh/ COPY *.go . -ENTRYPOINT go run . \ No newline at end of file +ENTRYPOINT go run . diff --git a/test/integration/backward-compatability.sh b/test/integration/backward-compatability.sh index c75fb4de..2a48c760 100755 --- a/test/integration/backward-compatability.sh +++ b/test/integration/backward-compatability.sh @@ -2,7 +2,7 @@ set -e source $(dirname "${BASH_SOURCE[0]}")/../../hack/lib/cluster.sh -lib::install_driver_from_manifest_file 'https://raw.githubusercontent.com/warm-metal/csi-driver-image/v0.4.2/install/cri-containerd.yaml' +lib::install_driver_from_manifest_file 'https://raw.githubusercontent.com/warm-metal/container-image-csi-driver/v0.4.2/install/cri-containerd.yaml' TestBase=$(dirname "${BASH_SOURCE[0]}") kubectl apply -f "${TestBase}/compatible-manifests/ephemeral-volume.yaml" @@ -11,7 +11,7 @@ kubectlwait default compatible-ephemeral-volume kubectl apply -f "${TestBase}/compatible-manifests/pre-provisioned-pv.yaml" kubectlwait default compatible-pre-provisioned-pv -kubectl delete --ignore-not-found -f 'https://raw.githubusercontent.com/warm-metal/csi-driver-image/v0.4.2/install/cri-containerd.yaml' +kubectl delete --ignore-not-found -f 'https://raw.githubusercontent.com/warm-metal/container-image-csi-driver/v0.4.2/install/cri-containerd.yaml' export VALUE_FILE=$(dirname "${BASH_SOURCE[0]}")/../../charts/warm-metal-csi-driver/values.yaml export IMAGE_TAG=$(git rev-parse --short HEAD) @@ -35,4 +35,4 @@ kubectl delete -f "${TestBase}/compatible-manifests/ephemeral-volume.yaml" kubectl delete --ignore-not-found -f "${TestBase}/compatible-manifests/pre-provisioned-pv.yaml" helm uninstall -n kube-system ${HELM_NAME} --wait -set +e \ No newline at end of file +set +e diff --git a/test/integration/node-server/README.md b/test/integration/node-server/README.md index 4e42121b..a15c24e1 100644 --- a/test/integration/node-server/README.md +++ b/test/integration/node-server/README.md @@ -1,4 +1,4 @@ -## What is this? +## What is this? This directory contains two files: 1. `docker-compose.yaml`: used to mount workspace on image built using `Dockerfile.containerd` 2. `Dockerfile.containerd`: used to run containerd @@ -26,7 +26,7 @@ For example: $ docker-compose up [+] Building 0.0s (0/0) docker:desktop-linux [+] Running 1/0 - ✔ Container node-server-containerd-workspace-1 Recreated 0.0s + ✔ Container node-server-containerd-workspace-1 Recreated 0.0s Attaching to node-server-containerd-workspace-1 node-server-containerd-workspace-1 | time="2023-11-08T09:03:00Z" level=warning msg="containerd config version `1` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header" node-server-containerd-workspace-1 | time="2023-11-08T09:03:00.484125750Z" level=info msg="starting containerd" revision=61f9fd88f79f081d64d6fa3bb1a0dc71ec870523 version=1.6.24 @@ -51,7 +51,7 @@ $ docker exec -it bash ``` For example: ```shell -$ docker exec -it 7769b9e621f1 bash ~ +$ docker exec -it 7769b9e621f1 bash ~ root@7769b9e621f1:/go# ``` @@ -69,7 +69,7 @@ I1108 10:27:13.225907 19936 mounter.go:45] load 0 snapshots from runtime I1108 10:27:13.235697 19936 server.go:108] Listening for connections on address: &net.UnixAddr{Name:"//csi/csi.sock", Net:"unix"} ... PASS -ok github.com/warm-metal/csi-driver-image/cmd/plugin 46.711s +ok github.com/warm-metal/container-image-csi-driver/cmd/plugin 46.711s ``` **To test `TestPull`**: @@ -78,6 +78,6 @@ ok github.com/warm-metal/csi-driver-image/cmd/plugin 46.711s root@cdf7ee254501:~# cd /code/pkg/remoteimage root@cdf7ee254501:/code/pkg/remoteimage# go test -run 'TestPull' PASS -ok github.com/warm-metal/csi-driver-image/pkg/remoteimage 2.247s +ok github.com/warm-metal/container-image-csi-driver/pkg/remoteimage 2.247s root@cdf7ee254501:/code/pkg/remoteimage# -``` \ No newline at end of file +``` diff --git a/test/sanity/Dockerfile b/test/sanity/Dockerfile index d49b7047..0d3e4195 100644 --- a/test/sanity/Dockerfile +++ b/test/sanity/Dockerfile @@ -1,10 +1,10 @@ FROM docker.io/library/golang:1.16 -WORKDIR /go/src/csi-driver-image +WORKDIR /go/src/container-image-csi-driver COPY go.mod go.sum ./ RUN go mod download COPY sanity_test.go . -CMD go test -v ./... -ginkgo.skip='.*\[Controller\s+Server\].*' \ No newline at end of file +CMD go test -v ./... -ginkgo.skip='.*\[Controller\s+Server\].*' From 637e8896f15b5c4610a8bdf9a1106a5e32b45ec5 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Mon, 22 Jan 2024 20:03:58 +0530 Subject: [PATCH 27/32] chore: update test manifests with new repo name (#129) --- .github/workflows/cri-o.yaml | 2 +- .github/workflows/restart-ds-crio.yaml | 2 +- Makefile | 4 ++-- test/e2e/manifest.yaml | 16 ++++++++-------- test/integration/test-in-kind-crio.sh | 4 ++-- test/sanity/manifest.yaml | 8 ++++---- test/unit/manifest.yaml | 8 ++++---- test/unit/skaffold.yaml | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/cri-o.yaml b/.github/workflows/cri-o.yaml index ef32298f..ca6a3bcd 100644 --- a/.github/workflows/cri-o.yaml +++ b/.github/workflows/cri-o.yaml @@ -15,7 +15,7 @@ jobs: with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" - node_image: "docker.io/warmmetal/kindest-node-crio:v1.25.2-csi-driver-image" + node_image: "docker.io/warmmetal/kindest-node-crio:v1.25.2-container-image-csi-driver" - name: Install private registry run: ./hack/ci/setup_private_registry.sh - name: Build image diff --git a/.github/workflows/restart-ds-crio.yaml b/.github/workflows/restart-ds-crio.yaml index ab99760c..855ec852 100644 --- a/.github/workflows/restart-ds-crio.yaml +++ b/.github/workflows/restart-ds-crio.yaml @@ -15,7 +15,7 @@ jobs: with: cluster_name: kind-${{ github.run_id }} kubectl_version: "v1.25.2" - node_image: "docker.io/warmmetal/kindest-node-crio:v1.25.2-csi-driver-image" + node_image: "docker.io/warmmetal/kindest-node-crio:v1.25.2-container-image-csi-driver" - name: Build image run: ./hack/ci/build.sh - name: Set image version diff --git a/Makefile b/Makefile index 5c6c6472..782f0b61 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,10 @@ build: .PHONY: sanity sanity: - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build -t local.test/csi-driver-image-test:sanity test/sanity + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build -t local.test/container-image-csi-driver-test:sanity test/sanity kubectl delete --ignore-not-found -f test/sanity/manifest.yaml kubectl apply --wait -f test/sanity/manifest.yaml - kubectl -n cliapp-system wait --for=condition=complete job/csi-driver-image-sanity-test + kubectl -n cliapp-system wait --for=condition=complete job/container-image-csi-driver-sanity-test .PHONY: e2e e2e: diff --git a/test/e2e/manifest.yaml b/test/e2e/manifest.yaml index fcf65627..9766cb07 100644 --- a/test/e2e/manifest.yaml +++ b/test/e2e/manifest.yaml @@ -1,36 +1,36 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: csi-driver-image-e2e-test + name: container-image-csi-driver-e2e-test namespace: cliapp-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: csi-driver-image-e2e-test + name: container-image-csi-driver-e2e-test roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount - name: csi-driver-image-e2e-test + name: container-image-csi-driver-e2e-test namespace: cliapp-system --- apiVersion: batch/v1 kind: Job metadata: - name: csi-driver-image-e2e-test + name: container-image-csi-driver-e2e-test namespace: cliapp-system spec: template: metadata: - name: csi-driver-image-e2e-test + name: container-image-csi-driver-e2e-test spec: - serviceAccountName: csi-driver-image-e2e-test + serviceAccountName: container-image-csi-driver-e2e-test containers: - - name: csi-driver-image-e2e-test - image: local.test/csi-driver-image-test:e2e + - name: container-image-csi-driver-e2e-test + image: local.test/container-image-csi-driver-test:e2e env: - name: KUBE_SSH_USER value: docker diff --git a/test/integration/test-in-kind-crio.sh b/test/integration/test-in-kind-crio.sh index 4f79d77f..5778ce37 100755 --- a/test/integration/test-in-kind-crio.sh +++ b/test/integration/test-in-kind-crio.sh @@ -4,7 +4,7 @@ set -e export IMAGE_TAG=v0.7.0 export GITHUB_RUN_ID=1 -export NODE_IMAGE=docker.io/warmmetal/kindest-node-crio:v1.25.2-csi-driver-image +export NODE_IMAGE=docker.io/warmmetal/kindest-node-crio:v1.25.2-container-image-csi-driver export VALUE_FILE=$(dirname "${BASH_SOURCE[0]}")/crio-helm-values.yaml HELM_NAME='wm-csi-integration-tests' @@ -29,4 +29,4 @@ $(dirname "${BASH_SOURCE[0]}")/../../hack/ci/test.sh helm uninstall -n kube-system ${HELM_NAME} --wait -set +e \ No newline at end of file +set +e diff --git a/test/sanity/manifest.yaml b/test/sanity/manifest.yaml index 0ee3f12d..29d3a862 100644 --- a/test/sanity/manifest.yaml +++ b/test/sanity/manifest.yaml @@ -1,17 +1,17 @@ apiVersion: batch/v1 kind: Job metadata: - name: csi-driver-image-sanity-test + name: container-image-csi-driver-sanity-test namespace: cliapp-system spec: template: metadata: - name: csi-driver-image-sanity-test + name: container-image-csi-driver-sanity-test spec: serviceAccountName: csi-image-warm-metal containers: - - name: csi-driver-image-sanity-test - image: local.test/csi-driver-image-test:sanity + - name: container-image-csi-driver-sanity-test + image: local.test/container-image-csi-driver-test:sanity volumeMounts: - mountPath: /csi name: socket-dir diff --git a/test/unit/manifest.yaml b/test/unit/manifest.yaml index 85da70ce..07f59550 100644 --- a/test/unit/manifest.yaml +++ b/test/unit/manifest.yaml @@ -1,17 +1,17 @@ apiVersion: batch/v1 kind: Job metadata: - name: csi-driver-image-test + name: container-image-csi-driver-test namespace: kube-system spec: template: metadata: - name: csi-driver-image-test + name: container-image-csi-driver-test spec: serviceAccountName: csi-image-warm-metal containers: - - name: csi-driver-image-test - image: warmmetal/csi-driver-image-test + - name: container-image-csi-driver-test + image: warmmetal/container-image-csi-driver-test env: - name: HTTP_PROXY value: http://192.168.64.1:1087 diff --git a/test/unit/skaffold.yaml b/test/unit/skaffold.yaml index 3b748817..ada165a5 100644 --- a/test/unit/skaffold.yaml +++ b/test/unit/skaffold.yaml @@ -7,7 +7,7 @@ build: - image: warmmetal/csi-image docker: dockerfile: Dockerfile - - image: warmmetal/csi-driver-image-test + - image: warmmetal/container-image-csi-driver-test docker: dockerfile: "test.dockerfile" # custom: From 9498bb68fb4866e3fa28b15d4f46d880df3552f2 Mon Sep 17 00:00:00 2001 From: Mugdha Adhav Date: Mon, 22 Jan 2024 20:30:30 +0530 Subject: [PATCH 28/32] chore: update names of test images and its refs (#130) --- Makefile | 12 ++++---- README.md | 8 +++--- hack/ci/setup_docker_cluster.sh | 6 ++-- hack/ci/setup_private_registry.sh | 6 ++-- hack/helper/prepare_containerd_cluster.sh | 8 +++--- ...image-csi-driver-test:check-fs.dockerfile} | 0 ...mage-csi-driver-test:simple-fs.dockerfile} | 0 ...-image-csi-driver-test:stat-fs.dockerfile} | 0 ...ge-csi-driver-test:write-check.dockerfile} | 4 +-- hack/lib/cluster.sh | 8 +++--- sample/ephemeral-volume.yaml | 4 +-- sample/pre-provisioned-pv.yaml | 12 ++++---- test/e2e/driver.go | 12 ++++---- .../ephemeral-volume.yaml | 6 ++-- .../pre-provisioned-pv.yaml | 10 +++---- ...ral-volume-private-with-daemon-secret.yaml | 4 +-- ...isioned-pv-private-with-daemon-secret.yaml | 4 +-- test/integration/failed-manifests/rwo-pv.yaml | 6 ++-- test/integration/failed-manifests/rwx-pv.yaml | 6 ++-- ...ephemeral-volume-docker-library-image.yaml | 4 +-- ...eral-volume-private-with-given-secret.yaml | 4 +-- .../manifests/ephemeral-volume.yaml | 4 +-- ...visioned-pv-private-with-given-secret.yaml | 4 +-- .../manifests/pre-provisioned-pv.yaml | 12 ++++---- .../manifests/readonly-ephemeral-volume.yaml | 4 +-- .../readonly-mount-ephemeral-volume.yaml | 4 +-- .../manifests/readonly-mount-pre-pv.yaml | 12 ++++---- .../two-readonly-ephemeral-volume.yaml | 6 ++-- .../manifests/two-readonly-pv.yaml | 22 +++++++-------- .../manifests/two-readonly-single-pv.yaml | 8 +++--- .../manual-manifests/write-check.yaml | 8 +++--- .../error-ephemeral-volume.yaml | 6 ++-- .../no-error-ephemeral-volume.yaml | 6 ++-- test/integration/restart-runtime.sh | 28 +++++++++---------- .../test-backward-compatability.sh | 6 ++-- test/integration/test-in-kind-containerd.sh | 4 +-- test/integration/test-in-kind-crio.sh | 2 +- .../test-in-minikube-containerd.sh | 4 +-- test/integration/test-in-minikube-cri-o.sh | 10 +++---- test/integration/test-in-minikube-docker.sh | 10 +++---- .../integration/test-restart-ds-containerd.sh | 6 ++-- test/integration/test-restart-ds-crio.sh | 6 ++-- .../test-restart-runtime-containerd.sh | 12 ++++---- test/integration/test-restart-runtime-crio.sh | 12 ++++---- 44 files changed, 160 insertions(+), 160 deletions(-) rename hack/integration-test-image/{csi-image-test:check-fs.dockerfile => container-image-csi-driver-test:check-fs.dockerfile} (100%) rename hack/integration-test-image/{csi-image-test:simple-fs.dockerfile => container-image-csi-driver-test:simple-fs.dockerfile} (100%) rename hack/integration-test-image/{csi-image-test:stat-fs.dockerfile => container-image-csi-driver-test:stat-fs.dockerfile} (100%) rename hack/integration-test-image/{csi-image-test:write-check.dockerfile => container-image-csi-driver-test:write-check.dockerfile} (60%) diff --git a/Makefile b/Makefile index 782f0b61..3df76684 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ VERSION ?= v1.1.0 IMAGE_BUILDER ?= docker IMAGE_BUILD_CMD ?= buildx REGISTRY ?= docker.io/warmmetal +PLATFORM ?= linux/amd64 export IMG = $(REGISTRY)/csi-image:$(VERSION) @@ -35,17 +36,18 @@ integration: .PHONY: image image: - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build -t $(REGISTRY)/csi-image:$(VERSION) --push . + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/csi-image:$(VERSION) --push . .PHONY: local local: - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build -t $(REGISTRY)/csi-image:$(VERSION) --load . + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/csi-image:$(VERSION) --load . .PHONY: test-deps test-deps: - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --push -t $(REGISTRY)/csi-image-test:stat-fs -f csi-image-test:stat-fs.dockerfile hack/integration-test-image - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --push -t $(REGISTRY)/csi-image-test:check-fs -f csi-image-test:check-fs.dockerfile hack/integration-test-image - $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --push -t $(REGISTRY)/csi-image-test:write-check -f csi-image-test:write-check.dockerfile hack/integration-test-image + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) --push -t $(REGISTRY)/container-image-csi-driver-test:simple-fs -f hack/integration-test-image/container-image-csi-driver-test:simple-fs.dockerfile hack/integration-test-image + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) --push -t $(REGISTRY)/container-image-csi-driver-test:stat-fs -f hack/integration-test-image/container-image-csi-driver-test:stat-fs.dockerfile hack/integration-test-image + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) --push -t $(REGISTRY)/container-image-csi-driver-test:check-fs -f hack/integration-test-image/container-image-csi-driver-test:check-fs.dockerfile hack/integration-test-image + $(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) --push -t $(REGISTRY)/container-image-csi-driver-test:write-check -f hack/integration-test-image/container-image-csi-driver-test:write-check.dockerfile hack/integration-test-image .PHONY: install-util install-util: diff --git a/README.md b/README.md index b275a9b1..cb61bc2b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ spec: spec: containers: - name: ephemeral-volume - image: docker.io/warmmetal/csi-image-test:check-fs + image: docker.io/warmmetal/container-image-csi-driver-test:check-fs env: - name: TARGET value: /target @@ -120,7 +120,7 @@ spec: # nodePublishSecretRef: # name: "ImagePullSecret name in the same namespace" volumeAttributes: - image: "docker.io/warmmetal/csi-image-test:simple-fs" + image: "docker.io/warmmetal/container-image-csi-driver-test:simple-fs" # # set pullAlways if you want to ignore local images # pullAlways: "true" backoffLimit: 0 @@ -133,7 +133,7 @@ For pre-provisioned PVs, `volumeHandle` instead of the attribute **image**, spec apiVersion: v1 kind: PersistentVolume metadata: - name: pv-test-csi-image-test-simple-fs + name: pv-test-container-image-csi-driver-test-simple-fs spec: storageClassName: csi-image.warm-metal.tech capacity: @@ -143,7 +143,7 @@ spec: persistentVolumeReclaimPolicy: Retain csi: driver: csi-image.warm-metal.tech - volumeHandle: "docker.io/warmmetal/csi-image-test:simple-fs" + volumeHandle: "docker.io/warmmetal/container-image-csi-driver-test:simple-fs" # nodePublishSecretRef: # name: "name of the ImagePullSecret" # namespace: "namespace of the secret" diff --git a/hack/ci/setup_docker_cluster.sh b/hack/ci/setup_docker_cluster.sh index 916a8ec3..78a07480 100755 --- a/hack/ci/setup_docker_cluster.sh +++ b/hack/ci/setup_docker_cluster.sh @@ -7,7 +7,7 @@ lib::start_cluster_docker $@ set -e echo "Install a private registry" lib::install_private_registry -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i pull docker.io/warmmetal/csi-image-test:simple-fs -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i tag --force docker.io/warmmetal/csi-image-test:simple-fs localhost:31000/warmmetal/csi-image-test:simple-fs -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i push localhost:31000/warmmetal/csi-image-test:simple-fs --plain-http --user warmmetal:warmmetal +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i pull docker.io/warmmetal/container-image-csi-driver-test:simple-fs +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i tag --force docker.io/warmmetal/container-image-csi-driver-test:simple-fs localhost:31000/warmmetal/container-image-csi-driver-test:simple-fs +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i push localhost:31000/warmmetal/container-image-csi-driver-test:simple-fs --plain-http --user warmmetal:warmmetal set +e diff --git a/hack/ci/setup_private_registry.sh b/hack/ci/setup_private_registry.sh index 138e21c3..c4fa4714 100755 --- a/hack/ci/setup_private_registry.sh +++ b/hack/ci/setup_private_registry.sh @@ -5,8 +5,8 @@ source $(dirname "$0")/../lib/cluster.sh set -e echo "Install a private registry" lib::install_private_registry -docker pull docker.io/warmmetal/csi-image-test:simple-fs -docker tag docker.io/warmmetal/csi-image-test:simple-fs localhost:5000/warmmetal/csi-image-test:simple-fs +docker pull docker.io/warmmetal/container-image-csi-driver-test:simple-fs +docker tag docker.io/warmmetal/container-image-csi-driver-test:simple-fs localhost:5000/warmmetal/container-image-csi-driver-test:simple-fs docker login -u warmmetal -p warmmetal localhost:5000 -docker push localhost:5000/warmmetal/csi-image-test:simple-fs +docker push localhost:5000/warmmetal/container-image-csi-driver-test:simple-fs set +e diff --git a/hack/helper/prepare_containerd_cluster.sh b/hack/helper/prepare_containerd_cluster.sh index 7a4cc2e7..dba39c18 100755 --- a/hack/helper/prepare_containerd_cluster.sh +++ b/hack/helper/prepare_containerd_cluster.sh @@ -11,9 +11,9 @@ lib::install_driver echo "Install a private registry" lib::install_private_registry -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i pull docker.io/warmmetal/csi-image-test:simple-fs -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i tag --force docker.io/warmmetal/csi-image-test:simple-fs localhost:31000/warmmetal/csi-image-test:simple-fs -minikube ssh -p csi-image-test -- sudo ctr -n k8s.io i push localhost:31000/warmmetal/csi-image-test:simple-fs --plain-http --user warmmetal:warmmetal +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i pull docker.io/warmmetal/container-image-csi-driver-test:simple-fs +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i tag --force docker.io/warmmetal/container-image-csi-driver-test:simple-fs localhost:31000/warmmetal/container-image-csi-driver-test:simple-fs +minikube ssh -p container-image-csi-driver-test -- sudo ctr -n k8s.io i push localhost:31000/warmmetal/container-image-csi-driver-test:simple-fs --plain-http --user warmmetal:warmmetal set +x -set +e \ No newline at end of file +set +e diff --git a/hack/integration-test-image/csi-image-test:check-fs.dockerfile b/hack/integration-test-image/container-image-csi-driver-test:check-fs.dockerfile similarity index 100% rename from hack/integration-test-image/csi-image-test:check-fs.dockerfile rename to hack/integration-test-image/container-image-csi-driver-test:check-fs.dockerfile diff --git a/hack/integration-test-image/csi-image-test:simple-fs.dockerfile b/hack/integration-test-image/container-image-csi-driver-test:simple-fs.dockerfile similarity index 100% rename from hack/integration-test-image/csi-image-test:simple-fs.dockerfile rename to hack/integration-test-image/container-image-csi-driver-test:simple-fs.dockerfile diff --git a/hack/integration-test-image/csi-image-test:stat-fs.dockerfile b/hack/integration-test-image/container-image-csi-driver-test:stat-fs.dockerfile similarity index 100% rename from hack/integration-test-image/csi-image-test:stat-fs.dockerfile rename to hack/integration-test-image/container-image-csi-driver-test:stat-fs.dockerfile diff --git a/hack/integration-test-image/csi-image-test:write-check.dockerfile b/hack/integration-test-image/container-image-csi-driver-test:write-check.dockerfile similarity index 60% rename from hack/integration-test-image/csi-image-test:write-check.dockerfile rename to hack/integration-test-image/container-image-csi-driver-test:write-check.dockerfile index d09e92f2..084f776f 100644 --- a/hack/integration-test-image/csi-image-test:write-check.dockerfile +++ b/hack/integration-test-image/container-image-csi-driver-test:write-check.dockerfile @@ -1,10 +1,10 @@ FROM docker.io/library/golang:1.16-alpine as builder -WORKDIR /go/src/csi-image-test +WORKDIR /go/src/container-image-csi-driver-test COPY write_check.go . RUN GO111MODULE=off go build -o write_check FROM alpine:3 ENV TARGET="" WORKDIR / -COPY --from=builder /go/src/csi-image-test/write_check . +COPY --from=builder /go/src/container-image-csi-driver-test/write_check . ENTRYPOINT ["/write_check"] diff --git a/hack/lib/cluster.sh b/hack/lib/cluster.sh index f8ecbea7..4ae2504d 100755 --- a/hack/lib/cluster.sh +++ b/hack/lib/cluster.sh @@ -4,7 +4,7 @@ source $(dirname "${BASH_SOURCE[0]}")/utils.sh function lib::start_cluster_containerd() { local version=${1:-stable} - minikube start -p csi-image-test \ + minikube start -p container-image-csi-driver-test \ --kubernetes-version=${version} \ --container-runtime=containerd \ --insecure-registry=localhost:31000 @@ -12,7 +12,7 @@ function lib::start_cluster_containerd() { function lib::start_cluster_crio() { local version=${1:-stable} - minikube start -p csi-image-test \ + minikube start -p container-image-csi-driver-test \ --kubernetes-version=${version} \ --container-runtime=cri-o \ --insecure-registry=localhost:31000 @@ -20,7 +20,7 @@ function lib::start_cluster_crio() { function lib::start_cluster_docker() { local version=${1:-stable} - minikube start -p csi-image-test \ + minikube start -p container-image-csi-driver-test \ --kubernetes-version=${version} \ --container-runtime=docker \ --insecure-registry=localhost:31000 @@ -101,7 +101,7 @@ function lib::install_private_registry() { if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' 'private-registry')" = 'null' ]; then docker network connect "kind" "private-registry" fi - + cat < Date: Sat, 3 Feb 2024 23:44:40 +0530 Subject: [PATCH 29/32] fix: remove node driver registrar lifecycle hook (#70) --- charts/warm-metal-csi-driver/templates/nodeplugin.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml index 9918a5a1..a65aaddd 100644 --- a/charts/warm-metal-csi-driver/templates/nodeplugin.yaml +++ b/charts/warm-metal-csi-driver/templates/nodeplugin.yaml @@ -31,13 +31,6 @@ spec: fieldPath: spec.nodeName image: "{{ .Values.csiNodeDriverRegistrar.image.repository }}:{{ .Values.csiNodeDriverRegistrar.image.tag }}" imagePullPolicy: {{ .Values.csiNodeDriverRegistrar.image.pullPolicy }} - lifecycle: - preStop: - exec: - command: - - /bin/sh - - -c - - rm -rf /registration/csi-image.warm-metal.tech /registration/csi-image.warm-metal.tech-reg.sock {{- with .Values.csiNodeDriverRegistrar.resources }} resources: {{- toYaml . | nindent 12 }} From 4d6fa737fd34de25b433f06291443440edd92d42 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Fri, 9 Feb 2024 00:57:47 +0530 Subject: [PATCH 30/32] =?UTF-8?q?=F0=9F=91=B7=20build(devcontainer):=20Fix?= =?UTF-8?q?=20issue=20with=20multi-architecture=20(#140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 👷 build(devcontainer): Update names * 👷 build(devcontainer): Build for amd64 and arm64 * 📝 docs(local): Add link to devcontainers Signed-off-by: Mriyam Tamuli --- .devcontainer/devcontainer.json | 8 +++--- .devcontainer/welcome.txt | 2 +- .github/.devcontainer/Dockerfile | 1 + .github/.devcontainer/devcontainer.json | 11 ++++++-- .../devcontainer-build-and-push.yaml | 25 ++++++++++++++++--- docs/running-locally.md | 2 +- 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 .github/.devcontainer/Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 169a22c7..3d4c7ff7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,11 @@ // For format details, see https://containers.dev { - "name": "csi-driver-image dev container", - "image": "ghcr.io/warm-metal/csi-driver-image/devcontainer:latest", + "name": "container-image-csi-driver dev container", + "image": "ghcr.io/warm-metal/container-image-csi-driver/devcontainer:latest", // Setup the go environment and mount into the dev container at the expected location - "workspaceFolder": "/go/src/github.com/warm-metal/csi-driver-image", - "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/warm-metal/csi-driver-image,type=bind,consistency=cached", + "workspaceFolder": "/go/src/github.com/warm-metal/container-image-csi-driver", + "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/warm-metal/container-image-csi-driver,type=bind,consistency=cached", // Copy over welcome message "postCreateCommand": "sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/welcome.txt b/.devcontainer/welcome.txt index 7ba0b745..18b9c34a 100644 --- a/.devcontainer/welcome.txt +++ b/.devcontainer/welcome.txt @@ -1,4 +1,4 @@ -👋 Welcome to your development environment for CSI Driver Image! +👋 Welcome to your development environment for Container Image CSI Driver! This debian dev container image contains all tools needed for development. diff --git a/.github/.devcontainer/Dockerfile b/.github/.devcontainer/Dockerfile new file mode 100644 index 00000000..88cae803 --- /dev/null +++ b/.github/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu diff --git a/.github/.devcontainer/devcontainer.json b/.github/.devcontainer/devcontainer.json index ce3721e4..b444b86d 100644 --- a/.github/.devcontainer/devcontainer.json +++ b/.github/.devcontainer/devcontainer.json @@ -1,7 +1,14 @@ // For format details, see https://containers.dev { - "name": "csi-driver-image dev container", - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "name": "container-image-csi-driver dev container", + // Workaround as mentioned in + // https://github.com/devcontainers/ci/issues/191#issuecomment-1473518609 + + //"image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, "otherPortsAttributes": { "onAutoForward": "silent" diff --git a/.github/workflows/devcontainer-build-and-push.yaml b/.github/workflows/devcontainer-build-and-push.yaml index 4d6c408d..bca90391 100644 --- a/.github/workflows/devcontainer-build-and-push.yaml +++ b/.github/workflows/devcontainer-build-and-push.yaml @@ -4,11 +4,11 @@ on: push: branches: [main] paths: - - .github/workflows/devcontainer-build-and-push.yml + - .github/workflows/devcontainer-build-and-push.yaml - '.github/.devcontainer/**' pull_request: paths: - - .github/workflows/devcontainer-build-and-push.yml + - .github/workflows/devcontainer-build-and-push.yaml - '.github/.devcontainer/**' permissions: @@ -21,18 +21,35 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to the GitHub Container registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Install updated skopeo + # https://github.com/devcontainers/ci/issues/191#issuecomment-1416384710 + run: | + sudo apt purge buildah golang-github-containers-common podman skopeo + sudo apt autoremove --purge + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable" + source /etc/os-release + sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" + sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key + sudo apt-key add Release.key + sudo apt-get update + sudo apt-get install skopeo -y - name: Pre-build dev container image uses: devcontainers/ci@v0.3 with: subFolder: .github imageName: ghcr.io/${{ github.repository }}/devcontainer cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + platform: linux/amd64,linux/arm64 push: always diff --git a/docs/running-locally.md b/docs/running-locally.md index 2bfbbc6a..aecae44c 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -7,7 +7,7 @@ You have two options: ## Development Container -The development container contains all the tools necessary to work with container-image-csi-driver. +The [development container](https://containers.dev) contains all the tools necessary to work with container-image-csi-driver. You can use the development container in a few different ways: From 82d2e856a589650433b58e26c5d35da201e4ca0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suraj=20Banakar=28=E0=A4=AC=E0=A4=BE=E0=A4=A8=E0=A4=95?= =?UTF-8?q?=E0=A4=B0=29=20=7C=20=E3=82=B9=E3=83=A9=E3=82=B8?= Date: Wed, 14 Feb 2024 14:43:45 +0530 Subject: [PATCH 31/32] test: use mock puller and mounter in the node server tests (#83) * edit: docs to run node server with containerd image * refactor: remove commented out code * chore: switch over from criapi `v1alpha2` -> `v1` * chore: fix import path name `csi-driver-image` -> `container-image-csi-driver` * docs: replace `warm metal` -> `container-image-csi-driver` * test: fix socket path `/tmp/csi/csi.sock` -> `/tmp/csi.sock` --- Makefile | 9 ++ cmd/plugin/main.go | 2 +- cmd/plugin/node_server.go | 4 +- cmd/plugin/node_server_test.go | 67 ++++++----- pkg/backend/containerd/containerd.go | 2 +- pkg/backend/mounter.go | 12 +- pkg/backend/runtime.go | 16 ++- pkg/mountexecutor/mountexecutor.go | 4 +- pkg/pullexecutor/pullexecutor.go | 4 +- pkg/test/utils/utils.go | 111 ++++++++++++++++++ .../node-server/Dockerfile.containerd | 0 test/{integration => }/node-server/README.md | 31 +---- .../node-server/docker-compose.yaml | 0 13 files changed, 186 insertions(+), 76 deletions(-) create mode 100644 pkg/test/utils/utils.go rename test/{integration => }/node-server/Dockerfile.containerd (100%) rename test/{integration => }/node-server/README.md (61%) rename test/{integration => }/node-server/docker-compose.yaml (100%) diff --git a/Makefile b/Makefile index 3df76684..c10cca6d 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,15 @@ sanity: e2e: cd ./test/e2e && KUBECONFIG=~/.kube/config go run . +# to run unit tests +# PHONY signifies the make recipe is not a file +# more info: https://stackoverflow.com/questions/2145590/what-is-the-purpose-of-phony-in-a-makefile +.PHONY: unit-tests +unit-tests: + # -count=1 forces re-test everytime (instead of caching the results) + # more info: https://stackoverflow.com/questions/48882691/force-retesting-or-disable-test-caching + go test -count=1 ./cmd/plugin + .PHONY: integration integration: ./test/integration/test-backward-compatability.sh diff --git a/cmd/plugin/main.go b/cmd/plugin/main.go index 28b5e4ee..4e2994f2 100644 --- a/cmd/plugin/main.go +++ b/cmd/plugin/main.go @@ -98,7 +98,7 @@ func main() { *runtimeAddr = addr.String() } - var mounter *backend.SnapshotMounter + var mounter backend.Mounter if len(*runtimeAddr) > 0 { addr, err := url.Parse(*runtimeAddr) if err != nil { diff --git a/cmd/plugin/node_server.go b/cmd/plugin/node_server.go index 84baf1ab..109eb5c3 100644 --- a/cmd/plugin/node_server.go +++ b/cmd/plugin/node_server.go @@ -31,7 +31,7 @@ const ( type ImagePullStatus int -func NewNodeServer(driver *csicommon.CSIDriver, mounter *backend.SnapshotMounter, imageSvc cri.ImageServiceClient, secretStore secret.Store, asyncImagePullMount bool) *NodeServer { +func NewNodeServer(driver *csicommon.CSIDriver, mounter backend.Mounter, imageSvc cri.ImageServiceClient, secretStore secret.Store, asyncImagePullMount bool) *NodeServer { return &NodeServer{ DefaultNodeServer: csicommon.NewDefaultNodeServer(driver), mounter: mounter, @@ -52,7 +52,7 @@ func NewNodeServer(driver *csicommon.CSIDriver, mounter *backend.SnapshotMounter type NodeServer struct { *csicommon.DefaultNodeServer - mounter *backend.SnapshotMounter + mounter backend.Mounter secretStore secret.Store asyncImagePullMount bool mountExecutor *mountexecutor.MountExecutor diff --git a/cmd/plugin/node_server_test.go b/cmd/plugin/node_server_test.go index e6aca0bb..5db8ac49 100644 --- a/cmd/plugin/node_server_test.go +++ b/cmd/plugin/node_server_test.go @@ -19,6 +19,7 @@ import ( "github.com/warm-metal/container-image-csi-driver/pkg/backend/containerd" "github.com/warm-metal/container-image-csi-driver/pkg/cri" "github.com/warm-metal/container-image-csi-driver/pkg/metrics" + "github.com/warm-metal/container-image-csi-driver/pkg/test/utils" csicommon "github.com/warm-metal/csi-drivers/pkg/csi-common" "google.golang.org/grpc" "k8s.io/apimachinery/pkg/util/wait" @@ -26,18 +27,16 @@ import ( "k8s.io/kubernetes/pkg/credentialprovider" ) -// Check test/integration/node-server/README.md for how to run this test correctly func TestNodePublishVolumeAsync(t *testing.T) { - socketAddr := "unix:///run/containerd/containerd.sock" - addr, err := url.Parse(socketAddr) - assert.NoError(t, err) - - criClient, err := cri.NewRemoteImageService(socketAddr, time.Minute) - assert.NoError(t, err) - assert.NotNil(t, criClient) + criClient := &utils.MockImageServiceClient{ + PulledImages: make(map[string]bool), + ImagePullTime: time.Second * 5, + } - mounter := containerd.NewMounter(addr.Path) - assert.NotNil(t, mounter) + mounter := &utils.MockMounter{ + ImageSvcClient: *criClient, + Mounted: make(map[string]bool), + } driver := csicommon.NewCSIDriver(driverName, driverVersion, "fake-node") assert.NotNil(t, driver) @@ -71,20 +70,23 @@ func TestNodePublishVolumeAsync(t *testing.T) { server := csicommon.NewNonBlockingGRPCServer() - addr, err = url.Parse(*endpoint) - assert.NoError(t, err) - - os.Remove("/csi/csi.sock") + endpoint := "unix:///tmp/csi.sock" // automatically deleted when the server is stopped - f, err := os.Create("/csi/csi.sock") + f, err := os.Create("/tmp/csi.sock") assert.NoError(t, err) assert.NotNil(t, f) + defer os.Remove("/tmp/csi.sock") + + addr, err := url.Parse("unix:///tmp/csi.sock") + assert.NoError(t, err) + var wg sync.WaitGroup wg.Add(1) go func() { - server.Start(*endpoint, + + server.Start(endpoint, nil, nil, ns) @@ -154,16 +156,14 @@ func TestNodePublishVolumeAsync(t *testing.T) { // Check test/integration/node-server/README.md for how to run this test correctly func TestNodePublishVolumeSync(t *testing.T) { - socketAddr := "unix:///run/containerd/containerd.sock" - addr, err := url.Parse(socketAddr) - assert.NoError(t, err) - - criClient, err := cri.NewRemoteImageService(socketAddr, time.Minute) - assert.NoError(t, err) - assert.NotNil(t, criClient) - - mounter := containerd.NewMounter(addr.Path) - assert.NotNil(t, mounter) + criClient := &utils.MockImageServiceClient{ + PulledImages: make(map[string]bool), + ImagePullTime: time.Second * 5, + } + mounter := &utils.MockMounter{ + ImageSvcClient: *criClient, + Mounted: make(map[string]bool), + } driver := csicommon.NewCSIDriver(driverName, driverVersion, "fake-node") assert.NotNil(t, driver) @@ -197,20 +197,23 @@ func TestNodePublishVolumeSync(t *testing.T) { server := csicommon.NewNonBlockingGRPCServer() - addr, err = url.Parse(*endpoint) - assert.NoError(t, err) - - os.Remove("/csi/csi.sock") + endpoint := "unix:///tmp/csi.sock" // automatically deleted when the server is stopped - f, err := os.Create("/csi/csi.sock") + f, err := os.Create("/tmp/csi.sock") assert.NoError(t, err) assert.NotNil(t, f) + defer os.Remove("/tmp/csi/csi.sock") + + addr, err := url.Parse("unix:///tmp/csi.sock") + assert.NoError(t, err) + var wg sync.WaitGroup wg.Add(1) go func() { - server.Start(*endpoint, + + server.Start(endpoint, nil, nil, ns) diff --git a/pkg/backend/containerd/containerd.go b/pkg/backend/containerd/containerd.go index 7b154632..8dfcdd3d 100644 --- a/pkg/backend/containerd/containerd.go +++ b/pkg/backend/containerd/containerd.go @@ -22,7 +22,7 @@ type snapshotMounter struct { cli *containerd.Client } -func NewMounter(socketPath string) *backend.SnapshotMounter { +func NewMounter(socketPath string) backend.Mounter { c, err := containerd.New(socketPath, containerd.WithDefaultNamespace("k8s.io")) if err != nil { klog.Fatalf("containerd connection is broken because the mounted unix socket somehow dose not work,"+ diff --git a/pkg/backend/mounter.go b/pkg/backend/mounter.go index 88717589..59a126fe 100644 --- a/pkg/backend/mounter.go +++ b/pkg/backend/mounter.go @@ -12,7 +12,7 @@ import ( ) type SnapshotMounter struct { - runtime ContainerRuntime + runtime ContainerRuntimeMounter guard sync.Mutex // mapping from targets to key of read-only snapshots @@ -21,7 +21,7 @@ type SnapshotMounter struct { roSnapshotTargetsMap map[SnapshotKey]map[MountTarget]struct{} } -func NewMounter(runtime ContainerRuntime) *SnapshotMounter { +func NewMounter(runtime ContainerRuntimeMounter) *SnapshotMounter { mounter := &SnapshotMounter{ runtime: runtime, targetRoSnapshotMap: make(map[MountTarget]SnapshotKey), @@ -173,7 +173,7 @@ func (s *SnapshotMounter) Mount( klog.Fatalf("invalid image id of image %q", image) } - key = genSnapshotKey(imageID) + key = GenSnapshotKey(imageID) klog.Infof("refer read-only snapshot of image %q with key %q", image, key) if err := s.refROSnapshot(ctx, target, imageID, key, createSnapshotMetaData(target)); err != nil { return err @@ -189,7 +189,7 @@ func (s *SnapshotMounter) Mount( }() } else { // For read-write volumes, they must be ephemeral volumes, that which volumeIDs are unique strings. - key = genSnapshotKey(volumeId) + key = GenSnapshotKey(volumeId) klog.Infof("create read-write snapshot of image %q with key %q", image, key) if err := s.runtime.PrepareRWSnapshot(ctx, imageID, key, nil); err != nil { return err @@ -221,13 +221,13 @@ func (s *SnapshotMounter) Unmount(ctx context.Context, volumeId string, target M klog.Infof("delete the read-write snapshot") // Must be a read-write snapshot - return s.runtime.DestroySnapshot(ctx, genSnapshotKey(volumeId)) + return s.runtime.DestroySnapshot(ctx, GenSnapshotKey(volumeId)) } func (s *SnapshotMounter) ImageExists(ctx context.Context, image docker.Named) bool { return s.runtime.ImageExists(ctx, image) } -func genSnapshotKey(parent string) SnapshotKey { +func GenSnapshotKey(parent string) SnapshotKey { return SnapshotKey(fmt.Sprintf("csi-image.warm-metal.tech-%s", parent)) } diff --git a/pkg/backend/runtime.go b/pkg/backend/runtime.go index b50d0813..28b1a548 100644 --- a/pkg/backend/runtime.go +++ b/pkg/backend/runtime.go @@ -13,7 +13,8 @@ type MountOptions struct { type SnapshotKey string type MountTarget string -type ContainerRuntime interface { +// ContainerRuntimeMounter is a container runtime specific interface +type ContainerRuntimeMounter interface { Mount(ctx context.Context, key SnapshotKey, target MountTarget, ro bool) error Unmount(ctx context.Context, target MountTarget) error @@ -43,3 +44,16 @@ type ContainerRuntime interface { // The snapshot key must also be saved in the returned map with the key "FakeMetaDataSnapshotKey". ListSnapshots(ctx context.Context) ([]SnapshotMetadata, error) } + +// Mounter is a generic interface used for mounting images +type Mounter interface { + // Mount mounts a specific image + Mount( + ctx context.Context, volumeId string, target MountTarget, image docker.Named, ro bool) (err error) + + // Unmount unmounts a specific image + Unmount(ctx context.Context, volumeId string, target MountTarget) error + + // ImageExists checks if the image already exists on the local machine + ImageExists(ctx context.Context, image docker.Named) bool +} diff --git a/pkg/mountexecutor/mountexecutor.go b/pkg/mountexecutor/mountexecutor.go index 540b8b6f..118fb563 100644 --- a/pkg/mountexecutor/mountexecutor.go +++ b/pkg/mountexecutor/mountexecutor.go @@ -25,7 +25,7 @@ const ( // MountExecutorOptions are options passed to mount executor type MountExecutorOptions struct { AsyncMount bool - Mounter *backend.SnapshotMounter + Mounter backend.Mounter } // MountOptions are options for a single mount request @@ -44,7 +44,7 @@ type MountOptions struct { type MountExecutor struct { asyncMount bool mutex *sync.Mutex - mounter *backend.SnapshotMounter + mounter backend.Mounter asyncErrs map[docker.Named]error } diff --git a/pkg/pullexecutor/pullexecutor.go b/pkg/pullexecutor/pullexecutor.go index 8ca0f73a..dbedd65f 100644 --- a/pkg/pullexecutor/pullexecutor.go +++ b/pkg/pullexecutor/pullexecutor.go @@ -29,7 +29,7 @@ type PullExecutorOptions struct { AsyncPull bool ImageServiceClient cri.ImageServiceClient SecretStore secret.Store - Mounter *backend.SnapshotMounter + Mounter backend.Mounter } // PullOptions are the options for a single pull request @@ -50,7 +50,7 @@ type PullExecutor struct { mutex *sync.Mutex asyncErrs map[docker.Named]error secretStore secret.Store - mounter *backend.SnapshotMounter + mounter backend.Mounter } // NewPullExecutor initializes a new pull executor object diff --git a/pkg/test/utils/utils.go b/pkg/test/utils/utils.go new file mode 100644 index 00000000..72ad1fbd --- /dev/null +++ b/pkg/test/utils/utils.go @@ -0,0 +1,111 @@ +package utils + +import ( + "context" + "fmt" + "time" + + "github.com/containerd/containerd/reference/docker" + "github.com/warm-metal/container-image-csi-driver/pkg/backend" + "google.golang.org/grpc" + criapi "k8s.io/cri-api/pkg/apis/runtime/v1" +) + +type MockImageServiceClient struct { + PulledImages map[string]bool + ImagePullTime time.Duration +} + +type MockMounter struct { + ImageSvcClient MockImageServiceClient + Mounted map[string]bool +} + +const hundredMB = 104857600 + +func (m *MockMounter) Mount( + ctx context.Context, volumeId string, target backend.MountTarget, image docker.Named, ro bool) (err error) { + m.Mounted[volumeId] = true + return nil +} + +// Unmount unmounts a specific image +func (m *MockMounter) Unmount(ctx context.Context, volumeId string, target backend.MountTarget) error { + if m.Mounted[volumeId] { + delete(m.Mounted, volumeId) + return nil + } + return fmt.Errorf("image mount not found") +} + +// ImageExists checks if the image already exists on the local machine +func (m *MockMounter) ImageExists(ctx context.Context, image docker.Named) bool { + return m.ImageSvcClient.PulledImages[image.Name()] +} + +func (c *MockImageServiceClient) ListImages(ctx context.Context, in *criapi.ListImagesRequest, opts ...grpc.CallOption) (*criapi.ListImagesResponse, error) { + resp := new(criapi.ListImagesResponse) + resp.Images = []*criapi.Image{} + + for k := range c.PulledImages { + resp.Images = append(resp.Images, &criapi.Image{ + Id: k, + // 100MB + Size_: hundredMB, + Spec: &criapi.ImageSpec{ + Image: k, + }, + }) + } + + return resp, nil +} + +func (c *MockImageServiceClient) ImageStatus(ctx context.Context, in *criapi.ImageStatusRequest, opts ...grpc.CallOption) (*criapi.ImageStatusResponse, error) { + resp := new(criapi.ImageStatusResponse) + resp.Image = &criapi.Image{ + Id: in.Image.Image, + Size_: hundredMB, + Spec: &criapi.ImageSpec{ + Image: in.Image.Image, + }, + } + return resp, nil +} + +func (c *MockImageServiceClient) PullImage(ctx context.Context, in *criapi.PullImageRequest, opts ...grpc.CallOption) (*criapi.PullImageResponse, error) { + resp := new(criapi.PullImageResponse) + resp.ImageRef = in.Image.Image + time.Sleep(c.ImagePullTime) + + return resp, nil +} + +func (c *MockImageServiceClient) RemoveImage(ctx context.Context, in *criapi.RemoveImageRequest, opts ...grpc.CallOption) (*criapi.RemoveImageResponse, error) { + resp := new(criapi.RemoveImageResponse) + delete(c.PulledImages, in.Image.Image) + return resp, nil +} + +func (c *MockImageServiceClient) ImageFsInfo(ctx context.Context, in *criapi.ImageFsInfoRequest, opts ...grpc.CallOption) (*criapi.ImageFsInfoResponse, error) { + resp := new(criapi.ImageFsInfoResponse) + resp.ImageFilesystems = []*criapi.FilesystemUsage{} + + for _ = range c.PulledImages { + resp.ImageFilesystems = append(resp.ImageFilesystems, &criapi.FilesystemUsage{ + Timestamp: time.Now().Unix(), + FsId: &criapi.FilesystemIdentifier{ + Mountpoint: "target", + }, + UsedBytes: &criapi.UInt64Value{ + Value: hundredMB, + }, + InodesUsed: &criapi.UInt64Value{ + // random value + Value: 10, + }, + }) + } + + return resp, nil +} diff --git a/test/integration/node-server/Dockerfile.containerd b/test/node-server/Dockerfile.containerd similarity index 100% rename from test/integration/node-server/Dockerfile.containerd rename to test/node-server/Dockerfile.containerd diff --git a/test/integration/node-server/README.md b/test/node-server/README.md similarity index 61% rename from test/integration/node-server/README.md rename to test/node-server/README.md index a15c24e1..e0f3f908 100644 --- a/test/integration/node-server/README.md +++ b/test/node-server/README.md @@ -4,9 +4,9 @@ This directory contains two files: 2. `Dockerfile.containerd`: used to run containerd ## Why? -This is to test `cmd/plugin/node_server_test.go` and `pkg/remoteimage/pull_test.go` +This is to run container-image-csi-driver code in a container where containerd is running -## How to run the tests? +## How to use? Build the image ```shell $ docker build . -f Dockerfile.containerd -t : @@ -54,30 +54,3 @@ For example: $ docker exec -it 7769b9e621f1 bash ~ root@7769b9e621f1:/go# ``` - -**To run `TestNodePublishVolume`**: - -`cd` into `/code/cmd/plugin` and run `go test -run 'TestNodePublishVolume'` (note that `TestNodePublishVolume` is a regex) -``` -root@7769b9e621f1:/go# cd /code/cmd/plugin -root@7769b9e621f1:/code/cmd/plugin# go test -run 'TestNodePublishVolume' -I1108 10:27:03.784182 19936 mounter.go:45] load 0 snapshots from runtime -I1108 10:27:03.787347 19936 server.go:108] Listening for connections on address: &net.UnixAddr{Name:"//csi/csi.sock", Net:"unix"} -... -I1108 10:27:13.222601 19936 node_server_test.go:94] server was stopped -I1108 10:27:13.225907 19936 mounter.go:45] load 0 snapshots from runtime -I1108 10:27:13.235697 19936 server.go:108] Listening for connections on address: &net.UnixAddr{Name:"//csi/csi.sock", Net:"unix"} -... -PASS -ok github.com/warm-metal/container-image-csi-driver/cmd/plugin 46.711s -``` - -**To test `TestPull`**: -`cd` into `/code/pkg/remoteimage` and run `go test -run 'TestPull'` (note that `TestPull` is a regex) -``` -root@cdf7ee254501:~# cd /code/pkg/remoteimage -root@cdf7ee254501:/code/pkg/remoteimage# go test -run 'TestPull' -PASS -ok github.com/warm-metal/container-image-csi-driver/pkg/remoteimage 2.247s -root@cdf7ee254501:/code/pkg/remoteimage# -``` diff --git a/test/integration/node-server/docker-compose.yaml b/test/node-server/docker-compose.yaml similarity index 100% rename from test/integration/node-server/docker-compose.yaml rename to test/node-server/docker-compose.yaml From 16892c441ff39bab512fb0473d7892038597b5db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:25:06 +0000 Subject: [PATCH 32/32] chore: [skip ci](deps): bump actions/delete-package-versions from 4 to 5 (#141) --- .github/workflows/images-cleanup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/images-cleanup.yaml b/.github/workflows/images-cleanup.yaml index 2b699f51..a87c41d6 100644 --- a/.github/workflows/images-cleanup.yaml +++ b/.github/workflows/images-cleanup.yaml @@ -15,7 +15,7 @@ jobs: name: Delete old unused container images runs-on: ubuntu-latest steps: - - uses: actions/delete-package-versions@v4 + - uses: actions/delete-package-versions@v5 if: github.repository != env.BASE_REPOSITORY with: owner: ${{ github.repository_owner }}