-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait for re-attachment of PVs during serialized eviction of pods
- Draining of pods with PV (Persistent Volume) now waits for re-attachment of PV on a different node. - When volumeAttachments support is enabled on the cluster, it tracks volume attachments to determine this. - Else it falls back to the default PV reattachment timeout value configured. Default value is 3mins. Co-authored-by: Amshuman K R <[email protected]>
- Loading branch information
1 parent
f81374f
commit ca09a31
Showing
16 changed files
with
725 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package k8sutils is used to provider helper consts and functions for k8s operations | ||
package k8sutils | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/klog" | ||
) | ||
|
||
const ( | ||
// VolumeAttachmentGroupName group name | ||
VolumeAttachmentGroupName = "storage.k8s.io" | ||
// VolumeAttachmentResourceName is the kind used for VolumeAttachment | ||
VolumeAttachmentResourceName = "volumeattachments" | ||
) | ||
|
||
// IsResourceSupported uses Discovery API to find out if the server supports | ||
// the given GroupResource. | ||
// If supported, it will return its groupVersion; Otherwise, it will return "" | ||
func IsResourceSupported( | ||
clientset kubernetes.Interface, | ||
gr schema.GroupResource, | ||
) bool { | ||
var ( | ||
foundDesiredGroup bool | ||
desiredGroupVersion string | ||
) | ||
|
||
discoveryClient := clientset.Discovery() | ||
groupList, err := discoveryClient.ServerGroups() | ||
if err != nil { | ||
return false | ||
} | ||
|
||
for _, group := range groupList.Groups { | ||
if group.Name == gr.Group { | ||
foundDesiredGroup = true | ||
desiredGroupVersion = group.PreferredVersion.GroupVersion | ||
break | ||
} | ||
} | ||
if !foundDesiredGroup { | ||
return false | ||
} | ||
|
||
resourceList, err := discoveryClient.ServerResourcesForGroupVersion(desiredGroupVersion) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
for _, resource := range resourceList.APIResources { | ||
if resource.Name == gr.Resource { | ||
klog.V(4).Infof("Found Resource: %s/%s", gr.Group, gr.Resource) | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.