Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last updates and linter errors fixed #46

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.15-alpine as builder
FROM golang:1.16-alpine as builder
RUN apk add make binutils
COPY / /work
WORKDIR /work
RUN make controller

FROM alpine:3.12
FROM alpine:3.13
COPY --from=builder /work/bin/csi-lvm-controller /csi-lvm-controller
USER 65534
ENTRYPOINT ["/csi-lvm-controller"]
4 changes: 2 additions & 2 deletions cmd/provisioner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.15-alpine as builder
FROM golang:1.16-alpine as builder
RUN apk add make binutils
COPY / /work
WORKDIR /work
RUN make provisioner

FROM alpine:3.12
FROM alpine:3.13
RUN apk add lvm2 e2fsprogs e2fsprogs-extra smartmontools nvme-cli util-linux
COPY --from=builder /work/bin/csi-lvm-provisioner /csi-lvm-provisioner
USER root
Expand Down
36 changes: 18 additions & 18 deletions cmd/provisioner/createlv.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,24 @@ func createLV(c *cli.Context) error {

output, err := createVG(vgName, devicesPattern)
if err != nil {
return fmt.Errorf("unable to create vg: %v output:%s", err, output)
return fmt.Errorf("unable to create vg: %w output:%s", err, output)
}

output, err = createLVS(context.Background(), vgName, lvName, lvSize, lvmType, blockMode)
if err != nil {
return fmt.Errorf("unable to create lv: %v output:%s", err, output)
return fmt.Errorf("unable to create lv: %w output:%s", err, output)
}

if !blockMode {
output, err = mountLV(lvName, vgName, dirName)
if err != nil {
return fmt.Errorf("unable to mount lv: %v output:%s", err, output)
return fmt.Errorf("unable to mount lv: %w output:%s", err, output)
}
klog.Infof("mounted lv %s size:%d vg:%s devices:%s created", lvName, lvSize, vgName, devicesPattern)
} else {
output, err = bindMountLV(lvName, vgName, dirName)
if err != nil {
return fmt.Errorf("unable to bind mount lv: %v output:%s", err, output)
return fmt.Errorf("unable to bind mount lv: %w output:%s", err, output)
}
klog.Infof("block lv %s size:%d vg:%s devices:%s created", lvName, lvSize, vgName, devicesPattern)
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func mountLV(lvname, vgname, directory string) (string, error) {
cmd := exec.Command("blkid", lvPath)
out, err := cmd.CombinedOutput()
if err != nil {
klog.Infof("unable to check if %s is already formatted:%v", lvPath, err)
klog.Infof("unable to check if %s is already formatted:%w", lvPath, err)
}
if strings.Contains(string(out), "ext4") {
formatted = true
Expand All @@ -155,13 +155,13 @@ func mountLV(lvname, vgname, directory string) (string, error) {
cmd = exec.Command("mkfs.ext4", lvPath)
out, err = cmd.CombinedOutput()
if err != nil {
return string(out), fmt.Errorf("unable to format lv:%s err:%v", lvname, err)
return string(out), fmt.Errorf("unable to format lv:%s err:%w", lvname, err)
}
}

err = os.MkdirAll(mountPath, 0777)
if err != nil {
return string(out), fmt.Errorf("unable to create mount directory for lv:%s err:%v", lvname, err)
return string(out), fmt.Errorf("unable to create mount directory for lv:%s err:%w", lvname, err)
}

// --make-shared is required that this mount is visible outside this container.
Expand All @@ -172,12 +172,12 @@ func mountLV(lvname, vgname, directory string) (string, error) {
if err != nil {
mountOutput := string(out)
if !strings.Contains(mountOutput, "already mounted") {
return string(out), fmt.Errorf("unable to mount %s to %s err:%v output:%s", lvPath, mountPath, err, out)
return string(out), fmt.Errorf("unable to mount %s to %s err:%w output:%s", lvPath, mountPath, err, out)
}
}
err = os.Chmod(mountPath, 0777)
if err != nil {
return "", fmt.Errorf("unable to change permissions of volume mount %s err:%v", mountPath, err)
return "", fmt.Errorf("unable to change permissions of volume mount %s err:%w", mountPath, err)
}
klog.Infof("mountlv output:%s", out)
return "", nil
Expand All @@ -188,7 +188,7 @@ func bindMountLV(lvname, vgname, directory string) (string, error) {
mountPath := path.Join(directory, lvname)
_, err := os.Create(mountPath)
if err != nil {
return "", fmt.Errorf("unable to create mount directory for lv:%s err:%v", lvname, err)
return "", fmt.Errorf("unable to create mount directory for lv:%s err:%w", lvname, err)
}

// --make-shared is required that this mount is visible outside this container.
Expand All @@ -200,12 +200,12 @@ func bindMountLV(lvname, vgname, directory string) (string, error) {
if err != nil {
mountOutput := string(out)
if !strings.Contains(mountOutput, "already mounted") {
return string(out), fmt.Errorf("unable to mount %s to %s err:%v output:%s", lvPath, mountPath, err, out)
return string(out), fmt.Errorf("unable to mount %s to %s err:%w output:%s", lvPath, mountPath, err, out)
}
}
err = os.Chmod(mountPath, 0777)
if err != nil {
return "", fmt.Errorf("unable to change permissions of volume mount %s err:%v", mountPath, err)
return "", fmt.Errorf("unable to change permissions of volume mount %s err:%w", mountPath, err)
}
klog.Infof("bindmountlv output:%s", out)
return "", nil
Expand All @@ -214,7 +214,7 @@ func bindMountLV(lvname, vgname, directory string) (string, error) {
func vgExists(name string) bool {
vgs, err := commands.ListVG(context.Background())
if err != nil {
klog.Infof("unable to list existing volumegroups:%v", err)
klog.Infof("unable to list existing volumegroups:%w", err)
}
vgexists := false
for _, vg := range vgs {
Expand All @@ -232,12 +232,12 @@ func vgactivate(name string) {
cmd := exec.Command("vgscan")
out, err := cmd.CombinedOutput()
if err != nil {
klog.Infof("unable to scan for volumegroups:%s %v", out, err)
klog.Infof("unable to scan for volumegroups:%s %w", out, err)
}
cmd = exec.Command("vgchange", "-ay")
_, err = cmd.CombinedOutput()
if err != nil {
klog.Infof("unable to activate volumegroups:%s %v", out, err)
klog.Infof("unable to activate volumegroups:%s %w", out, err)
}
}

Expand All @@ -257,7 +257,7 @@ func createVG(name string, devicesPattern []string) (string, error) {

physicalVolumes, err := devices(devicesPattern)
if err != nil {
return "", fmt.Errorf("unable to lookup devices from devicesPattern %s, err:%v", devicesPattern, err)
return "", fmt.Errorf("unable to lookup devices from devicesPattern %s, err:%w", devicesPattern, err)
}
tags := []string{"vg.metal-stack.io/csi-lvm"}

Expand All @@ -276,7 +276,7 @@ func createVG(name string, devicesPattern []string) (string, error) {
func createLVS(ctx context.Context, vg string, name string, size uint64, lvmType string, blockMode bool) (string, error) {
lvs, err := commands.ListLV(context.Background(), vg+"/"+name)
if err != nil {
klog.Infof("unable to list existing logicalvolumes:%v", err)
klog.Infof("unable to list existing logicalvolumes:%w", err)
}
lvExists := false
for _, lv := range lvs {
Expand All @@ -300,7 +300,7 @@ func createLVS(ctx context.Context, vg string, name string, size uint64, lvmType

pvs, err := pvCount(vg)
if err != nil {
return "", fmt.Errorf("unable to determine pv count of vg: %v", err)
return "", fmt.Errorf("unable to determine pv count of vg: %w", err)
}

if pvs < 2 {
Expand Down
8 changes: 4 additions & 4 deletions cmd/provisioner/deletelv.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func deleteLV(c *cli.Context) error {

output, err := umountLV(lvName, vgName, dirName)
if err != nil {
return fmt.Errorf("unable to delete lv: %v output:%s", err, output)
return fmt.Errorf("unable to delete lv: %w output:%s", err, output)
}

output, err = commands.RemoveLV(context.Background(), vgName, lvName)
if err != nil {
return fmt.Errorf("unable to delete lv: %v output:%s", err, output)
return fmt.Errorf("unable to delete lv: %w output:%s", err, output)
}
klog.Infof("lv %s vg:%s deleted", lvName, vgName)
return nil
Expand All @@ -80,11 +80,11 @@ func umountLV(lvname, vgname, directory string) (string, error) {
cmd := exec.Command("umount", "--lazy", "--force", mountPath)
out, err := cmd.CombinedOutput()
if err != nil {
klog.Errorf("unable to umount %s from %s output:%s err:%v", mountPath, lvPath, string(out), err)
klog.Errorf("unable to umount %s from %s output:%s err:%w", mountPath, lvPath, string(out), err)
}
err = os.Remove(mountPath)
if err != nil {
klog.Errorf("unable to remove mount directory:%s err:%v", mountPath, err)
klog.Errorf("unable to remove mount directory:%s err:%w", mountPath, err)
}
return "", nil
}
1 change: 0 additions & 1 deletion deploy/reviver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ spec:
privileged: true
fsGroup:
rule: RunAsAny
privileged: true
runAsUser:
rule: RunAsAny
seLinux:
Expand Down
42 changes: 19 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
module github.com/metal-stack/csi-lvm

go 1.15
go 1.16

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v0.3.0 // indirect
github.com/google/go-cmp v0.5.3 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/lvmd v0.0.0-20200421122210-17bd8b9f710f
github.com/googleapis/gnostic v0.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/miekg/dns v1.1.35 // indirect
github.com/miekg/dns v1.1.40 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/prometheus/common v0.15.0 // indirect
github.com/prometheus/client_golang v1.9.0 // indirect
github.com/prometheus/common v0.18.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/urfave/cli/v2 v2.3.0
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/oauth2 v0.0.0-20210311163135-5366d9dc1934 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20201112120144-2985b7af83de // indirect
google.golang.org/grpc v1.33.2 // indirect
k8s.io/api v0.18.12
k8s.io/apimachinery v0.18.12
k8s.io/client-go v0.18.12
k8s.io/klog/v2 v2.4.0
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/sig-storage-lib-external-provisioner/v6 v6.0.0
google.golang.org/genproto v0.0.0-20210311153111-e2979279ddde // indirect
google.golang.org/grpc v1.36.0 // indirect
k8s.io/api v0.20.4
k8s.io/apimachinery v0.20.4
k8s.io/client-go v0.20.4
k8s.io/klog/v2 v2.7.0
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 // indirect
sigs.k8s.io/sig-storage-lib-external-provisioner/v6 v6.3.0
)
Loading