Skip to content

Commit

Permalink
feat(controller): support for standard storage tier (#105)
Browse files Browse the repository at this point in the history
- support for standard storage tier
- update upcloud-go-api to v8.6.1
- update Go to 1.22
  • Loading branch information
peknur authored Jul 9, 2024
1 parent e59d5af commit 7436691
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set go environment
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version-file: 'go.mod'

- name: Build Go binary
run: GOOS=${{ env.GOOS }} GOARCH=${{ env.GOARCH }} CGO_ENABLED=0 go build -ldflags "-w -s" -o cmd/upcloud-csi-plugin/${{ env.NAME }} ${{ env.PKG }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
uses: actions/checkout@v4

- name: Setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version-file: 'go.mod'
cache: false

- name: Run golangci-lint-action
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v5
with:
version: v1.54
args: --timeout 5m
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/checkout@v4

- name: Set go environment
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version-file: 'go.mod'

- name: Get release notes
run: make release-notes > .release_notes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
- name: Test Driver Integration
env:
UPCLOUD_TEST_USERNAME: ${{ secrets.UPCLOUD_TEST_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5

- name: Test Driver
run: sudo make test
2 changes: 1 addition & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CSI driver's primary goal is to conform to [Container Storage Interface (CSI)](h
Depending on [CO](https://www.vmware.com/topics/glossary/content/container-orchestration.html), endpoints are called directly or by [sidecar containers](deploy/kubernetes/README.md#sidecars).

## Requirements
- [Go](https://golang.org/doc/install) >= 1.20
- [Go](https://golang.org/doc/install) >= 1.22

Get the source code:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PLUGIN_NAME=upcloud-csi-plugin
PLUGIN_PKG ?= github.com/UpCloudLtd/upcloud-csi
PLUGIN_CMD ?= ${PLUGIN_PKG}/cmd/upcloud-csi-plugin
OS ?= linux
GO_VERSION := 1.20
GO_VERSION := 1.22
ARCH := amd64
CGO_ENABLED := 1
TAG ?= $(shell git describe --tags)
Expand Down
2 changes: 1 addition & 1 deletion cmd/upcloud-csi-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.17
FROM alpine:3.20

RUN apk add ca-certificates \
e2fsprogs \
Expand Down
14 changes: 14 additions & 0 deletions deploy/kubernetes/setup-upcloud-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ provisioner: storage.csi.upcloud.com
allowVolumeExpansion: true
reclaimPolicy: Retain

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: upcloud-block-storage-standard
namespace: kube-system
annotations:
storageclass.kubernetes.io/is-default-class: "false"
parameters:
tier: standard
provisioner: storage.csi.upcloud.com
allowVolumeExpansion: true
reclaimPolicy: Retain

---
#######################
# Controller plugin
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/UpCloudLtd/upcloud-csi

go 1.20
go 1.22

require (
github.com/container-storage-interface/spec v1.6.0
Expand All @@ -22,7 +22,7 @@ require (

require github.com/kubernetes-csi/csi-test/v5 v5.0.0

require github.com/UpCloudLtd/upcloud-go-api/v6 v6.12.0
require github.com/UpCloudLtd/upcloud-go-api/v8 v8.6.1

require (
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/UpCloudLtd/upcloud-go-api/v6 v6.12.0 h1:Qol8WuStmqWTXO8Hfel6FjCgLOZ98MGVCvg3ExcEs68=
github.com/UpCloudLtd/upcloud-go-api/v6 v6.12.0/go.mod h1:I8rWmBBl+OhiY3AGzKbrobiE5TsLCLNYkCQxE4eJcTg=
github.com/UpCloudLtd/upcloud-go-api/v8 v8.6.1 h1:8GEUDjMastRQDHLG4/tBN31Rd2UxdEhkjwkXwe8XyUc=
github.com/UpCloudLtd/upcloud-go-api/v8 v8.6.1/go.mod h1:/BL9bYxio0GCdotzBvZjkpm1fSDtD0+0z6PtNMew9HU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand All @@ -27,6 +27,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE=
github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Expand Down Expand Up @@ -324,6 +325,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
Expand Down
10 changes: 7 additions & 3 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/UpCloudLtd/upcloud-csi/internal/logger"
"github.com/UpCloudLtd/upcloud-csi/internal/service"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -743,7 +743,11 @@ func listSnapshotsErrorResponse(err error) (*csi.ListSnapshotsResponse, error) {
}

func createVolumeRequestTier(r *csi.CreateVolumeRequest) (string, error) {
tierMapper := map[string]string{"maxiops": upcloud.StorageTierMaxIOPS, "hdd": upcloud.StorageTierHDD}
tierMapper := map[string]string{
"maxiops": upcloud.StorageTierMaxIOPS,
"hdd": upcloud.StorageTierHDD,
"standard": upcloud.StorageTierStandard,
}
p, ok := r.Parameters["tier"]
if !ok {
// tier parameter is not required
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/controller_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"testing"

"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controller
import (
"strings"

"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
)

func upcloudLabels(labels []string) []upcloud.Label {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/mock/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

"github.com/UpCloudLtd/upcloud-csi/internal/service"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
"github.com/google/uuid"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/service/mock/upcloud_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sync"
"time"

"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/service"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service"
)

type UpCloudClient struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"errors"

"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions internal/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

"github.com/UpCloudLtd/upcloud-csi/internal/service"
"github.com/UpCloudLtd/upcloud-csi/internal/service/mock"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/client"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/service"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/client"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
14 changes: 8 additions & 6 deletions internal/service/upcloud_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"sync"
"time"

"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/client"
"github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v6/upcloud/service"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/client"
"github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request"
upsvc "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/service"
)

const (
Expand Down Expand Up @@ -322,18 +322,20 @@ func (u *UpCloudService) RequireStorageOnline(ctx context.Context, s *upcloud.St
}

func (u *UpCloudService) waitForStorageOnline(ctx context.Context, uuid string) (*upcloud.StorageDetails, error) {
ctx, cancel := context.WithTimeout(ctx, storageStateTimeout)
defer cancel()
return u.client.WaitForStorageState(ctx, &request.WaitForStorageStateRequest{
UUID: uuid,
DesiredState: upcloud.StorageStateOnline,
Timeout: storageStateTimeout,
})
}

func (u *UpCloudService) waitForServerOnline(ctx context.Context, uuid string) error {
ctx, cancel := context.WithTimeout(ctx, serverStateTimeout)
defer cancel()
_, err := u.client.WaitForServerState(ctx, &request.WaitForServerStateRequest{
UUID: uuid,
DesiredState: upcloud.ServerStateStarted,
Timeout: serverStateTimeout,
})
return err
}

0 comments on commit 7436691

Please sign in to comment.