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

Support dynamic provisioning for CSI migration scenarios #73653

Merged
merged 1 commit into from
Feb 28, 2019
Merged

Support dynamic provisioning for CSI migration scenarios #73653

merged 1 commit into from
Feb 28, 2019

Conversation

ddebroy
Copy link
Member

@ddebroy ddebroy commented Feb 2, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:
This PR introduces a set of changes needed in in-tree PV Controller to call out to the external provisioning controller for in-tree plugins if they are migratable to CSI. The basic steps are:

  1. Check if in-tree plugin is migratable to CSI. If so:
  2. Set annStorageProvisioner in the PVC to CSI plugin name that superseded the specified in-tree plugin.
  3. Do not proceed with in-tree provisioning and return so that external provisioner can act on the claim.

In addition to the above, the PR also introduces a new API TranslateInTreeStorageClassParametersToCSI in the CSI translation staging repo. This will be used by the external provisioner to translate from in-tree storage class parameters to CSI plugin parameters.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
Part of enhancements for kubernetes/enhancements#625

For the changes in this PR to take an effect, we need a separate set of changes in https://github.com/kubernetes-sigs/sig-storage-lib-external-provisioner.git which does the following:

  1. Enhances getStorageClassFields to check (through GetCSINameFromIntreeName) if the storageclass provisioner has a corresponding CSI plugin that supersedes it. If so:
  2. Makes getStorageClassFields aware that it's handling dynamic volume provisioning for an in-tree plugin that has been migrated to CSI because [a] For regular in-tree provisioning path, external provisioning will never get invoked [b] For regular CSI provisioning path, GetCSINameFromIntreeName would not return anything for a CSI plugin name.
  3. Enhances getStorageClassFields to [a] translate in-tree storage class parameters to the corresponding CSI plugin parameters using TranslateInTreeStorageClassParametersToCSI [b] return the CSI plugin name (instead of the storage class in-tree provisioner) as the provisioner name (so that it aligns with ctrl.provisionerName) and [c] return a boolean to provisionClaimOperation indicating dynamic provisioning in a CSI migration context
  4. Enhances provisionClaimOperation to invoke TranslateCSIPVToInTree for dynamic provisioning in a CSI migration context.

The above PR depends on TranslateInTreeStorageClassParametersToCSI from this PR to be staged first.

Does this PR introduce a user-facing change?:

Introduce dynamic volume provisioning shim for CSI migration

/sig-storage
/assign @jsafrane @saad-ali
/cc @msau42 @leakingtapan @davidz627

@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 Feb 2, 2019
@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 2, 2019
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 2, 2019
@ddebroy ddebroy changed the title Provisioning changes for CSI migration Support dynamic provisioning for CSI migration scenarios Feb 2, 2019
@ddebroy
Copy link
Member Author

ddebroy commented Feb 2, 2019

/sig storage

@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label Feb 2, 2019
@davidz627
Copy link
Contributor

@ddebroy thanks for this PR! I will review shortly.

Would recommend that you create a separate PR for the translation library staging change. Since the external provisioner depends on it lets fast track that and merge it separately.

// Set provisionerName to CSI plugin name for setClaimProvisioner
provisionerName, err = csitranslation.GetCSINameFromIntreeName(storageClass.Provisioner)
if err != nil {
strerr := fmt.Sprintf("Failed to get CSI name for In tree plugin: %s", storageClass.Provisioner)
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 print the err so it's in strerr itself?
  • also we can drop the klog as we are returning the err as well as logging it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The convention in provisionClaimOperation appears to be to klog.V(2|3).Infof(...) all errors besides returning them as well as reporting the event with ctrl.eventRecorder.Event. So I was following the convention elsewhere in provisionClaimOperation. @jsafrane please confirm the convention.

I will change the error message to include the whole error as suggested.

@ddebroy
Copy link
Member Author

ddebroy commented Feb 5, 2019

PR #73734 supersedes the csi-translation-lib bits of of this PR.

if plugin != nil {
pluginName = plugin.GetPluginName()
if plugin.IsMigratedToCSI() {
Copy link
Member

Choose a reason for hiding this comment

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

Please add an unit test for this. "11-17 - external provisioner" could be a good start. You need to inject a volume plugin that's migrated to CSI, some variant of wrapTestWithPluginCalls might be sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated PR with 11-21 - external provisioner for CSI migration testcase to make sure for CSI migration scenarios, provisioning ends up waiting for a claim with annotation vendor.com/MockCSIPlugin and event Normal ExternalProvisioning.

@@ -40,6 +40,11 @@ func NewAWSElasticBlockStoreCSITranslator() InTreePlugin {
return &awsElasticBlockStoreCSITranslator{}
}

// TranslateInTreeStorageClassParametersToCSI translates InTree EBS storage class parameters to CSI storage class
Copy link
Member

Choose a reason for hiding this comment

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

IMO, this can be removed now.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2019
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 25, 2019
Copy link
Member

@jsafrane jsafrane left a comment

Choose a reason for hiding this comment

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

Thanks for the test! Please remove one commented-out line and I think we're good to go.


// For testing only: hook to intercept CSI driver name <=> Intree plugin name mapping
// Not used when set to nil
csiNameFromIntreeNameHook func(pluginName string) (string, error)
Copy link
Member

Choose a reason for hiding this comment

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

In long term it would be better if CSI translation library provided an interface instead of function calls so its callers can create fake implementations for unit tests. As a separate PR, of course, no need to fix it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree.

Copy link
Contributor

Choose a reason for hiding this comment

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

xref" #74594

// of not setting pluginName for external provisioners (including CSI)
// Set provisionerName to CSI plugin name for setClaimProvisioner
provisionerName, err = ctrl.getCSINameFromIntreeName(storageClass.Provisioner)
// provisionerName, err = csitranslation.GetCSINameFromIntreeName(storageClass.Provisioner)
Copy link
Member

Choose a reason for hiding this comment

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

nit: please remove

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Deep Debroy <ddebroy@docker.com>
@ddebroy
Copy link
Member Author

ddebroy commented Feb 26, 2019

Addressed code review comment and squashed commits

@davidz627
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 26, 2019
@jsafrane
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ddebroy, jsafrane

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 Feb 27, 2019
@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.

2 similar comments
@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.

@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.

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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.

None yet

7 participants