diff --git a/Makefile b/Makefile index 0c33fb8c..58e93688 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ EXTERNAL_TOOLS=\ # By default the organization name is `openebs`. ifeq (${IMAGE_ORG}, ) - IMAGE_ORG="openebs" + IMAGE_ORG="abhishek09dh" export IMAGE_ORG endif diff --git a/buildscripts/lvm-driver/Dockerfile b/buildscripts/lvm-driver/Dockerfile index 5d1eea4d..1afc9e0f 100644 --- a/buildscripts/lvm-driver/Dockerfile +++ b/buildscripts/lvm-driver/Dockerfile @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM alpine:3.12 -RUN apk add --no-cache lvm2 lvm2-extra util-linux device-mapper -RUN apk add --no-cache btrfs-progs xfsprogs xfsprogs-extra e2fsprogs e2fsprogs-extra -RUN apk add --no-cache ca-certificates libc6-compat +FROM ubuntu:20.04 +RUN apt-get update +RUN apt-get -y install xfsprogs e2fsprogs +RUN apt-get -y install ca-certificates +RUN apt-get -y install vim ARG DBUILD_DATE ARG DBUILD_REPO_URL diff --git a/buildscripts/lvm-driver/Dockerfile.buildx b/buildscripts/lvm-driver/Dockerfile.buildx index d50f8f9c..fe705de5 100644 --- a/buildscripts/lvm-driver/Dockerfile.buildx +++ b/buildscripts/lvm-driver/Dockerfile.buildx @@ -41,10 +41,11 @@ COPY . . RUN make buildx.csi-driver -FROM alpine:3.12 -RUN apk add --no-cache lvm2 lvm2-extra util-linux device-mapper -RUN apk add --no-cache btrfs-progs xfsprogs xfsprogs-extra e2fsprogs e2fsprogs-extra -RUN apk add --no-cache ca-certificates libc6-compat +FROM ubuntu:20.04 +RUN apt-get update +RUN apt-get -y install xfsprogs e2fsprogs +RUN apt-get -y install ca-certificates +RUN apt-get -y install vim ARG DBUILD_DATE ARG DBUILD_REPO_URL diff --git a/deploy/lvm-operator.yaml b/deploy/lvm-operator.yaml index 7f08b844..8cc2ae4f 100644 --- a/deploy/lvm-operator.yaml +++ b/deploy/lvm-operator.yaml @@ -1338,6 +1338,74 @@ roleRef: --- +kind: ConfigMap +apiVersion: v1 +metadata: + name: openebs-lvmpv-bin + namespace: kube-system # should be the same namespace where it is getting mounted +data: + get_bin_path: | + #!/bin/sh + bin_name=$1 + if [ -x /host/bin/which ]; then + echo $(chroot /host /bin/which $bin_name | cut -d ' ' -f 1) + elif [ -x /host/usr/bin/which ]; then + echo $(chroot /host /usr/bin/which $bin_name | cut -d ' ' -f 1) + else + $(chroot /host which $bin_name | cut -d ' ' -f 1) + fi + + vgcreate: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "vgcreate") + chroot /host $path "$@" + + vgchange: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "vgchange") + chroot /host $path "$@" + + vgs: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "vgs") + chroot /host $path "$@" + + lvcreate: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "lvcreate") + chroot /host $path "$@" + + lvchange: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "lvchange") + chroot /host $path "$@" + + lvextend: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "lvextend") + chroot /host $path "$@" + + lvremove: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "lvremove") + chroot /host $path "$@" + + lvs: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "lvs") + chroot /host $path "$@" + + pvs: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "pvs") + chroot /host $path "$@" + + pvscan: | + #!/bin/sh + path=$(/sbin/lvm-eg/get_bin_path "pvscan") + chroot /host $path "$@" + +--- apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: @@ -1436,6 +1504,10 @@ spec: mountPath: /plugin - name: device-dir mountPath: /dev + - name: chroot-lvm + mountPath: /sbin/lvm-eg + - name: host-root + mountPath: /host - name: pods-mount-dir mountPath: /var/lib/kubelet/ # needed so that any mounts setup inside this container are @@ -1446,6 +1518,14 @@ spec: hostPath: path: /dev type: Directory + - name: chroot-lvm + configMap: + defaultMode: 0555 + name: openebs-lvmpv-bin + - name: host-root + hostPath: + path: / + type: Directory - name: registration-dir hostPath: path: /var/lib/kubelet/plugins_registry/ diff --git a/pkg/lvm/lvm_util.go b/pkg/lvm/lvm_util.go index 068885c2..e3f58337 100644 --- a/pkg/lvm/lvm_util.go +++ b/pkg/lvm/lvm_util.go @@ -46,18 +46,18 @@ const ( // lvm command related constants const ( - VGCreate = "vgcreate" - VGList = "vgs" - VGChange = "vgchange" - - LVCreate = "lvcreate" - LVRemove = "lvremove" - LVExtend = "lvextend" - LVList = "lvs" - LVChange = "lvchange" - - PVList = "pvs" - PVScan = "pvscan" + VGCreate = "/sbin/lvm-eg/vgcreate" + VGList = "/sbin/lvm-eg/vgs" + VGChange = "/sbin/lvm-eg/vgchange" + + LVCreate = "/sbin/lvm-eg/lvcreate" + LVRemove = "/sbin/lvm-eg/lvremove" + LVExtend = "/sbin/lvm-eg/lvextend" + LVList = "/sbin/lvm-eg/lvs" + LVChange = "/sbin/lvm-eg/lvchange" + + PVList = "/sbin/lvm-eg/pvs" + PVScan = "/sbin/lvm-eg/pvscan" YES = "yes" LVThinPool = "thin-pool" diff --git a/pkg/mgmt/volume/volume.go b/pkg/mgmt/volume/volume.go index 1ad393be..7cc6e978 100644 --- a/pkg/mgmt/volume/volume.go +++ b/pkg/mgmt/volume/volume.go @@ -165,8 +165,10 @@ func (c *VolController) getVgPriorityList(vol *apis.LVMVolume) ([]apis.VolumeGro if err != nil { return nil, fmt.Errorf("failed to list vgs available on node: %v", err) } + fmt.Printf("list of vgs = %v", vgs) filteredVgs := make([]apis.VolumeGroup, 0) for _, vg := range vgs { + fmt.Printf("vol= %v, object = %v", vol.Name, vol) if !re.MatchString(vg.Name) { continue } @@ -177,19 +179,25 @@ func (c *VolController) getVgPriorityList(vol *apis.LVMVolume) ([]apis.VolumeGro continue } } - // skip th vg if the volume is to be created in exclusive shared mode but the underlying + fmt.Printf("sharedmode = %v, attribute = %s, attribute[0] = %v, attribute[5] = %v, filteredvgs = %v", vol.Spec.SharedMode, vg.Attribute, vg.Attribute[0], vg.Attribute[5], filteredVgs) + // skip the vg if the volume is to be created in exclusive shared mode but the underlying // vg is not shared. Shared VGs are indicated by "s" (for shared) in the sixth attr // field if vol.Spec.SharedMode == apis.LVMExclusiveSharedMode && vg.Attribute[5] != 's' { + fmt.Printf("vg = %s is a shared vg", vg.Name) continue } filteredVgs = append(filteredVgs, vg) } + fmt.Println("filtered vgs= ", filteredVgs) + // prioritize the volume group having less free space available. sort.SliceStable(filteredVgs, func(i, j int) bool { return filteredVgs[i].Free.Cmp(filteredVgs[j].Free) < 0 }) + + fmt.Println("sorted filtered vgs= ", filteredVgs) return filteredVgs, nil }