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

Extend allowed DataSources #220

Merged
merged 1 commit into from
Jun 12, 2019

Conversation

j-griffith
Copy link
Contributor

@j-griffith j-griffith commented Jan 29, 2019

This PR extends the supported DataSources handled by the
external-provisioner to include PVCs (Clone) and Populators (external
CRDs).

It removes the restriction of of the provisioner erroring when a
DataSource.Kind of anything other than VolumeSnapshot is supplied (the
Kubernetes API currently enforces this anyway via it's verifictaion
checks) and adds handling for a DataSource.Kind of
PersistentVolumeClaim.

Addresses: Issue #172

Does this PR introduce a user-facing change?:

Adds the ability to handle PVC as a DataSource to enable cloning for plugins that support it.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 29, 2019
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 14, 2019
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 15, 2019
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
//var timeNow = time.Now().UnixNano()
//var metaTimeNowUnix = &metav1.Time{
// Time: time.Unix(0, timeNow),
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

@j-griffith can we remove this commented code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes sorry!

@j-griffith
Copy link
Contributor Author

j-griffith commented Apr 11, 2019

Cleaned up with the rebase, should be good to go.

@msau42
Copy link
Collaborator

msau42 commented Apr 17, 2019

/assign @saad-ali

if err != nil {
return nil, fmt.Errorf("error getting PVC %s from api server: %v", options.PVC.Spec.DataSource.Name, err)
}
if string(sourcePVC.Status.Phase) != "Bound" {
Copy link
Contributor

Choose a reason for hiding this comment

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

@j-griffith I dont know whether this can land on a race , that said, by the time getPVCSource returns its available/ready , someone released it or vice versa. @jsafrane thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that's possible, I guess you'd want to add a shared mutex for the source PVC here?

if *(options.PVC.Spec.DataSource.APIGroup) != snapshotAPIGroup {
return nil, fmt.Errorf("the PVC source does not belong to the right APIGroup. Expected %s, Got %s", snapshotAPIGroup, *(options.PVC.Spec.DataSource.APIGroup))

switch options.PVC.Spec.DataSource.Kind {
Copy link
Contributor

Choose a reason for hiding this comment

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

@j-griffith we already have a getVolumeContentSource, can we make use of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @humblec thanks for pointing that out. Actually you'll notice I do utilize that helper function, I added the fetch for PVC to it and call it when we actually pull the content.

This particular check in this section was a here to validate the options and "fail fast" if they were invalid, as well as set a variable so that the provision stage later would have a flag to "getContentSource" or not. If we want to consolidate things into a single helper, that's certainly possible, but it seemed like following the flow we already have for Snapshots was a good idea here.

}
capacity := options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
requestedSize := capacity.Value()
if requestedSize < int64(sourcePVC.Spec.Size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@j-griffith There could be scenarios where resizer is processing an expansion request in the backend. So, may be checking current PVC's size and capacity could help as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, i'm not sure I follow; what do you mean the "current PVC's size and capacity"? The destination has yet to be created at this stage, so the only object that's relevant is the sourcePVC and the requested size; do you mean a resize in progress on the specified source volume?

Copy link
Contributor

@humblec humblec May 2, 2019

Choose a reason for hiding this comment

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

do you mean a resize in progress on the specified source volume?

Exactly! thats what I meant, in short, the resizer took the request and working with the driver to get it into desired state.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't checking sourcePVC.Spec alone be sufficient since it will be the largest possible value (it will be the desired size)? Validation prevents setting that value to a smaller value right?

Copy link
Contributor Author

@j-griffith j-griffith May 31, 2019

Choose a reason for hiding this comment

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

@j-griffith There could be scenarios where resizer is processing an expansion request in the backend. So, may be checking current PVC's size and capacity could help as well.

@humblec so I've thought about this a bit; and yes there's certainly a potential for a race here. That being said, we have that condition across other operations already (snapshots for example) and the challenge that's been discussed is coordinating any sort of locking/checks across the different control planes. Not to mention as @jsafrane pointed out, even across CSI provisioner nodes.

Note that this PR does fetch the source PVC object and check its capacity before processing/issuing the provision call, so I think it's doing basically what you're suggesting.

IMO this is a larger problem that needs solved independent of the cloning implementation. Whether that's new phases on the PVC, some other event tracking, or (as I think we've done thus far) the "storage device plugins problem". It sounds like this is something that's been brought up in other context and is being discussed, but we have some long term work to do here I think.

@j-griffith j-griffith force-pushed the extend_datasources branch from 839edba to 33ea9a5 Compare May 30, 2019 18:39
@k8s-ci-robot k8s-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label May 30, 2019
@j-griffith j-griffith force-pushed the extend_datasources branch from 33ea9a5 to 1dd93e3 Compare May 30, 2019 19:48
@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 30, 2019
@j-griffith j-griffith force-pushed the extend_datasources branch from 1dd93e3 to 47c105a Compare May 31, 2019 02:47
@j-griffith
Copy link
Contributor Author

/retest

Copy link
Member

@saad-ali saad-ali left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold
To give @humblec a chance to review

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 10, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: j-griffith, saad-ali

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 Jun 10, 2019
@humblec
Copy link
Contributor

humblec commented Jun 11, 2019

@j-griffith as discussed in above review comments (#220 (comment)) i see possibilities of couple of race conditions ( pvc status/capacity..etc) , however these are not really specific to this PR rather its a general problem which we have to address with a thorough design. Lets attack it later in a different discussion/PR. LGTM from my side on this PR . Thanks !!

@saad-ali I am good to get this in and thanks for giving chance for final review from my side!

@j-griffith
Copy link
Contributor Author

@j-griffith as discussed in above review comments (#220 (comment)) i see possibilities of couple of race conditions ( pvc status/capacity..etc) , however these are not really specific to this PR rather its a general problem which we have to address with a thorough design. Lets attack it later in a different discussion/PR. LGTM from my side on this PR . Thanks !!

@saad-ali I am good to get this in and thanks for giving chance for final review from my side!

Thanks @humblec I agree with you, we'll need to consider these in a broader scope.

@msau42
Copy link
Collaborator

msau42 commented Jun 12, 2019

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2019
@j-griffith
Copy link
Contributor Author

/retest

This PR extends the supported DataSources handled by the
external-provisioner to include PVCs (Clone).

It removes the restriction of of the provisioner erroring when a
DataSource.Kind of anything other than VolumeSnapshot is supplied
and adds handling for a DataSource.Kind of PersistentVolumeClaim.

This implements the ability to specify a clone, and pass that dataSource
on to plugins that report support for the capability.

Addresses: Issue kubernetes-csi#172
@j-griffith j-griffith force-pushed the extend_datasources branch from 47c105a to c7b783a Compare June 12, 2019 18:40
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2019
@j-griffith
Copy link
Contributor Author

Had to update the call I added to NewCSIProvisioner in the test file after rebase.

@msau42
Copy link
Collaborator

msau42 commented Jun 12, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2019
@k8s-ci-robot k8s-ci-robot merged commit 22bb640 into kubernetes-csi:master Jun 12, 2019
@msau42
Copy link
Collaborator

msau42 commented Jun 20, 2019

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 20, 2019
sunnylovestiramisu added a commit to sunnylovestiramisu/external-provisioner that referenced this pull request Apr 12, 2023
6613c3980 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae993d Update k8s image repo url
77e47cce8 Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b09 Fix dep version mismatch
8f839056a Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94dd5 Update go version to 1.20 to match k/k v1.27
e322ce5e5 Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a51209 test: fix golint error
aa61bfd0c Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d1963 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171bef0 Merge pull request kubernetes-csi#216 from msau42/process
cb9878261 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e47 add new reviewers and remove inactive reviewers
dd9867540 Add step for checking builds
b66c08249 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763bd filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d4277839f filter-junit.go: preserve system error log
38e11468f prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: 6613c3980d1e418bebb7bc49d64c977cfff85671
sunnylovestiramisu added a commit to sunnylovestiramisu/external-provisioner that referenced this pull request Apr 14, 2023
6613c3980 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae993d Update k8s image repo url
77e47cce8 Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b09 Fix dep version mismatch
8f839056a Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94dd5 Update go version to 1.20 to match k/k v1.27
e322ce5e5 Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a51209 test: fix golint error
aa61bfd0c Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d1963 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171bef0 Merge pull request kubernetes-csi#216 from msau42/process
cb9878261 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e47 add new reviewers and remove inactive reviewers
dd9867540 Add step for checking builds
b66c08249 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763bd filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d4277839f filter-junit.go: preserve system error log
38e11468f prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: 6613c3980d1e418bebb7bc49d64c977cfff85671
sunnylovestiramisu added a commit to sunnylovestiramisu/external-provisioner that referenced this pull request Apr 14, 2023
6613c3980 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae993d Update k8s image repo url
77e47cce8 Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b09 Fix dep version mismatch
8f839056a Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94dd5 Update go version to 1.20 to match k/k v1.27
e322ce5e5 Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a51209 test: fix golint error
aa61bfd0c Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d1963 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171bef0 Merge pull request kubernetes-csi#216 from msau42/process
cb9878261 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e47 add new reviewers and remove inactive reviewers
dd9867540 Add step for checking builds
b66c08249 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763bd filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d4277839f filter-junit.go: preserve system error log
38e11468f prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: 6613c3980d1e418bebb7bc49d64c977cfff85671
kbsonlong pushed a commit to kbsonlong/external-provisioner that referenced this pull request Dec 29, 2023
kbsonlong pushed a commit to kbsonlong/external-provisioner that referenced this pull request Dec 29, 2023
6613c398 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae993 Update k8s image repo url
77e47cce Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b0 Fix dep version mismatch
8f839056 Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94dd Update go version to 1.20 to match k/k v1.27
e322ce5e Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a5120 test: fix golint error
aa61bfd0 Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d196 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171bef Merge pull request kubernetes-csi#216 from msau42/process
cb987826 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e4 add new reviewers and remove inactive reviewers
dd986754 Add step for checking builds
b66c0824 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763b filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d4277839 filter-junit.go: preserve system error log
38e11468 prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: 6613c3980d1e418bebb7bc49d64c977cfff85671
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. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants