Skip to content

Cherrypick #855, #858 - Doc and Image update for 1.3.4 release #859

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

Closed
wants to merge 16 commits into from
Closed
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
57 changes: 56 additions & 1 deletion CHANGELOG/CHANGELOG-1.3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
# v1.2.3 - Changelog since v1.2.2
# v1.3.4 - Changelog since v1.3.3

## Changes by Kind

### Bug or Regression

- Update go builder to 1.17 ([#850](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/850), [@mattcary](https://github.com/mattcary))

## Dependencies

### Added
_Nothing has changed._

### Changed
_Nothing has changed._

### Removed
_Nothing has changed._

# v1.3.3 - Changelog since v1.3.1

## Changes by Kind

### Bug or Regression

- Update debian image to buster-1.9.0. ([#841](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/841), [@mattcary](https://github.com/mattcary))

## Dependencies

### Added
_Nothing has changed._

### Changed
_Nothing has changed._

### Removed
_Nothing has changed._

# v1.3.1 - Changelog since v1.3.0

### Issues

- Fixes issue where `ControllerPublishVolume` is called repeatly if gke nodes are in different cloud zones than the gke controller ([#817](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/817), [@leiyiz](https://github.com/leiyiz))

## Dependencies

### Added
_Nothing has changed._

### Changed
_Nothing has changed._

### Removed
_Nothing has changed._

# v1.3.0 - Changelog since v1.2.2

### Feature

Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ARG BUILDPLATFORM

FROM --platform=$BUILDPLATFORM golang:1.13.15 as builder
FROM --platform=$BUILDPLATFORM golang:1.17.2 as builder

ARG STAGINGVERSION
ARG TARGETPLATFORM
Expand All @@ -24,15 +24,15 @@ ADD . .
RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') GCE_PD_CSI_STAGING_VERSION=$STAGINGVERSION make gce-pd-driver

# MAD HACKS: Build a version first so we can take the scsi_id bin and put it somewhere else in our real build
FROM k8s.gcr.io/build-image/debian-base:buster-v1.6.0 as mad-hack
RUN ln -s /bin/rm /usr/sbin/rm \
FROM k8s.gcr.io/build-image/debian-base:buster-v1.9.0 as mad-hack
RUN ln -fs /bin/rm /usr/sbin/rm \
&& clean-install udev

# Start from Kubernetes Debian base
FROM k8s.gcr.io/build-image/debian-base:buster-v1.6.0
FROM k8s.gcr.io/build-image/debian-base:buster-v1.9.0
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver
# Install necessary dependencies
RUN ln -s /bin/rm /usr/sbin/rm \
RUN ln -fs /bin/rm /usr/sbin/rm \
&& clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs
COPY --from=mad-hack /lib/udev/scsi_id /lib/udev_containerized/scsi_id

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lifecycle of Google Compute Engine Persistent Disks.
## Project Status

Status: GA
Latest stable image: `k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.2.1`
Latest stable image: `k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.3.4`

### Test Status

Expand Down
3 changes: 2 additions & 1 deletion deploy/kubernetes/images/stable-master/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ imageTag:
name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
# Don't change stable image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
newTag: "v1.2.1-gke.0"
newName: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver
newTag: "v1.3.4"
---
44 changes: 43 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/gcp-compute-persistent-disk-csi-driver

go 1.13
go 1.17

require (
cloud.google.com/go v0.65.0
Expand Down Expand Up @@ -32,6 +32,48 @@ require (
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v0.2.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/go-cmp v0.5.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/json-iterator/go v1.1.8 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.4.1 // indirect
github.com/prometheus/procfs v0.0.8 // indirect
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
k8s.io/klog/v2 v2.4.0 // indirect
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace k8s.io/api => k8s.io/api v0.18.0

replace k8s.io/apimachinery => k8s.io/apimachinery v0.18.0
Expand Down
40 changes: 4 additions & 36 deletions pkg/gce-cloud-provider/compute/fake-gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"

"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/uuid"
)

const (
Expand Down Expand Up @@ -115,43 +114,12 @@ func (cloud *FakeCloudProvider) ListZones(ctx context.Context, region string) ([
return []string{cloud.zone, "country-region-fakesecondzone"}, nil
}

func (cloud *FakeCloudProvider) ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error) {
// Ignore page tokens for now
var seen sets.String
var ok bool
var count int64 = 0
var newToken string
func (cloud *FakeCloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error) {
d := []*computev1.Disk{}

if pageToken != "" {
seen, ok = cloud.pageTokens[pageToken]
if !ok {
return nil, "", invalidError()
}
} else {
seen = sets.NewString()
}

if maxEntries == 0 {
maxEntries = 500
}

for name, cd := range cloud.disks {
// Only return v1 disks for simplicity
if !seen.Has(name) {
d = append(d, cd.disk)
seen.Insert(name)
count++
}

if count >= maxEntries {
newToken = string(uuid.NewUUID())
cloud.pageTokens[newToken] = seen
break
}
for _, cd := range cloud.disks {
d = append(d, cd.disk)
}

return d, newToken, nil
return d, "", nil
}

func (cloud *FakeCloudProvider) ListSnapshots(ctx context.Context, filter string, maxEntries int64, pageToken string) ([]*computev1.Snapshot, string, error) {
Expand Down
32 changes: 22 additions & 10 deletions pkg/gce-cloud-provider/compute/gce-compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type GCECompute interface {
GetDiskTypeURI(project string, volKey *meta.Key, diskType string) string
WaitForAttach(ctx context.Context, project string, volKey *meta.Key, instanceZone, instanceName string) error
ResizeDisk(ctx context.Context, project string, volKey *meta.Key, requestBytes int64) (int64, error)
ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error)
ListDisks(ctx context.Context) ([]*computev1.Disk, string, error)
// Regional Disk Methods
GetReplicaZoneURI(project string, zone string) string
// Instance Methods
Expand All @@ -89,19 +89,31 @@ func (cloud *CloudProvider) GetDefaultZone() string {

// ListDisks lists disks based on maxEntries and pageToken only in the project
// and zone that the driver is running in.
func (cloud *CloudProvider) ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error) {
lCall := cloud.service.Disks.List(cloud.project, cloud.zone)
if maxEntries != 0 {
lCall = lCall.MaxResults(maxEntries)
}
if len(pageToken) != 0 {
lCall = lCall.PageToken(pageToken)
func (cloud *CloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error) {
region, err := common.GetRegionFromZones([]string{cloud.zone})
if err != nil {
return nil, "", fmt.Errorf("failed to get region from zones: %v", err)
}
diskList, err := lCall.Do()
zones, err := cloud.ListZones(ctx, region)
if err != nil {
return nil, "", err
}
return diskList.Items, diskList.NextPageToken, nil
items := []*computev1.Disk{}

for _, zone := range zones {
lCall := cloud.service.Disks.List(cloud.project, zone)
nextPageToken := "pageToken"
for nextPageToken != "" {
diskList, err := lCall.Do()
if err != nil {
return nil, "", err
}
items = append(items, diskList.Items...)
nextPageToken = diskList.NextPageToken
lCall.PageToken(nextPageToken)
}
}
return items, "", nil
}

// RepairUnderspecifiedVolumeKey will query the cloud provider and check each zone for the disk specified
Expand Down
48 changes: 36 additions & 12 deletions pkg/gce-pd-csi-driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/klog"

"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
Expand All @@ -39,6 +40,9 @@ type GCEControllerServer struct {
Driver *GCEDriver
CloudProvider gce.GCECompute

disks []*compute.Disk
seen map[string]int

// A map storing all volumes with ongoing operations so that additional
// operations for that same volume (as defined by Volume Key) return an
// Aborted error
Expand Down Expand Up @@ -524,22 +528,36 @@ func (gceCS *GCEControllerServer) ListVolumes(ctx context.Context, req *csi.List
// https://cloud.google.com/compute/docs/reference/beta/disks/list
if req.MaxEntries < 0 {
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf(
"ListVolumes got max entries request %v. GCE only supports values between 0-500", req.MaxEntries))
}
var maxEntries int64 = int64(req.MaxEntries)
if maxEntries > 500 {
klog.Warningf("ListVolumes requested max entries of %v, GCE only supports values <=500 so defaulting value back to 500", maxEntries)
maxEntries = 500
"ListVolumes got max entries request %v. GCE only supports values >0", req.MaxEntries))
}
diskList, nextToken, err := gceCS.CloudProvider.ListDisks(ctx, maxEntries, req.StartingToken)
if err != nil {
if gce.IsGCEInvalidError(err) {
return nil, status.Error(codes.Aborted, fmt.Sprintf("ListVolumes error with invalid request: %v", err))

offset := 0
var ok bool
if req.StartingToken == "" {
diskList, _, err := gceCS.CloudProvider.ListDisks(ctx)
if err != nil {
if gce.IsGCEInvalidError(err) {
return nil, status.Error(codes.Aborted, fmt.Sprintf("ListVolumes error with invalid request: %v", err))
}
return nil, status.Error(codes.Internal, fmt.Sprintf("Unknown list disk error: %v", err))
}
return nil, status.Error(codes.Internal, fmt.Sprintf("Unknown list disk error: %v", err))
gceCS.disks = diskList
gceCS.seen = map[string]int{}
} else {
offset, ok = gceCS.seen[req.StartingToken]
if !ok {
return nil, status.Error(codes.Aborted, fmt.Sprintf("ListVolumes error with invalid startingToken: %s", req.StartingToken))
}
}

var maxEntries int = int(req.MaxEntries)
if maxEntries == 0 {
maxEntries = len(gceCS.disks)
}

entries := []*csi.ListVolumesResponse_Entry{}
for _, d := range diskList {
for i := 0; i+offset < len(gceCS.disks) && i < maxEntries; i++ {
d := gceCS.disks[i+offset]
users := []string{}
for _, u := range d.Users {
users = append(users, cleanSelfLink(u))
Expand All @@ -554,6 +572,12 @@ func (gceCS *GCEControllerServer) ListVolumes(ctx context.Context, req *csi.List
})
}

nextToken := ""
if len(entries)+offset < len(gceCS.disks) {
nextToken = string(uuid.NewUUID())
gceCS.seen[nextToken] = len(entries) + offset
}

return &csi.ListVolumesResponse{
Entries: entries,
NextToken: nextToken,
Expand Down
10 changes: 3 additions & 7 deletions pkg/gce-pd-csi-driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ func TestCreateVolumeArguments(t *testing.T) {
}

func TestListVolumeArgs(t *testing.T) {
diskCount := 600
testCases := []struct {
name string
maxEntries int32
Expand All @@ -779,18 +780,13 @@ func TestListVolumeArgs(t *testing.T) {
}{
{
name: "normal",
expectedEntries: 500,
expectedEntries: diskCount,
},
{
name: "fine amount of entries",
maxEntries: 420,
expectedEntries: 420,
},
{
name: "too many entries, but defaults to 500",
maxEntries: 501,
expectedEntries: 500,
},
{
name: "negative entries",
maxEntries: -1,
Expand All @@ -802,7 +798,7 @@ func TestListVolumeArgs(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// Setup new driver each time so no interference
var d []*gce.CloudDisk
for i := 0; i < 600; i++ {
for i := 0; i < diskCount; i++ {
// Create 600 dummy disks
d = append(d, gce.CloudDiskFromV1(&compute.Disk{Name: fmt.Sprintf("%v", i)}))
}
Expand Down
1 change: 1 addition & 0 deletions pkg/gce-pd-csi-driver/gce-pd-driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func NewControllerServer(gceDriver *GCEDriver, cloudProvider gce.GCECompute) *GC
return &GCEControllerServer{
Driver: gceDriver,
CloudProvider: cloudProvider,
seen: map[string]int{},
volumeLocks: common.NewVolumeLocks(),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/gce-pd-csi-driver/utils_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

/*
Expand Down
Loading