diff --git a/modules/031-local-path-provisioner/images/local-path-provisioner/Dockerfile b/modules/031-local-path-provisioner/images/local-path-provisioner/Dockerfile index 321d67210bc..fd53866c1e9 100644 --- a/modules/031-local-path-provisioner/images/local-path-provisioner/Dockerfile +++ b/modules/031-local-path-provisioner/images/local-path-provisioner/Dockerfile @@ -1,5 +1,19 @@ ARG BASE_ALPINE -FROM rancher/local-path-provisioner:v0.0.20@sha256:d5999b20a1b180940061677db3bdb48dd7eb432cd48147c4ff15469fb74ade80 as artifact +FROM $BASE_ALPINE as artifact + +ARG VERSION=0.0.21 +ARG COMMIT_REF=755e331a276d4dd26f84377db5504a38109df8fb + +RUN apk add --no-cache go git +RUN git clone https://github.com/rancher/local-path-provisioner.git +WORKDIR /local-path-provisioner +RUN git checkout "${COMMIT_REF}" + +# Do not create directory if not found (GH: #224) +COPY patches/fix-directory-or-create.patch / +RUN git apply /fix-directory-or-create.patch + +RUN CGO_ENABLED=0 go build -ldflags "-X main.VERSION=${VERSION} -extldflags -static -s -w" -o /local-path-provisioner FROM $BASE_ALPINE @@ -10,6 +24,6 @@ RUN apk add --no-cache ca-certificates \ blkid \ e2fsprogs-extra -COPY --from=artifact /usr/bin/local-path-provisioner /usr/bin/local-path-provisioner +COPY --from=artifact /local-path-provisioner /usr/bin/local-path-provisioner ENTRYPOINT ["/usr/bin/local-path-provisioner"] diff --git a/modules/031-local-path-provisioner/images/local-path-provisioner/patches/README.md b/modules/031-local-path-provisioner/images/local-path-provisioner/patches/README.md new file mode 100644 index 00000000000..1e0de51367b --- /dev/null +++ b/modules/031-local-path-provisioner/images/local-path-provisioner/patches/README.md @@ -0,0 +1,7 @@ +## Patches + +## Fix DirectoryOrCreate + +Use `type: Directory` instead of `type: DirectoryOrCreate` for created PVs +to avoid the situations when initial storage is broken and unmounted. +https://github.com/rancher/local-path-provisioner/pull/224 diff --git a/modules/031-local-path-provisioner/images/local-path-provisioner/patches/fix-directory-or-create.patch b/modules/031-local-path-provisioner/images/local-path-provisioner/patches/fix-directory-or-create.patch new file mode 100644 index 00000000000..4ef770475f5 --- /dev/null +++ b/modules/031-local-path-provisioner/images/local-path-provisioner/patches/fix-directory-or-create.patch @@ -0,0 +1,13 @@ +diff --git a/provisioner.go b/provisioner.go +index b6591d0..be1aa9b 100644 +--- a/provisioner.go ++++ b/provisioner.go +@@ -215,7 +215,7 @@ func (p *LocalPathProvisioner) Provision(opts pvController.ProvisionOptions) (*v + } + + fs := v1.PersistentVolumeFilesystem +- hostPathType := v1.HostPathDirectoryOrCreate ++ hostPathType := v1.HostPathDirectory + + valueNode, ok := node.GetLabels()[KeyNode] + if !ok {