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

Make createEndpointService() and deleteEndpointService() plugin interface methods. #45528

Merged
merged 1 commit into from May 16, 2017

Conversation

humblec
Copy link
Contributor

@humblec humblec commented May 9, 2017

Why this change?

In some setups, after creation of dynamic PVs and before mounting/using these PVs in a pod, the endpoint/service got mistakenly deleted by the user/developer. By making these methods 'plugin' specific, we can call it from mounter if there are scenarios where the endpoint and service got wiped in between accidentally.

Signed-off-by: Humble Chirammal hchiramm@redhat.com

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

This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @humblec. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 9, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 9, 2017
@humblec
Copy link
Contributor Author

humblec commented May 9, 2017

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels May 9, 2017
@humblec
Copy link
Contributor Author

humblec commented May 9, 2017

/assign @jsafrane @rootfs

@humblec
Copy link
Contributor Author

humblec commented May 9, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 9, 2017
@k8s-ci-robot
Copy link
Contributor

@humblec: you can't request testing unless you are a kubernetes member.

In response to this:

@k8s-bot ok to test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@rootfs
Copy link
Contributor

rootfs commented May 9, 2017

@k8s-bot ok to test

@rootfs
Copy link
Contributor

rootfs commented May 9, 2017

These two methods are used by the provisioner, plugin doesn't need to create/delete endpoints for now.

If the use case is generic enough, we can consider adding endpoint methods as volume utilities.

@humblec
Copy link
Contributor Author

humblec commented May 9, 2017

@rootfs you are correct, these are provisioner methods. The main reason to make this change is due to below.
In some setups, after creation of PVs and before mounting of the PV in a pod, the endpoint got mistakenly deleted by the user. So, what I am planning with this change is calling this function at mount time, if some how the endpoint and service got wiped in between. I would have mentioned this in the commit message. I will update the commit message if you ack on this change.

@humblec
Copy link
Contributor Author

humblec commented May 9, 2017

@rootfs the PR note reflect the reason for this change. Please review. Thanks !

@humblec humblec changed the title Make createEndpointService() and deleteEndpointService() plugin interface methods. [WIP] Make createEndpointService() and deleteEndpointService() plugin interface methods. May 12, 2017
ep, err := kubeClient.Core().Endpoints(ns).Get(epName, metav1.GetOptions{})
if err != nil {
glog.Errorf("glusterfs: failed to get endpoints %s[%v]", epName, err)
return nil, err

class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume)
Copy link
Contributor

Choose a reason for hiding this comment

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

recreate endpoint if:

  • spec != nil
  • err indicates the endpoint doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume)
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to get storageclass: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

PV may not be created via storage class. Tune the message a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@humblec humblec changed the title [WIP] Make createEndpointService() and deleteEndpointService() plugin interface methods. Make createEndpointService() and deleteEndpointService() plugin interface methods. May 15, 2017
@humblec
Copy link
Contributor Author

humblec commented May 15, 2017

@rootfs Addressed the comments. Please review.

if spec != nil && spec.PersistentVolume.Annotations["kubernetes.io/createdby"] == "heketi-dynamic-provisioner" {
class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume)
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to get storageclass when recreating endpoint/service: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the PV has no storage class, don't treat it as an error.

if spec != nil && spec.PersistentVolume.Annotations["kubernetes.io/createdby"] == "heketi-dynamic-provisioner" {
class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume)
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to get storage class

return nil, err
if err != nil && errors.IsNotFound(err) {
glog.Errorf("glusterfs: failed to get endpoint %s[%v]", epName, err)
if spec != nil && spec.PersistentVolume.Annotations["kubernetes.io/createdby"] == "heketi-dynamic-provisioner" {
Copy link
Contributor

Choose a reason for hiding this comment

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

make heketi-dynamic-provisioner a const and replace it in provision() too


cfg, err := parseClassParameters(class.Parameters, plugin.host.GetKubeClient())
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to parse parameters

scConfig := *cfg
cli := gcli.NewClient(scConfig.url, scConfig.user, scConfig.secretValue)
if cli == nil {
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to create heketi client

volumeID := dstrings.TrimPrefix(source.Path, volPrefix)
volInfo, err := cli.VolumeInfo(volumeID)
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to get volume info


endpointIPs, err := getClusterNodes(cli, volInfo.Cluster)
if err != nil {
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to get cluster nodes

if err != nil {
glog.Errorf("glusterfs: failed to get endpoints %s[%v]", epName, err)
return nil, err
if err != nil && errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit more paranoid but validate that epName is created using the same schema that provision uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

claim := spec.PersistentVolume.Spec.ClaimRef.Name
checkEpName := dynamicEpSvcPrefix + claim
if epName != checkEpName {
return nil, fmt.Errorf("failed to get proper endpoint name, error: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

glusterfs: failed to get endpoints %s, error %v since in this case, failed validation indicates the volume is not provisioned by provision().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@humblec
Copy link
Contributor Author

humblec commented May 16, 2017

@k8s-bot verify test this

@rootfs
Copy link
Contributor

rootfs commented May 16, 2017

/approve
@k8s-bot verify test this

@humblec squash commits, then lgtm

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 16, 2017
In some setups, after creation of dynamic PVs and before mounting/using
these PVs in a pod, the endpoint/service got mistakenly deleted by the
user/developer. By making these methods 'plugin' specific, we can call
it from mounter if there are scenarios where the endpoint and service
got wiped in between accidentally.

Signed-off-by: Humble Chirammal hchiramm@redhat.com
@rootfs
Copy link
Contributor

rootfs commented May 16, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: humblec, rootfs

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

@humblec
Copy link
Contributor Author

humblec commented May 16, 2017

Thanks a lot @rootfs !

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45408, 45355, 45528)

@k8s-github-robot k8s-github-robot merged commit 11a6f19 into kubernetes:master May 16, 2017
@k8s-github-robot
Copy link

@humblec PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2017
}
glog.Errorf("glusterfs: failed to get endpoint %s[%v]", epName, err)
if spec != nil && spec.PersistentVolume.Annotations["kubernetes.io/createdby"] == heketiAnn {
class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume)
Copy link
Member

Choose a reason for hiding this comment

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

nodes cannot look up arbitrary secrets based on values in storage class parameters...

Copy link
Member

Choose a reason for hiding this comment

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

I also thought only the create/delete, attach/detach phases were supposed to resolve storage class info... isn't mount only supposed to use info in the PV?


// Give an attempt to recreate endpoint/service.

_, _, err = plugin.createEndpointService(ns, epName, endpointIPs, claim)
Copy link
Member

Choose a reason for hiding this comment

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

nodes do not have permission to create endpoints or services... this will fail on any cluster running RBAC

@rootfs rootfs mentioned this pull request Jun 19, 2017
rootfs added a commit to rootfs/kubernetes that referenced this pull request Jun 19, 2017
Signed-off-by: Huamin Chen <hchen@redhat.com>
k8s-github-robot pushed a commit that referenced this pull request Jun 20, 2017
Automatic merge from submit-queue (batch tested with PRs 47726, 47693, 46909, 46812)

manually revert #45528

**What this PR does / why we need it**:
Revert #45528
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47657

**Special notes for your reviewer**:
@humblec @liggitt @saad-ali @kubernetes/kubernetes-release-managers 
**Release note**:

```release-note
NONE
```
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. 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.

None yet

9 participants