Skip to content

Commit 61fe1b9

Browse files
committed
Merge branch 'master' into 3751-volume-attribute-class
2 parents 799ca64 + 5362aab commit 61fe1b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2887
-853
lines changed

Dockerfile

+23-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM --platform=$BUILDPLATFORM golang:1.22.3 as builder
15+
FROM --platform=$BUILDPLATFORM golang:1.22.4 as builder
1616

1717
ARG STAGINGVERSION
1818
ARG TARGETPLATFORM
@@ -22,13 +22,15 @@ ADD . .
2222
RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') GCE_PD_CSI_STAGING_VERSION=$STAGINGVERSION make gce-pd-driver
2323

2424
# Start from Kubernetes Debian base.
25-
FROM gke.gcr.io/debian-base:bullseye-v1.4.3-gke.5 as debian
25+
26+
FROM gke.gcr.io/debian-base:bookworm-v1.0.3-gke.0 as debian
27+
2628
# Install necessary dependencies
2729
# google_nvme_id script depends on the following packages: nvme-cli, xxd, bash
2830
RUN clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs nvme-cli xxd bash
2931

3032
# Since we're leveraging apt to pull in dependencies, we use `gcr.io/distroless/base` because it includes glibc.
31-
FROM gcr.io/distroless/base-debian11 as distroless-base
33+
FROM gcr.io/distroless/base-debian12 as distroless-base
3234

3335
# The distroless amd64 image has a target triplet of x86_64
3436
FROM distroless-base AS distroless-amd64
@@ -72,8 +74,7 @@ COPY --from=debian /bin/ln /bin/ln
7274
COPY --from=debian /bin/udevadm /bin/udevadm
7375

7476
# Copy shared libraries into distroless base.
75-
COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre.so.3 \
76-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 \
77+
COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 \
7778
/lib/${LIB_DIR_PREFIX}-linux-gnu/libtinfo.so.6 \
7879
/lib/${LIB_DIR_PREFIX}-linux-gnu/libe2p.so.2 \
7980
/lib/${LIB_DIR_PREFIX}-linux-gnu/libcom_err.so.2 \
@@ -82,7 +83,20 @@ COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre.so.3 \
8283
/lib/${LIB_DIR_PREFIX}-linux-gnu/libgcc_s.so.1 \
8384
/lib/${LIB_DIR_PREFIX}-linux-gnu/liblzma.so.5 \
8485
/lib/${LIB_DIR_PREFIX}-linux-gnu/libreadline.so.8 \
85-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libz.so.1 /lib/${LIB_DIR_PREFIX}-linux-gnu/
86+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libz.so.1 \
87+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6 \
88+
/lib/${LIB_DIR_PREFIX}-linux-gnu/liburcu.so.8 \
89+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libcap.so.2 \
90+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libcrypto.so.3 \
91+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libdbus-1.so.3 \
92+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libgcrypt.so.20 \
93+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libjson-c.so.5 \
94+
/lib/${LIB_DIR_PREFIX}-linux-gnu/liblz4.so.1 \
95+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libm.so.6 \
96+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libnvme-mi.so.1 \
97+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libnvme.so.1 \
98+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libsystemd.so.0 \
99+
/lib/${LIB_DIR_PREFIX}-linux-gnu/libzstd.so.1 /lib/${LIB_DIR_PREFIX}-linux-gnu/
86100

87101
COPY --from=debian /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libblkid.so.1 \
88102
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libbsd.so.0 \
@@ -93,9 +107,9 @@ COPY --from=debian /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libblkid.so.1 \
93107
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libacl.so.1 \
94108
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libattr.so.1 \
95109
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libedit.so.2 \
96-
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicudata.so.67 \
97-
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicui18n.so.67 \
98-
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicuuc.so.67 \
110+
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicudata.so.72 \
111+
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicui18n.so.72 \
112+
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicuuc.so.72 \
99113
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libkmod.so.2 \
100114
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libmd.so.0 \
101115
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 \

Dockerfile.Windows

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
ARG BASE_IMAGE
16-
FROM --platform=$BUILDPLATFORM golang:1.22.3 AS builder
16+
FROM --platform=$BUILDPLATFORM golang:1.22.4 AS builder
1717

1818
ARG TARGETPLATFORM
1919
ARG STAGINGVERSION

Dockerfile.debug

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.22.3 as builder
15+
FROM golang:1.22.4 as builder
1616
WORKDIR /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
1717
ADD . .
1818

cmd/gce-pd-csi-driver/main.go

+41-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"time"
2929

3030
"k8s.io/klog/v2"
31+
"k8s.io/utils/strings/slices"
3132

3233
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
3334
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/deviceutils"
@@ -98,7 +99,7 @@ func init() {
9899
// Use V(4) for general debug information logging
99100
// Use V(5) for GCE Cloud Provider Call informational logging
100101
// Use V(6) for extra repeated/polling information
101-
enumFlag(&computeEnvironment, "compute-environment", allowedComputeEnvironment, "Operating compute environment")
102+
stringEnumFlag(&computeEnvironment, "compute-environment", allowedComputeEnvironment, "Operating compute environment")
102103
urlFlag(&computeEndpoint, "compute-endpoint", "Compute endpoint")
103104
klog.InitFlags(flag.CommandLine)
104105
flag.Set("logtostderr", "true")
@@ -175,23 +176,23 @@ func handle() {
175176
identityServer := driver.NewIdentityServer(gceDriver)
176177

177178
// Initialize requisite zones
178-
fallbackRequisiteZones := strings.Split(*fallbackRequisiteZonesFlag, ",")
179+
fallbackRequisiteZones := parseCSVFlag(*fallbackRequisiteZonesFlag)
179180

180181
// Initialize multi-zone disk types
181-
multiZoneVolumeHandleDiskTypes := strings.Split(*multiZoneVolumeHandleDiskTypesFlag, ",")
182+
multiZoneVolumeHandleDiskTypes := parseCSVFlag(*multiZoneVolumeHandleDiskTypesFlag)
182183
multiZoneVolumeHandleConfig := driver.MultiZoneVolumeHandleConfig{
183184
Enable: *multiZoneVolumeHandleEnableFlag,
184185
DiskTypes: multiZoneVolumeHandleDiskTypes,
185186
}
186187

187188
// Initialize waitForAttach config
188-
useInstanceAPIOnWaitForAttachDiskTypes := strings.Split(*useInstanceAPIOnWaitForAttachDiskTypesFlag, ",")
189+
useInstanceAPIOnWaitForAttachDiskTypes := parseCSVFlag(*useInstanceAPIOnWaitForAttachDiskTypesFlag)
189190
waitForAttachConfig := gce.WaitForAttachConfig{
190191
UseInstancesAPIForDiskTypes: useInstanceAPIOnWaitForAttachDiskTypes,
191192
}
192193

193194
// Initialize listVolumes config
194-
instancesListFilters := strings.Split(*instancesListFiltersFlag, ",")
195+
instancesListFilters := parseCSVFlag(*instancesListFiltersFlag)
195196
listInstancesConfig := gce.ListInstancesConfig{
196197
Filters: instancesListFilters,
197198
}
@@ -252,18 +253,48 @@ func handle() {
252253
gceDriver.Run(*endpoint, *grpcLogCharCap, *enableOtelTracing)
253254
}
254255

255-
func enumFlag(target *gce.Environment, name string, allowedComputeEnvironment []gce.Environment, usage string) {
256+
func notEmpty(v string) bool {
257+
return v != ""
258+
}
259+
260+
func parseCSVFlag(list string) []string {
261+
return slices.Filter(nil, strings.Split(list, ","), notEmpty)
262+
}
263+
264+
type enumConverter[T any] interface {
265+
convert(v string) (T, error)
266+
eq(a, b T) bool
267+
}
268+
269+
type stringConverter[T ~string] struct{}
270+
271+
func (s stringConverter[T]) convert(v string) (T, error) {
272+
return T(v), nil
273+
}
274+
275+
func (s stringConverter[T]) eq(a, b T) bool {
276+
return a == b
277+
}
278+
279+
func stringEnumFlag[T ~string](target *T, name string, allowed []T, usage string) {
280+
enumFlag(target, name, stringConverter[T]{}, allowed, usage)
281+
}
282+
283+
func enumFlag[T any](target *T, name string, converter enumConverter[T], allowed []T, usage string) {
256284
flag.Func(name, usage, func(flagValue string) error {
257-
for _, allowedValue := range allowedComputeEnvironment {
258-
if gce.Environment(flagValue) == allowedValue {
259-
*target = gce.Environment(flagValue)
285+
tValue, err := converter.convert(flagValue)
286+
if err != nil {
287+
return err
288+
}
289+
for _, allowedValue := range allowed {
290+
if converter.eq(allowedValue, tValue) {
291+
*target = tValue
260292
return nil
261293
}
262294
}
263295
errMsg := fmt.Sprintf(`must be one of %v`, allowedComputeEnvironment)
264296
return errors.New(errMsg)
265297
})
266-
267298
}
268299

269300
func urlFlag(target **url.URL, name string, usage string) {

go.mod

+13-13
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ require (
2222
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0
2323
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0
2424
go.opentelemetry.io/otel/sdk v1.24.0
25-
golang.org/x/oauth2 v0.20.0
26-
golang.org/x/sys v0.20.0
25+
golang.org/x/oauth2 v0.21.0
26+
golang.org/x/sys v0.21.0
2727
golang.org/x/time v0.5.0
28-
google.golang.org/api v0.182.0
29-
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda
28+
google.golang.org/api v0.183.0
29+
google.golang.org/genproto v0.0.0-20240528184218-531527333157
3030
google.golang.org/grpc v1.64.0
3131
google.golang.org/protobuf v1.34.1
3232
gopkg.in/gcfg.v1 v1.2.3
@@ -43,7 +43,7 @@ require (
4343

4444
require (
4545
cloud.google.com/go v0.114.0 // indirect
46-
cloud.google.com/go/auth v0.5.0 // indirect
46+
cloud.google.com/go/auth v0.5.1 // indirect
4747
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
4848
cloud.google.com/go/iam v1.1.8 // indirect
4949
cloud.google.com/go/longrunning v0.5.7 // indirect
@@ -100,15 +100,15 @@ require (
100100
go.opentelemetry.io/otel/trace v1.24.0 // indirect
101101
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
102102
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
103-
golang.org/x/crypto v0.23.0 // indirect
104-
golang.org/x/mod v0.17.0 // indirect
105-
golang.org/x/net v0.25.0 // indirect
103+
golang.org/x/crypto v0.24.0 // indirect
104+
golang.org/x/mod v0.18.0 // indirect
105+
golang.org/x/net v0.26.0 // indirect
106106
golang.org/x/sync v0.7.0 // indirect
107-
golang.org/x/term v0.20.0 // indirect
108-
golang.org/x/text v0.15.0 // indirect
109-
golang.org/x/tools v0.21.0 // indirect
110-
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
111-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
107+
golang.org/x/term v0.21.0 // indirect
108+
golang.org/x/text v0.16.0 // indirect
109+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
110+
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect
111+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
112112
gopkg.in/inf.v0 v0.9.1 // indirect
113113
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
114114
gopkg.in/warnings.v0 v0.1.2 // indirect

0 commit comments

Comments
 (0)