Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'fix/volume-expansion' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Apr 8, 2021
2 parents e8ddc69 + 60cde53 commit 41b0bbf
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ push helm chart:
script:
- git clone --single-branch --branch master git@github.com:enix/helm-charts.git
- rm -rf ./helm-charts/charts/dothill-csi
- cp ./LICENSE ./helm/dothill-csi/
- cp -R ./helm/dothill-csi ./helm-charts/charts/dothill-csi
- cd ./helm-charts/charts/dothill-csi
- >
Expand Down
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ COPY Makefile ./

ARG version

RUN echo "package common\nconst Version = \"${version}\"" > ./pkg/common/version.go

RUN BIN="/dothill" make controller

RUN BIN="/dothill" make node
RUN BIN="/dothill" VERSION="$version" make controller
RUN BIN="/dothill" VERSION="$version" make node

###########################################

FROM ubuntu:18.04

LABEL maintainer="Enix <no-reply@enix.fr>" \
org.opencontainers.image.title="Dothill CSI" \
org.opencontainers.image.description="A dynamic persistent volume provisioner for Dothill AssuredSAN based storage systems." \
org.opencontainers.image.url="https://github.com/enix/dothill-csi" \
org.opencontainers.image.source="https://github.com/enix/dothill-csi/blob/master/Dockerfile" \
org.opencontainers.image.documentation="https://github.com/enix/dothill-csi/blob/master/README.md" \
org.opencontainers.image.authors="Enix <no-reply@enix.fr>" \
org.opencontainers.image.licenses="MIT"

RUN apt update \
&& apt dist-upgrade -y \
&& apt install -y dosfstools e2fsprogs xfsprogs jfsutils libisns0 open-iscsi kmod multipath-tools \
Expand All @@ -34,3 +40,10 @@ RUN apt update \
COPY --from=build /dothill-* /usr/local/bin/

CMD [ "/usr/local/bin/dothill-controller" ]

ARG version
ARG vcs_ref
ARG build_date
LABEL org.opencontainers.image.version="$version" \
org.opencontainers.image.revision="$vcs_ref" \
org.opencontainers.image.created="$build_date"
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
ifeq ($(DOCKER_HUB_REPOSITORY),)
ifndef DOCKER_HUB_REPOSITORY
DOCKER_HUB_REPOSITORY = docker.io/enix
endif

ifeq ($(VERSION),)
ifndef VERSION
VERSION = latest
else
VERSION_FLAG = -X github.com/enix/dothill-csi/pkg/common.Version=$(VERSION)
endif

ifeq ($(BIN),)
ifndef BIN
BIN = dothill
endif

Expand All @@ -19,19 +21,20 @@ bin: controller node
.PHONY: bin

controller:
go build -v -o $(BIN)-controller ./cmd/controller
go build -v -ldflags "$(VERSION_FLAG)" -o $(BIN)-controller ./cmd/controller
.PHONY: controller

node:
go build -v -o $(BIN)-node ./cmd/node
echo "$(VERSION_FLAG)"
go build -v -ldflags "$(VERSION_FLAG)" -o $(BIN)-node ./cmd/node
.PHONY: node

test:
./test/sanity
.PHONY: test

image:
docker build -t $(IMAGE) --build-arg version=$(VERSION) .
docker build -t $(IMAGE) --build-arg version="$(VERSION)" --build-arg vcs_ref="$(shell git rev-parse HEAD)" --build-arg build_date="$(shell date --rfc-3339=seconds)" .
.PHONY: image

push: image
Expand Down
4 changes: 4 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ kubeletPath: /opt/rke/var/lib/kubelet
It's a known fact that when `multipathd` segfaults, it can produce wrong mappings of device paths. When such a multipathed device is mounted, it can result in a corruption of the filesystem. Some checks were added to ensure that the different paths are consistent and lead to the same volume in the appliance.

If you still get this issue, please check that the candidate for the package `multipath-tools` on your host is on the same version as in the container. You can do so by running `apt-cache policy multipath-tools` on your host as well as in the container `multipathd` from one of the pod `dothill-node-server-xxxxx`.

## When expanding a volume, I get the error "missing API credentials"

It's because your storage class miss parameters `csi.storage.k8s.io/controller-expand-secret-name` and `csi.storage.k8s.io/controller-expand-secret-namespace`. The same can happen with volume's creation and publication. The solution is to add those parameters to your storage class. Since a storage class is immutable, you will have to delete it first and then recreate it. The CSI plugin may not take account of this change if an expansion is already in progress. A solution could be to [clone](./volume-snapshots.md#clone-a-volume) the volume you wanted to expand using your new storage class and replace it by its clone.
2 changes: 2 additions & 0 deletions docs/volume-snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ To restore a snapshot, you have to create a new `PersistantVolumeClaim` and spec

To clone a volume, you can follow the same procedure than to restore a snapshot, but configure another volume instead of a snapshot. An example can be found [here](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/examples/csi-clone.yaml) and the kubernetes documentation [here](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-cloning).

---

References:
- https://kubernetes.io/docs/concepts/storage/volume-snapshots
- https://github.com/kubernetes-csi/external-snapshotter
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/enix/dothill-csi
go 1.16

require (
github.com/container-storage-interface/spec v1.3.0
github.com/enix/dothill-api-go v1.7.0
github.com/container-storage-interface/spec v1.4.0
github.com/enix/dothill-api-go v1.7.1
github.com/golang/protobuf v1.4.3
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
github.com/kubernetes-csi/csi-lib-iscsi v0.0.0-20200118015005-959f12c91ca8
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/container-storage-interface/spec v1.3.0 h1:wMH4UIoWnK/TXYw8mbcIHgZmB6kHOeIsYsiaTJwa6bc=
github.com/container-storage-interface/spec v1.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/container-storage-interface/spec v1.4.0 h1:ozAshSKxpJnYUfmkpZCTYyF/4MYeYlhdXbAvPvfGmkg=
github.com/container-storage-interface/spec v1.4.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
Expand All @@ -55,10 +55,10 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/enix/csi-lib-iscsi v0.0.0-dothill-3-0-3 h1:PFOkMy2rmW0xviq9stiEKZ1XQu+TtSA6d0tEZyLfwTo=
github.com/enix/csi-lib-iscsi v0.0.0-dothill-3-0-3/go.mod h1:c/keGS6bErOzLrFyNgafdDWT6h72v2XQiA/p2R7yghU=
github.com/enix/dothill-api-go v1.7.0 h1:jbziGAb4ecXRgds47zcfXqEeNPJJBOgiDPV4FH0FQgA=
github.com/enix/dothill-api-go v1.7.0/go.mod h1:OuhSm5SRGxzXFy3kmRAGCCDpbp6q/2JFmTdES2jP5Jw=
github.com/enix/csi-lib-iscsi v0.0.0-dothill-3-1-1-1 h1:cfq1+Xm8XO/ijV6fPP/d5a+4qwwV93I+3LQ+ClgAB/k=
github.com/enix/csi-lib-iscsi v0.0.0-dothill-3-1-1-1/go.mod h1:c/keGS6bErOzLrFyNgafdDWT6h72v2XQiA/p2R7yghU=
github.com/enix/dothill-api-go v1.7.1 h1:A8O9xXyiMPFtThQXqh1w5er6i7QTA71Yew+LUsSEXjw=
github.com/enix/dothill-api-go v1.7.1/go.mod h1:OuhSm5SRGxzXFy3kmRAGCCDpbp6q/2JFmTdES2jP5Jw=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
package common

// Version : version of the packages
const Version = "0.0.0-DIRTY"
var Version = "0.0.0-DIRTY"
30 changes: 26 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"
"errors"
"sync"

"github.com/container-storage-interface/spec/lib/go/csi"
Expand Down Expand Up @@ -42,6 +43,16 @@ var csiMutexes = map[string]*sync.Mutex{
"/csi.v1.Controller/ControllerExpandVolume": {},
}

var nonAuthenticatedMethods = []string{
"/csi.v1.Controller/ControllerGetCapabilities",
"/csi.v1.Controller/ListVolumes",
"/csi.v1.Controller/GetCapacity",
"/csi.v1.Controller/ControllerGetVolume",
"/csi.v1.Identity/Probe",
"/csi.v1.Identity/GetPluginInfo",
"/csi.v1.Identity/GetPluginCapabilities",
}

// Controller is the implementation of csi.ControllerServer
type Controller struct {
*common.Driver
Expand Down Expand Up @@ -87,7 +98,7 @@ func New() *Controller {
driverContext.VolumeCaps = reqWithVolumeCaps.GetVolumeCapabilities()
}

err := controller.beginRoutine(&driverContext)
err := controller.beginRoutine(&driverContext, info.FullMethod)
defer controller.endRoutine()
if err != nil {
return nil, err
Expand Down Expand Up @@ -171,16 +182,27 @@ func (controller *Controller) Probe(ctx context.Context, req *csi.ProbeRequest)
return &csi.ProbeResponse{}, nil
}

func (controller *Controller) beginRoutine(ctx *DriverCtx) error {
func (controller *Controller) beginRoutine(ctx *DriverCtx, methodName string) error {
if err := runPreflightChecks(ctx.Parameters, ctx.VolumeCaps); err != nil {
return err
}

if ctx.Credentials == nil {
klog.Info("skipping login as this RPC does not require any API call")
needsAuthentication := true
for _, name := range nonAuthenticatedMethods {
if methodName == name {
needsAuthentication = false
break
}
}

if !needsAuthentication {
return nil
}

if ctx.Credentials == nil {
return errors.New("missing API credentials")
}

return controller.configureClient(ctx.Credentials)
}

Expand Down

0 comments on commit 41b0bbf

Please sign in to comment.