Skip to content

Commit

Permalink
Allow usage of PVCTemplate as storage pool source. (#175)
Browse files Browse the repository at this point in the history
* Add mounter binary that attempts to mount a volume on the host so
the hostpath provisioner can use it.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Refactor unit tests.
Add unit tests for storage pool.
Refactor mounter to be easier to read.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Refactored mounter so it will remount if something unmounts the mount.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Added unmounting when deployment is no longer available on a node.

Signed-off-by: Alexander Wels <awels@redhat.com>

* generated crd files

Signed-off-by: Alexander Wels <awels@redhat.com>

* Moved PVCTemplate up to the storage pool level.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Add SA to mount and unmount deployment/job

Signed-off-by: Alexander Wels <awels@redhat.com>

* Don't clobber existing finalizers, add/remove properly.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Don't remove finalizer from hpp until all the unmount jobs finish

Signed-off-by: Alexander Wels <awels@redhat.com>

* Delete daemonset and deployments associated with SA instead of pods.

Signed-off-by: Alexander Wels <awels@redhat.com>
  • Loading branch information
awels committed Dec 1, 2021
1 parent a7589b6 commit 361e426
Show file tree
Hide file tree
Showing 31 changed files with 2,746 additions and 1,134 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM registry.fedoraproject.org/fedora-minimal:34

RUN microdnf install -y xfsprogs

COPY _out/hostpath-provisioner-operator /usr/bin/hostpath-provisioner-operator
COPY _out/csv-generator /usr/bin/csv-generator
COPY _out/mounter /usr/bin/mounter
COPY _out/version.txt /version.txt
ENV PATH=/usr/bin
ENTRYPOINT ["hostpath-provisioner-operator"]
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ all: test build
operator:
GOLANG_VER=${GOLANG_VER} ./hack/build-operator.sh

mounter:
GOLANG_VER=${GOLANG_VER} ./hack/build-mounter.sh

csv-generator:
GOLANG_VER=${GOLANG_VER} ./hack/build-csv-generator.sh

crd-generator: generate-crd
GOLANG_VER=${GOLANG_VER} ./hack/build-crd-generator.sh
_out/crd-generator --sourcefile=./deploy/operator.yaml --outputDir=./tools/helper

image: operator csv-generator
image: operator mounter csv-generator
TAG=$(TAG) ./hack/version.sh ./_out; \
docker build -t $(DOCKER_REPO)/$(OPERATOR_IMAGE):$(TAG) -f Dockerfile .

Expand Down
42 changes: 42 additions & 0 deletions cmd/mounter/chroot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2021 The hostpath provisioner operator Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"os"
"syscall"
)

func chroot(path string) (func() error, error) {
root, err := os.Open("/")
if err != nil {
return nil, err
}

if err := syscall.Chroot(path); err != nil {
root.Close()
return nil, err
}

return func() error {
defer root.Close()
if err := root.Chdir(); err != nil {
return err
}
return syscall.Chroot(".")
}, nil
}
Loading

0 comments on commit 361e426

Please sign in to comment.