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
Make createEndpointService() and deleteEndpointService() plugin interface methods. #45528
Conversation
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 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. |
/release-note-none |
@k8s-bot ok to test |
@humblec: you can't request testing unless you are a kubernetes member. In response to this:
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. |
06fe9a2
to
d32df0c
Compare
@k8s-bot ok to test |
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. |
@rootfs you are correct, these are provisioner methods. The main reason to make this change is due to below. |
@rootfs the PR note reflect the reason for this change. Please review. Thanks ! |
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pkg/volume/glusterfs/glusterfs.go
Outdated
|
||
class, err := volutil.GetClassForVolume(plugin.host.GetKubeClient(), spec.PersistentVolume) | ||
if err != nil { | ||
return nil, fmt.Errorf("glusterfs: failed to get storageclass: %v", err) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
b204b6c
to
0879bac
Compare
0879bac
to
0c61cf6
Compare
@rootfs Addressed the comments. Please review. |
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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.
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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
pkg/volume/glusterfs/glusterfs.go
Outdated
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" { |
There was a problem hiding this comment.
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
pkg/volume/glusterfs/glusterfs.go
Outdated
|
||
cfg, err := parseClassParameters(class.Parameters, plugin.host.GetKubeClient()) | ||
if err != nil { | ||
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed to parse parameters
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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
pkg/volume/glusterfs/glusterfs.go
Outdated
|
||
endpointIPs, err := getClusterNodes(cli, volInfo.Cluster) | ||
if err != nil { | ||
return nil, fmt.Errorf("glusterfs: failed to recreate endpoint/service, error: %v", err) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
01d4b4b
to
f4c6cca
Compare
pkg/volume/glusterfs/glusterfs.go
Outdated
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) |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
f4c6cca
to
057944e
Compare
@k8s-bot verify test this |
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
057944e
to
936c81d
Compare
/lgtm |
[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 |
Thanks a lot @rootfs ! |
Automatic merge from submit-queue (batch tested with PRs 45408, 45355, 45528) |
@humblec PR needs rebase |
} | ||
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) |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Signed-off-by: Huamin Chen <hchen@redhat.com>
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 ```
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