Skip to content

Commit 02fe8b3

Browse files
Merge branch 'kubernetes-sigs:master' into master
2 parents 6223b23 + 10ed92e commit 02fe8b3

File tree

18 files changed

+257
-92
lines changed

18 files changed

+257
-92
lines changed

Diff for: Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ COPY --from=debian /bin/date /bin/date
7171
COPY --from=debian /bin/grep /bin/grep
7272
COPY --from=debian /bin/sed /bin/sed
7373
COPY --from=debian /bin/ln /bin/ln
74+
COPY --from=debian /bin/udevadm /bin/udevadm
7475

7576
# Copy shared libraries into distroless base.
7677
COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libblkid.so.1 \
@@ -79,6 +80,7 @@ COPY --from=debian /lib/${LIB_DIR_PREFIX}-linux-gnu/libblkid.so.1 \
7980
/lib/${LIB_DIR_PREFIX}-linux-gnu/libe2p.so.2 \
8081
/lib/${LIB_DIR_PREFIX}-linux-gnu/libext2fs.so.2 \
8182
/lib/${LIB_DIR_PREFIX}-linux-gnu/libgcc_s.so.1 \
83+
/lib/${LIB_DIR_PREFIX}-linux-gnu/liblzma.so.5 \
8284
/lib/${LIB_DIR_PREFIX}-linux-gnu/libmount.so.1 \
8385
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre.so.3 \
8486
/lib/${LIB_DIR_PREFIX}-linux-gnu/libreadline.so.5 \
@@ -93,6 +95,7 @@ COPY --from=debian /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libacl.so.1 \
9395
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicudata.so.63 \
9496
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicui18n.so.63 \
9597
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libicuuc.so.63 \
98+
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libkmod.so.2 \
9699
/usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libstdc++.so.6 /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/
97100

98101
# Copy NVME support required script and rules into distroless base.

Diff for: Dockerfile.debug

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ FROM k8s.gcr.io/build-image/debian-base-amd64:buster-v1.5.0
3333
# Copy source code too to correlate the binary and the breakpoints
3434
WORKDIR /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
3535
ADD . .
36+
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver
3637

3738
COPY --from=builder /go/bin/dlv /go/bin/dlv
3839

Diff for: OWNERS

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
reviewers:
2-
- davidz627
3-
- jingxu97
2+
- amacaskill
3+
- leiyiz
44
- mattcary
55
- msau42
6-
- saad-ali
76
- saikat-royc
87
approvers:
9-
- davidz627
10-
- jingxu97
8+
- amacaskill
9+
- leiyiz
1110
- mattcary
1211
- msau42
13-
- saad-ali
1412
- saikat-royc
13+
emeritus_reviewers:
14+
- davidz627
15+
- jingxu97
16+
- saad-ali

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The following table captures the compatibility matrix of the core persistent dis
4040
| dev | yes |
4141

4242
The manifest bundle which captures all the driver components (driver pod which includes the containers csi-provisioner, csi-resizer, csi-snapshotter, gce-pd-driver, csi-driver-registrar;
43-
csi driver object, rbacs, pod security policies etc) can be picked up from the master branch [overlays](deploy/kubernetes/overlays) directory. We structure the overlays directory, per minor version of kubernetes because not all driver components can be used with all kubernetes versions.
43+
csi driver object, rbacs, pod security policies etc) can be picked up from the master branch [overlays](deploy/kubernetes/overlays) directory. We structure the overlays directory, per minor version of kubernetes because not all driver components can be used with all kubernetes versions.
4444

4545
Example:
4646

@@ -99,7 +99,7 @@ Controller-level and node-level deployments will both have priorityClassName set
9999

100100
## Further Documentation
101101

102-
[Local Development](docs/local-development.md)
102+
[Local Development](docs/kubernetes/development.md)
103103

104104
For releasing new versions of this driver, googlers should consult [go/pdcsi-oss-release-process](go/pdcsi-oss-release-process).
105105

Diff for: cmd/gce-pd-csi-driver/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
var (
3737
cloudConfigFilePath = flag.String("cloud-config", "", "Path to GCE cloud provider config")
3838
endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint")
39+
computeEndpoint = flag.String("compute-endpoint", "", "If set, used as the endpoint for the GCE API.")
3940
runControllerService = flag.Bool("run-controller-service", true, "If set to false then the CSI driver does not activate its controller service (default: true)")
4041
runNodeService = flag.Bool("run-node-service", true, "If set to false then the CSI driver does not activate its node service (default: true)")
4142
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.")
@@ -117,7 +118,7 @@ func handle() {
117118
//Initialize requirements for the controller service
118119
var controllerServer *driver.GCEControllerServer
119120
if *runControllerService {
120-
cloudProvider, err := gce.CreateCloudProvider(ctx, version, *cloudConfigFilePath)
121+
cloudProvider, err := gce.CreateCloudProvider(ctx, version, *cloudConfigFilePath, *computeEndpoint)
121122
if err != nil {
122123
klog.Fatalf("Failed to get cloud provider: %v", err)
123124
}

Diff for: deploy/common.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function ensure_var(){
1919

2020
function get_needed_roles()
2121
{
22-
echo "roles/compute.storageAdmin roles/iam.serviceAccountUser projects/${PROJECT}/roles/gcp_compute_persistent_disk_csi_driver_custom_role"
22+
echo "roles/editor roles/compute.storageAdmin roles/iam.serviceAccountUser projects/${PROJECT}/roles/gcp_compute_persistent_disk_csi_driver_custom_role"
2323
}
2424

2525
# Installs kustomize in ${PKGDIR}/bin

Diff for: docs/kubernetes/development.md

+44
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,50 @@ To bring down driver:
1818
```
1919
$ ./deploy/kubernetes/delete-driver.sh
2020
```
21+
## Testing
22+
23+
### E2E Tests:
24+
25+
#### One time setup
26+
27+
```console
28+
$ export PROJECT=my-project # GCP Project to run tests in
29+
$ export GCE_PD_SA_NAME=$PROJECT-pd-sa # Name of the service account to create
30+
$ export GCE_PD_SA_DIR=/my/safe/credentials/directory # Directory to save the service account key
31+
$ export ENABLE_KMS=false
32+
$ ./deploy/setup-project.sh
33+
```
34+
#### Ongoing runs
35+
```console
36+
$ export PROJECT=my-project # GCP Project to run tests in
37+
$ export GCE_PD_SA_NAME=$PROJECT-pd-sa
38+
$ export IAM_NAME=$GCE_PD_SA_NAME@$PROJECT.iam.gserviceaccount.com # IAM SA that was set up in "one time setup"
39+
40+
$ ./test/run-e2e-local.sh
41+
```
42+
43+
### Sanity Tests
44+
> **_NOTE:_** Sanity tests are currently failing, tracked by https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/990.
45+
46+
Sanity tests can be run from VS Code, etc directly or via the cmd line:
47+
```
48+
$ ./test/run-sanity.sh
49+
```
50+
51+
### Unit Tests
52+
Unit tests can be run from VS Code, etc directly or via the cmd line:
53+
```
54+
$ ./test/run-unit.sh
55+
```
56+
57+
## Dependency Management
58+
59+
Use [dep](https://github.com/golang/dep)
60+
```
61+
$ dep ensure
62+
```
63+
64+
To modify dependencies or versions change `./Gopkg.toml`
2165

2266
## Debugging
2367

Diff for: docs/local-development.md

-30
This file was deleted.

Diff for: pkg/gce-cloud-provider/compute/gce.go

+21-13
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ const (
4444

4545
regionURITemplate = "projects/%s/regions/%s"
4646

47-
GCEComputeAPIEndpoint = "https://www.googleapis.com/compute/v1/"
48-
GCEComputeBetaAPIEndpoint = "https://www.googleapis.com/compute/beta/"
49-
GCEComputeAlphaAPIEndpoint = "https://www.googleapis.com/compute/alpha/"
50-
5147
replicaZoneURITemplateSingleZone = "projects/%s/zones/%s" // {gce.projectID}/zones/{disk.Zone}
5248
)
5349

@@ -73,7 +69,7 @@ type ConfigGlobal struct {
7369
Zone string `gcfg:"zone"`
7470
}
7571

76-
func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath string) (*CloudProvider, error) {
72+
func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath string, computeEndpoint string) (*CloudProvider, error) {
7773
configFile, err := readConfig(configPath)
7874
if err != nil {
7975
return nil, err
@@ -88,12 +84,12 @@ func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath s
8884
return nil, err
8985
}
9086

91-
svc, err := createCloudService(ctx, vendorVersion, tokenSource)
87+
svc, err := createCloudService(ctx, vendorVersion, tokenSource, computeEndpoint)
9288
if err != nil {
9389
return nil, err
9490
}
9591

96-
betasvc, err := createBetaCloudService(ctx, vendorVersion, tokenSource)
92+
betasvc, err := createBetaCloudService(ctx, vendorVersion, tokenSource, computeEndpoint)
9793
if err != nil {
9894
return nil, err
9995
}
@@ -159,30 +155,42 @@ func readConfig(configPath string) (*ConfigFile, error) {
159155
return cfg, nil
160156
}
161157

162-
func createBetaCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource) (*computebeta.Service, error) {
158+
func createBetaCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource, computeEndpoint string) (*computebeta.Service, error) {
163159
client, err := newOauthClient(ctx, tokenSource)
164160
if err != nil {
165161
return nil, err
166162
}
167-
service, err := computebeta.NewService(ctx, option.WithHTTPClient(client))
163+
164+
computeOpts := []option.ClientOption{option.WithHTTPClient(client)}
165+
if computeEndpoint != "" {
166+
betaEndpoint := fmt.Sprintf("%s/compute/beta/", computeEndpoint)
167+
computeOpts = append(computeOpts, option.WithEndpoint(betaEndpoint))
168+
}
169+
service, err := computebeta.NewService(ctx, computeOpts...)
168170
if err != nil {
169171
return nil, err
170172
}
171173
service.UserAgent = fmt.Sprintf("GCE CSI Driver/%s (%s %s)", vendorVersion, runtime.GOOS, runtime.GOARCH)
172174
return service, nil
173175
}
174176

175-
func createCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource) (*compute.Service, error) {
176-
svc, err := createCloudServiceWithDefaultServiceAccount(ctx, vendorVersion, tokenSource)
177+
func createCloudService(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource, computeEndpoint string) (*compute.Service, error) {
178+
svc, err := createCloudServiceWithDefaultServiceAccount(ctx, vendorVersion, tokenSource, computeEndpoint)
177179
return svc, err
178180
}
179181

180-
func createCloudServiceWithDefaultServiceAccount(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource) (*compute.Service, error) {
182+
func createCloudServiceWithDefaultServiceAccount(ctx context.Context, vendorVersion string, tokenSource oauth2.TokenSource, computeEndpoint string) (*compute.Service, error) {
181183
client, err := newOauthClient(ctx, tokenSource)
182184
if err != nil {
183185
return nil, err
184186
}
185-
service, err := compute.New(client)
187+
188+
computeOpts := []option.ClientOption{option.WithHTTPClient(client)}
189+
if computeEndpoint != "" {
190+
v1Endpoint := fmt.Sprintf("%s/compute/v1/", computeEndpoint)
191+
computeOpts = append(computeOpts, option.WithEndpoint(v1Endpoint))
192+
}
193+
service, err := compute.NewService(ctx, computeOpts...)
186194
if err != nil {
187195
return nil, err
188196
}

Diff for: pkg/gce-pd-csi-driver/controller.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"context"
1919
"fmt"
2020
"math/rand"
21+
"regexp"
2122
"sort"
22-
"strings"
2323
"time"
2424

2525
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
@@ -1526,9 +1526,8 @@ func generateCreateVolumeResponse(disk *gce.CloudDisk, zones []string) *csi.Crea
15261526
}
15271527

15281528
func cleanSelfLink(selfLink string) string {
1529-
temp := strings.TrimPrefix(selfLink, gce.GCEComputeAPIEndpoint)
1530-
temp = strings.TrimPrefix(temp, gce.GCEComputeBetaAPIEndpoint)
1531-
return strings.TrimPrefix(temp, gce.GCEComputeAlphaAPIEndpoint)
1529+
r, _ := regexp.Compile("https:\\/\\/www.*apis.com\\/.*(v1|beta|alpha)\\/")
1530+
return r.ReplaceAllString(selfLink, "")
15321531
}
15331532

15341533
func createRegionalDisk(ctx context.Context, cloudProvider gce.GCECompute, name string, zones []string, params common.DiskParameters, capacityRange *csi.CapacityRange, capBytes int64, snapshotID string, volumeContentSourceVolumeID string, multiWriter bool) (*gce.CloudDisk, error) {

Diff for: pkg/gce-pd-csi-driver/controller_test.go

+65
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,71 @@ func TestControllerPublishBackoffMissingInstance(t *testing.T) {
23192319
})
23202320
}
23212321

2322+
func TestCleanSelfLink(t *testing.T) {
2323+
testCases := []struct {
2324+
name string
2325+
in string
2326+
want string
2327+
}{
2328+
{
2329+
name: "v1 full standard w/ endpoint prefix",
2330+
in: "https://www.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk",
2331+
want: "projects/project/zones/zone/disks/disk",
2332+
},
2333+
{
2334+
name: "beta full standard w/ endpoint prefix",
2335+
in: "https://www.googleapis.com/compute/beta/projects/project/zones/zone/disks/disk",
2336+
want: "projects/project/zones/zone/disks/disk",
2337+
},
2338+
{
2339+
name: "alpha full standard w/ endpoint prefix",
2340+
in: "https://www.googleapis.com/compute/alpha/projects/project/zones/zone/disks/disk",
2341+
want: "projects/project/zones/zone/disks/disk",
2342+
},
2343+
{
2344+
name: "no prefix",
2345+
in: "projects/project/zones/zone/disks/disk",
2346+
want: "projects/project/zones/zone/disks/disk",
2347+
},
2348+
2349+
{
2350+
name: "no prefix + project omitted",
2351+
in: "zones/zone/disks/disk",
2352+
want: "zones/zone/disks/disk",
2353+
},
2354+
{
2355+
name: "Compute prefix, google api",
2356+
in: "https://www.compute.googleapis.com/compute/v1/projects/project/zones/zone/disks/disk",
2357+
want: "projects/project/zones/zone/disks/disk",
2358+
},
2359+
{
2360+
name: "Compute prefix, partner api",
2361+
in: "https://www.compute.PARTNERapis.com/compute/v1/projects/project/zones/zone/disks/disk",
2362+
want: "projects/project/zones/zone/disks/disk",
2363+
},
2364+
{
2365+
name: "Partner beta api",
2366+
in: "https://www.PARTNERapis.com/compute/beta/projects/project/zones/zone/disks/disk",
2367+
want: "projects/project/zones/zone/disks/disk",
2368+
},
2369+
{
2370+
name: "Partner alpha api",
2371+
in: "https://www.partnerapis.com/compute/alpha/projects/project/zones/zone/disks/disk",
2372+
want: "projects/project/zones/zone/disks/disk",
2373+
},
2374+
}
2375+
2376+
// Run test cases
2377+
for _, tc := range testCases {
2378+
t.Run(tc.name, func(t *testing.T) {
2379+
got := cleanSelfLink(tc.in)
2380+
if got != tc.want {
2381+
t.Errorf("Expected cleaned self link: %v, got: %v", tc.want, got)
2382+
}
2383+
})
2384+
}
2385+
}
2386+
23222387
func backoffTesterForPublish(t *testing.T, config *backoffTesterConfig) {
23232388
readyToExecute := make(chan chan gce.Signal)
23242389
cloudDisks := []*gce.CloudDisk{

Diff for: release-tools/KUBERNETES_CSI_OWNERS_ALIASES

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ aliases:
2727
- jingxu97
2828
- jsafrane
2929
- pohly
30+
- RaunakShah
3031
- xing-yang
3132

3233
# This documents who previously contributed to Kubernetes-CSI

0 commit comments

Comments
 (0)