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

Update dependencies and build process #61

Merged
merged 7 commits into from
Feb 29, 2024
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
95 changes: 95 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: Docker Build Action
on:
pull_request:
branches:
- master
release:
types:
- published
push:
branches:
- master

env:
REGISTRY: ghcr.io
PROVISIONER_IMAGE_NAME: ${{ github.repository }}-provisioner
CONTROLLER_IMAGE_NAME: ${{ github.repository }}-controller

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Lint
uses: golangci/golangci-lint-action@v4
with:
args: --build-tags integration -p bugs -p unused --timeout=10m


build-platforms:
name: Docker Build Platforms
runs-on: ubuntu-latest
needs:
- lint
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

steps:
- name: Log in to the container registry
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Checkout
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: actions/checkout@v4

- name: Setup Go
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Set up Docker Buildx
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: docker/setup-buildx-action@v3

- name: Make tag
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
run: |
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true

- name: Build and push controller image
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.CONTROLLER_IMAGE_NAME }}:${{ env.tag }}
file: cmd/controller/Dockerfile
platforms: linux/amd64

- name: Build and push provisioner image
if: ${{ env.DOCKER_REGISTRY_TOKEN != '' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.PROVISIONER_IMAGE_NAME }}:${{ env.tag }}
file: cmd/provisioner/Dockerfile
platforms: linux/amd64
34 changes: 0 additions & 34 deletions .github/workflows/latest.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/pull_request.yaml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/release.yaml

This file was deleted.

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.19-alpine as builder
FROM golang:1.22-alpine as builder
RUN apk add make binutils
COPY / /work
WORKDIR /work
RUN make controller

FROM alpine:3.16
FROM alpine:3.19
COPY --from=builder /work/bin/csi-lvm-controller /csi-lvm-controller
USER 65534
ENTRYPOINT ["/csi-lvm-controller"]
2 changes: 1 addition & 1 deletion cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v8/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"

"k8s.io/klog/v2"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/klog/v2"
pvController "sigs.k8s.io/sig-storage-lib-external-provisioner/v8/controller"
pvController "sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions cmd/provisioner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.19-alpine as builder
FROM golang:1.22-alpine as builder
RUN apk add make binutils
COPY / /work
WORKDIR /work
RUN make provisioner

FROM alpine:3.16
RUN apk add lvm2 e2fsprogs e2fsprogs-extra smartmontools nvme-cli util-linux
FROM alpine:3.19
RUN apk add lvm2 e2fsprogs e2fsprogs-extra smartmontools nvme-cli util-linux lvm2-dmeventd
COPY --from=builder /work/bin/csi-lvm-provisioner /csi-lvm-provisioner
USER root
ENTRYPOINT ["/csi-lvm-provisioner"]
10 changes: 5 additions & 5 deletions cmd/provisioner/createlv.go
Original file line number Diff line number Diff line change
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:%w", lvPath, err)
klog.Infof("unable to check if %s is already formatted:%v", lvPath, err)
}
if strings.Contains(string(out), "ext4") {
formatted = true
Expand Down Expand Up @@ -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:%w", err)
klog.Infof("unable to list existing volumegroups:%v", err)
}
vgexists := false
for _, vg := range vgs {
Expand All @@ -232,12 +232,12 @@ func vgactivate() {
cmd := exec.Command("vgscan")
out, err := cmd.CombinedOutput()
if err != nil {
klog.Infof("unable to scan for volumegroups:%s %w", out, err)
klog.Infof("unable to scan for volumegroups:%s %v", out, err)
}
cmd = exec.Command("vgchange", "-ay")
_, err = cmd.CombinedOutput()
if err != nil {
klog.Infof("unable to activate volumegroups:%s %w", out, err)
klog.Infof("unable to activate volumegroups:%s %v", out, err)
}
}

Expand Down Expand Up @@ -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(ctx, vg+"/"+name)
if err != nil {
klog.Infof("unable to list existing logicalvolumes:%w", err)
klog.Infof("unable to list existing logicalvolumes:%v", err)
}
lvExists := false
for _, lv := range lvs {
Expand Down
4 changes: 2 additions & 2 deletions cmd/provisioner/deletelv.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func umountLV(lvname, vgname, directory string) string {
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:%w", mountPath, lvPath, string(out), err)
klog.Errorf("unable to umount %s from %s output:%s err:%v", mountPath, lvPath, string(out), err)
}
err = os.Remove(mountPath)
if err != nil {
klog.Errorf("unable to remove mount directory:%s err:%w", mountPath, err)
klog.Errorf("unable to remove mount directory:%s err:%v", mountPath, err)
}
return ""
}
Loading