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 a persistent volume label controller to the cloud-controller-manager #44680

Merged
merged 1 commit into from
Sep 1, 2017

Conversation

rrati
Copy link

@rrati rrati commented Apr 19, 2017

Part of kubernetes/enhancements#88

Outstanding concerns needing input:

I'm willing to work on addressing the removal of the direct linkage to aws/gce after this PR gets in.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 19, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@rrati
Copy link
Author

rrati commented Apr 19, 2017

@wlan0

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note-label-needed labels Apr 19, 2017
@justinsb
Copy link
Member

So AFAICT the magic here is to set "Phase" to Pending.

  1. Do we avoid doing anything with the volume while the Phase is Pending? I'm not familiar with it, and want to be sure there's not going to be a race.
  2. It looks like the volume will be stuck in Pending if no labels are applied with AWS/GCE, or for all non AWS/GCE volumes?
  3. If we're removing from apiserver, this makes running cloud-controller-manager mandatory in 1.7. Has that been decided?

@wlan0
Copy link
Member

wlan0 commented Apr 19, 2017

So AFAICT the magic here is to set "Phase" to Pending.

What's the latest on the generic admission controller that you were working on. Honestly, that would satisfy this use-case better.

  1. It looks like the volume will be stuck in Pending if no labels are applied with AWS/GCE, or for all non AWS/GCE volumes?

Yeah, that's not ok. The previous behavior was -

  1. If the admission controller was activated, and the labels couldn't be obtained for EBS/PD, then PV creation failed.
  2. In case of other PV types, the admission controller simply let the creation happen.
  1. If we're removing from apiserver, this makes running cloud-controller-manager mandatory in 1.7. Has that been decided?

We are NOT making ccm mandatory in 1.7.

@rrati
Copy link
Author

rrati commented Apr 20, 2017

   It looks like the volume will be stuck in Pending if no labels are applied with AWS/GCE, or for all non AWS/GCE volumes?

Yeah, that's not ok. The previous behavior was -

If the admission controller was activated, and the labels couldn't be obtained for EBS/PD, then PV creation failed.
In case of other PV types, the admission controller simply let the creation happen.

I looked at conditionalizing the setting of the status, but it looks like the pv-controller sets the status to Available when performing a sync or when the pv is unbound. That should handle setting the pv to Available for non-cloud pv shouldn't it? If not I could set the status only for GCE or AWS volumes.

Taking this approach would allow us to completely deprecate the admission plugin in the future. When the ccm becomes mandatory there will really be no need for the admission plugin at all.

   If we're removing from apiserver, this makes running cloud-controller-manager mandatory in 1.7. Has that been decided?

We are NOT making ccm mandatory in 1.7.

Are you wanting to keep the admission plugin as is? That could cause complications.

@ncdc
Copy link
Member

ncdc commented Apr 20, 2017

cc @sttts @liggitt @deads2k @derekwaynecarr @kubernetes/rh-cluster-infra @eparis

@@ -216,6 +217,11 @@ func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restc
nodeController.Run()
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))

// Start thePersistentVolumeLabelController
Copy link
Contributor

@sttts sttts Apr 20, 2017

Choose a reason for hiding this comment

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

the<space>

Copy link
Author

Choose a reason for hiding this comment

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

Done

"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"

"k8s.io/kube-aggregator/pkg/controllers"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we allow this import from pkg/ to k8s.io/kube-aggregator? IMO, we shouldn't. /cc @deads2k

Copy link
Author

Choose a reason for hiding this comment

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

Moved to the controller import

"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
vol "k8s.io/kubernetes/pkg/volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

why the alias? volume is nice and short.

Copy link
Author

Choose a reason for hiding this comment

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

Removed

@@ -15,154 +15,3 @@ limitations under the License.
*/

package label
Copy link
Contributor

Choose a reason for hiding this comment

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

is this empty now? Then just delete it.


import (
"testing"

Copy link
Contributor

Choose a reason for hiding this comment

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

no empty line

Copy link
Author

Choose a reason for hiding this comment

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

Removed

limitations under the License.
*/

package cloud
Copy link
Contributor

Choose a reason for hiding this comment

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

are here any changes or is it a plain move? I think the only way to make this easier to review is to have a pure move commit and one to fix-up everything.

Copy link
Author

Choose a reason for hiding this comment

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

pvlcontroller is new. The meat of the work is the logic from the admission controller, but there have been some minor changes to work within a controller vs the admission plugin. The logic related to creating/starting the controller is all new

@@ -216,6 +217,11 @@ func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restc
nodeController.Run()
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))

// Start thePersistentVolumeLabelController
pvlController := pvlcontroller.NewPersistentVolumeLabelController(sharedInformers.Core().V1().PersistentVolumes(), cloud)
go pvlController.Run(5, stop)
Copy link
Contributor

Choose a reason for hiding this comment

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

threadiness := 5 would make this clearer.

@thockin thockin self-assigned this Apr 21, 2017
@thockin
Copy link
Member

thockin commented Apr 21, 2017

I will take a look ASAP

@rrati rrati force-pushed the pvl-controller branch 2 times, most recently from 01a7a39 to 2d6195f Compare April 24, 2017 17:00
@rrati
Copy link
Author

rrati commented Apr 24, 2017

@thockin atm, this PR is incomplete because of the race condition with the pv-controller and setting the status of cloud pv. We need to resolve that before you spend time reviewing.

@derekwaynecarr derekwaynecarr removed their assignment May 26, 2017
curVol.Labels = volume.Labels
curVol.Status.Phase = volume.Status.Phase

_, err = pvlc.kubeClient.Core().PersistentVolumes().Update(curVol)
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 use a patch here? Avoids the version skew problems, and should be clearer.

Copy link
Author

Choose a reason for hiding this comment

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

Switched to using a patch

}
// glog.Info("Pausing before setting volume available")
// time.Sleep(30 * time.Second)
volume.Status.Phase = v1.VolumeAvailable
Copy link
Member

Choose a reason for hiding this comment

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

(I feel like I've done this review before, so forgive me if you've already explained this somewhere and just point me there!)

So it is possible that there are no labels, and I don't understand why we wouldn't then mark the volume as Available in that case also. But in general, what is the lifecycle of the volume phase here? It looks like we aren't solely responsible for updating the phase. And in that case, are we guaranteed that the volume won't be used before we label it?

@justinsb
Copy link
Member

justinsb commented Jun 1, 2017

Never mind, looks like I probably shouldn't have reviewed this one. Sorry for noise.

@rrati rrati force-pushed the pvl-controller branch from 2d6195f to 7a404ed Compare July 6, 2017 18:01
@rrati
Copy link
Author

rrati commented Jul 6, 2017

@smarterclayton PTAL at the initializer use

@rrati rrati force-pushed the pvl-controller branch from 7a404ed to 8fe0858 Compare July 6, 2017 19:29
@rrati
Copy link
Author

rrati commented Aug 30, 2017

/test pull-kubernetes-e2e-gce-gpu

// Only add labels if in the list of initializers
if needsInitialization(vol.Initializers, initializerName) {
if vol.Spec.AWSElasticBlockStore != nil {
labels, err := pvlc.findAWSEBSLabels(vol)
Copy link
Member

Choose a reason for hiding this comment

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

@rrati How long is this call going to take? We might enforce a global timeout on all initializers.

Copy link
Member

Choose a reason for hiding this comment

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

@rrati I put the do-not-merge label on the PR for this question because it might affect the evolving of initializers.

Copy link
Author

Choose a reason for hiding this comment

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

This is the same logic that is in the admission plugin. It will be going away in a future revision of this controller. The call is very fast in my testing, but I haven't hit any instances where the API won't respond.

Copy link
Member

Choose a reason for hiding this comment

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

@caesarxuchao what happens if this initializer times out? Is the object considered uninitializable?

Copy link
Member

Choose a reason for hiding this comment

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

We perhaps will let the apiserver or garbage collector delete the object.

The call is very fast in my testing

How fast is the API call? Less than 1s? Could you do caching?

Copy link
Author

Choose a reason for hiding this comment

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

The API call itself is <<1s in my testing. However, that number could go up if the cloud provider is having issues, and I don't have any numbers for that. I never ran into a case where that occurred.

Copy link
Member

Choose a reason for hiding this comment

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

<<1s sounds good. Thanks.

@caesarxuchao caesarxuchao added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Aug 30, 2017
@deads2k
Copy link
Contributor

deads2k commented Aug 31, 2017

@rrati I put the do-not-merge label on the PR for this question because it might affect the evolving of initializers.

This is the same logic that is in the admission plugin. It will be going away in a future revision of this controller. The call is very fast in my testing, but I haven't hit any instances where the API won't respond.

@caesarxuchao I think the question has been answered. Looks to be fine. Even if it did take a while, this still appears to the structurally correct way of dealing with the problem.

@smarterclayton
Copy link
Contributor

Looks ok as long as the "alpha initializers are disabled ootb" doesn't cause issues for this.

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, ironcladlou, rrati, smarterclayton

Associated issue: 88

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2017
@smarterclayton
Copy link
Contributor

re: timeout this is an excellent example of an initializer that should block progress on PVCs until it completes - i don't realistically think failure is an option for correct labelling.

@smarterclayton smarterclayton removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Aug 31, 2017
@rrati
Copy link
Author

rrati commented Aug 31, 2017

@smarterclayton Can you approve the changes you requested?

@wlan0
Copy link
Member

wlan0 commented Aug 31, 2017

Great to see this going through @rrati! Thanks for seeing this through.

@smarterclayton - the review is on an outdated commit, and the concerns have been addressed since. If everything looks good to you, please approve it.

@deads2k
Copy link
Contributor

deads2k commented Aug 31, 2017

Great to see this going through @rrati! Thanks for seeing this through.

@smarterclayton - the review is on an outdated commit, and the concerns have been addressed since. If everything looks good to you, please approve it.

@smarterclayton Can you approve the changes you requested?

The PR is lgtm'ed, approved, and in queue.

@caesarxuchao
Copy link
Member

@smarterclayton @deads2k @rrati I was in a discussion on whether it's realistic to set a global initilaization timeout at 15s, and let the apiserver or a garbage collector delete objects that exceed the limit. I think timing out this initializer is ok, user should retry creating the PV, as long as the timeout only happens occasionally.

Copy link
Member

@cheftako cheftako left a comment

Choose a reason for hiding this comment

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

Looks pretty good but I we need a plan to better break out the provider specific pieces.

@@ -220,6 +220,12 @@ func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restc
nodeController.Run()
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))

// Start the PersistentVolumeLabelController
pvlController := cloudcontrollers.NewPersistentVolumeLabelController(client("pvl-controller"), cloud)
threads := 5
Copy link
Member

Choose a reason for hiding this comment

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

Why 5? Would it be worth making this configurable?


// Only add labels if in the list of initializers
if needsInitialization(vol.Initializers, initializerName) {
if vol.Spec.AWSElasticBlockStore != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Do we have an idea of how to get this block out of here and in to the AWS specific cloud provider section?
It seems as though we should add a GetVolumeLabel method to the cloud provider interface.

}
volumeLabels = labels
}
if vol.Spec.GCEPersistentDisk != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto can we work out how to move this into the gce provider section?

@rrati
Copy link
Author

rrati commented Aug 31, 2017

/test pull-kubernetes-bazel-test

Copy link
Member

@cheftako cheftako left a comment

Choose a reason for hiding this comment

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

Looks good and thank you for doing this. We need to track moving the AWS/GCE specific code into the relevant provider section.

@luxas
Copy link
Member

luxas commented Aug 31, 2017 via email

@rrati
Copy link
Author

rrati commented Sep 1, 2017

There already is an issue for removing the cloud provider linkage #51629

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 51574, 51534, 49257, 44680, 48836)

@dims
Copy link
Member

dims commented Sep 8, 2017

related to #49402

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/cloudprovider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.