Skip to content
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

Add FromFile and FromExistingClassName support for SnapshotClass in external storage e2e test #88669

Merged
merged 1 commit into from Mar 4, 2020

Conversation

mkimuram
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
This PR is to add a feature to pass parameters to SnapshotClass in e2e test via FromFile option. This is needed for CSI drivers to pass parameters like secret to SnapshotClass.

Which issue(s) this PR fixes:
Fixes #88668

Special notes for your reviewer:
/sig storage
/sig testing
cc @pohly @wongma7 @xing-yang @oomichi

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 28, 2020
@mkimuram
Copy link
Contributor Author

This will allow users to pass user defined SnapshotClass like below way.

# cat << EOF > /tmp/hostpath-testdriver-from-file.yaml
StorageClass:
  FromName: true
SnapshotClass:
  FromFile: "/tmp/snapshot-class.yaml"
DriverInfo:
  Name: hostpath.csi.k8s.io
  Capabilities:
    persistence: true
    snapshotDataSource: true
EOF

# cat << EOF > /tmp/snapshot-class.yaml
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshotClass
metadata:
  name: csi-hostpath-snapclass
driver: hostpath.csi.k8s.io
deletionPolicy: Delete
parameters:
  csi.storage.k8s.io/snapshotter-secret-name: snapshot-secret
  csi.storage.k8s.io/snapshotter-secret-namespace: default
EOF

# ginkgo -p -focus='External.Storage.*hostpath.*snap.*' e2e.test -- -storage.testdriver=/tmp/hostpath-testdriver-from-file.yaml

Note that due to the change in SnapshotClass in v1.17, we need to back port this PR to v1.16 or prior and run back ported version of e2e binary, if e2e test is required for v1.16 or prior. (E2E test binary for certain version creates SnapshotClass for the API of its binary version, not k8s cluster's version. So, running latest e2e binary in older k8s cluster won't work if there's API incompatibility.)

Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2020
@xing-yang
Copy link
Contributor

/lgtm

@mkimuram
Copy link
Contributor Author

/retest

@oomichi
Copy link
Member

oomichi commented Feb 28, 2020

Thanks for doing this.

/lgtm

//
// This can be used when the snapshot class is meant to have
// additional parameters.
FromFile string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a "From Existing" option, similar to Storage Class above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. I will work on it.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2020
@mkimuram
Copy link
Contributor Author

Added FromExistingClassName for SnapshotClass. It works like below way. PTAL

# kubectl get volumesnapshotclasses
NAME                     AGE
csi-hostpath-snapclass   8d

# cat << EOF > /tmp/hostpath-testdriver-FromExistingClassName.yaml
StorageClass:
  FromName: true
SnapshotClass:
  FromExistingClassName: csi-hostpath-snapclass
DriverInfo:
  Name: hostpath.csi.k8s.io
  Capabilities:
    persistence: true
    snapshotDataSource: true
EOF

# ginkgo -p -focus='External.Storage.*hostpath.*snap.*' e2e.test -- -storage.testdriver=/tmp/hostpath-testdriver-FromExistingClassName.yaml

Note that:

  • Without clearing resourceVersion, resource creation fails with "resourceVersion should not be set on objects to be created" error.
  • For StorageClass's FromExistingClassName, rename is done in testsuites.GetStorageClass, but for SnapshotClass's FromExistingClassName rename is done directly.

@mkimuram
Copy link
Contributor Author

/retest

@xing-yang
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 29, 2020
snapshotGVR = schema.GroupVersionResource{Group: snapshotGroup, Version: "v1beta1", Resource: "volumesnapshots"}
snapshotClassGVR = schema.GroupVersionResource{Group: snapshotGroup, Version: "v1beta1", Resource: "volumesnapshotclasses"}
snapshotContentGVR = schema.GroupVersionResource{Group: snapshotGroup, Version: "v1beta1", Resource: "volumesnapshotcontents"}
SnapshotGVR = schema.GroupVersionResource{Group: snapshotGroup, Version: "v1beta1", Resource: "volumesnapshots"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing it out. Fixed.

@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 2, 2020
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 2, 2020
@mkimuram
Copy link
Contributor Author

mkimuram commented Mar 2, 2020

Resolved merge conflict.

@mkimuram
Copy link
Contributor Author

mkimuram commented Mar 3, 2020

/retest

Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2020
@pohly
Copy link
Contributor

pohly commented Mar 3, 2020

/approve

case d.SnapshotClass.FromName:
snapshotter := d.DriverInfo.Name
parameters := map[string]string{}
ns := config.Framework.Namespace.Name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have all 3 cases use GetSnapshotClass so that they all use the same ns and suffix formats?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that it would be nice to do so, after I wrote my last comment.
However, to do so, we need to get parameters from *unstructured.Unstructured. Is there a good way to achieve it? I couldn't find a good way from here.

Copy link
Member

@msau42 msau42 Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does something like this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and rebased. PTAL

snapshotter := d.DriverInfo.Name
parameters := map[string]string{}
ns := config.Framework.Namespace.Name
suffix := snapshotter + "-vsc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suffix should just be "-vsc"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it came from the original code. And it could be both, because it adds ns to suffix inside GetSnapshotClass to be unique. (If there will be a test case that creates multiple SnapshotClass, it's safe to keep snapshotter, though.)

Copy link
Contributor Author

@mkimuram mkimuram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msau42

Thank you for your review.

I'll change both if you prefer and tell me how on getting parameters.

case d.SnapshotClass.FromName:
snapshotter := d.DriverInfo.Name
parameters := map[string]string{}
ns := config.Framework.Namespace.Name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that it would be nice to do so, after I wrote my last comment.
However, to do so, we need to get parameters from *unstructured.Unstructured. Is there a good way to achieve it? I couldn't find a good way from here.

snapshotter := d.DriverInfo.Name
parameters := map[string]string{}
ns := config.Framework.Namespace.Name
suffix := snapshotter + "-vsc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it came from the original code. And it could be both, because it adds ns to suffix inside GetSnapshotClass to be unique. (If there will be a test case that creates multiple SnapshotClass, it's safe to keep snapshotter, though.)

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 3, 2020
@mkimuram mkimuram changed the title Add FromFile support for SnapshotClass in external storage e2e test Add FromFile and FromExistingClassName support for SnapshotClass in external storage e2e test Mar 3, 2020
@mkimuram
Copy link
Contributor Author

mkimuram commented Mar 3, 2020

/retest

@msau42
Copy link
Member

msau42 commented Mar 3, 2020

/lgtm
/approve
Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mkimuram, msau42, pohly

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 3, 2020
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit c2593d3 into kubernetes:master Mar 4, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E2E storage: SnapshotClass needs FromFile to pass parameters
7 participants