Skip to content

Commit

Permalink
Merge pull request #290 from davidz627/fix/validateAccessModes
Browse files Browse the repository at this point in the history
Cherrypick to v0.5.0: Remove cross validation of access modes, multiple access modes can be specified that represent all the capabilities of the volume
  • Loading branch information
k8s-ci-robot authored Jun 6, 2019
2 parents 7ae2a2b + 3d6be58 commit 8a6b66a
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 53 deletions.
8 changes: 5 additions & 3 deletions deploy/kubernetes/base/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: csi-controller-sa
containers:
- name: csi-provisioner
image: gcr.io/gke-release/csi-provisioner
image: gke.gcr.io/csi-provisioner
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
Expand All @@ -25,15 +25,17 @@ spec:
- name: socket-dir
mountPath: /csi
- name: csi-attacher
image: gcr.io/gke-release/csi-attacher
image: gke.gcr.io/csi-attacher
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
volumeMounts:
- name: socket-dir
mountPath: /csi
- name: gce-pd-driver
image: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
# Don't change base image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
Expand Down
6 changes: 4 additions & 2 deletions deploy/kubernetes/base/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
serviceAccountName: csi-node-sa
containers:
- name: csi-driver-registrar
image: gcr.io/gke-release/csi-node-driver-registrar
image: gke.gcr.io/csi-node-driver-registrar
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
Expand All @@ -37,7 +37,9 @@ spec:
- name: gce-pd-driver
securityContext:
privileged: true
image: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
# Don't change base image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
containers:
- name: csi-snapshotter
imagePullPolicy: Always
image: gcr.io/gke-release/csi-snapshotter:v1.0.1-gke.0
image: gke.gcr.io/csi-snapshotter:v1.0.1-gke.0
args:
- "--v=5"
- "--csi-address=/csi/csi.sock"
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ patches:
- node_always_pull.yaml
images:
# Replace this with your private image names and tags
- name: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/REPLACEME/gcp-compute-persistent-disk-csi-driver
newTag: "latest"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ kind: Kustomization
bases:
- ../../base
images:
- name: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/gke-release-staging/gcp-compute-persistent-disk-csi-driver
newTag: "latest"
- name: gcr.io/gke-release/csi-provisioner
- name: gke.gcr.io/csi-provisioner
newName: gcr.io/gke-release-staging/csi-provisioner
newTag: "latest"
- name: gcr.io/gke-release/csi-attacher
- name: gke.gcr.io/csi-attacher
newName: gcr.io/gke-release-staging/csi-attacher
newTag: "latest"
- name: gcr.io/gke-release/csi-node-driver-registrar
- name: gke.gcr.io/csi-node-driver-registrar
newName: gcr.io/gke-release-staging/csi-node-driver-registrar
newTag: "latest"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ kind: Kustomization
bases:
- ../../base
images:
- name: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/gke-release-staging/gcp-compute-persistent-disk-csi-driver
newTag: "v0.5.0-rc1"
- name: gcr.io/gke-release/csi-provisioner
- name: gke.gcr.io/csi-provisioner
newName: gcr.io/gke-release-staging/csi-provisioner
newTag: "v1.2.0-gke.0"
- name: gcr.io/gke-release/csi-attacher
- name: gke.gcr.io/csi-attacher
newName: gcr.io/gke-release-staging/csi-attacher
newTag: "v1.1.0-gke.0"
- name: gcr.io/gke-release/csi-node-driver-registrar
- name: gke.gcr.io/csi-node-driver-registrar
newName: gcr.io/gke-release-staging/csi-node-driver-registrar
newTag: "v1.1.0-gke.0"
18 changes: 10 additions & 8 deletions deploy/kubernetes/overlays/stable/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ kind: Kustomization
bases:
- ../../base
images:
- name: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
newName: gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver
- name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
# Don't change stable image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
newName: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
newTag: "v0.5.0-gke.0"
- name: gcr.io/gke-release/csi-provisioner
newName: gcr.io/gke-release/csi-provisioner
- name: gke.gcr.io/csi-provisioner
newName: gke.gcr.io/csi-provisioner
newTag: "v1.2.0-gke.0"
- name: gcr.io/gke-release/csi-attacher
newName: gcr.io/gke-release/csi-attacher
- name: gke.gcr.io/csi-attacher
newName: gke.gcr.io/csi-attacher
newTag: "v1.1.0-gke.0"
- name: gcr.io/gke-release/csi-node-driver-registrar
newName: gcr.io/gke-release/csi-node-driver-registrar
- name: gke.gcr.io/csi-node-driver-registrar
newName: gke.gcr.io/csi-node-driver-registrar
newTag: "v1.1.0-gke.0"
25 changes: 0 additions & 25 deletions pkg/gce-pd-csi-driver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,6 @@ func validateVolumeCapabilities(vcs []*csi.VolumeCapability) error {
return err
}
}
if err := crossValidateAccessModes(vcs); err != nil {
return err
}
return nil
}

func crossValidateAccessModes(vcs []*csi.VolumeCapability) error {
m := map[csi.VolumeCapability_AccessMode_Mode]bool{}

for _, vc := range vcs {
m[vc.GetAccessMode().GetMode()] = true
}

hasWriter := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER]
hasSingleReader := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY]
hasMultiReader := m[csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY]

if hasWriter && (hasSingleReader || hasMultiReader) {
return fmt.Errorf("both SINGLE_NODE_WRITER and READER_ONLY access mode specified")
}

if hasSingleReader && hasMultiReader {
return fmt.Errorf("both SINGLE_NODE_READER_ONLY and MULTI_NODE_READY_ONLY specified")
}

return nil
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/gce-pd-csi-driver/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,18 @@ func TestValidateVolumeCapabilities(t *testing.T) {
expErr: true,
},
{
name: "fail with reader + writer capabilities",
name: "success with reader + writer capabilities",
vc: []*csi.VolumeCapability{
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
},
expErr: true,
},
{
name: "fail with different reader capabilities",
name: "success with different reader capabilities",
vc: []*csi.VolumeCapability{
createVolumeCapability(csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY),
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
},
expErr: true,
},
}

Expand Down
2 changes: 1 addition & 1 deletion test/k8s-integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var (
)

const (
pdImagePlaceholder = "gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver"
pdImagePlaceholder = "gke.gcr.io/gcp-compute-persistent-disk-csi-driver"
k8sBuildBinDir = "_output/dockerized/bin/linux/amd64"
)

Expand Down

0 comments on commit 8a6b66a

Please sign in to comment.