mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Cleanup: merge checkVolumeNodeAffinity with CheckVolumeNodeAffinity
Signed-off-by: Konstantin Misyutin <konstantin.misyutin@huawei.com>
This commit is contained in:
parent
4ba98a8610
commit
0b5b04842c
@ -52,15 +52,12 @@ func GetPersistentVolumeClass(volume *v1.PersistentVolume) string {
|
|||||||
// CheckNodeAffinity looks at the PV node affinity, and checks if the node has the same corresponding labels
|
// CheckNodeAffinity looks at the PV node affinity, and checks if the node has the same corresponding labels
|
||||||
// This ensures that we don't mount a volume that doesn't belong to this node
|
// This ensures that we don't mount a volume that doesn't belong to this node
|
||||||
func CheckNodeAffinity(pv *v1.PersistentVolume, nodeLabels map[string]string) error {
|
func CheckNodeAffinity(pv *v1.PersistentVolume, nodeLabels map[string]string) error {
|
||||||
return checkVolumeNodeAffinity(pv, &v1.Node{ObjectMeta: metav1.ObjectMeta{Labels: nodeLabels}})
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkVolumeNodeAffinity(pv *v1.PersistentVolume, node *v1.Node) error {
|
|
||||||
if pv.Spec.NodeAffinity == nil {
|
if pv.Spec.NodeAffinity == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if pv.Spec.NodeAffinity.Required != nil {
|
if pv.Spec.NodeAffinity.Required != nil {
|
||||||
|
node := &v1.Node{ObjectMeta: metav1.ObjectMeta{Labels: nodeLabels}}
|
||||||
terms := pv.Spec.NodeAffinity.Required
|
terms := pv.Spec.NodeAffinity.Required
|
||||||
if matches, err := corev1.MatchNodeSelectorTerms(node, terms); err != nil {
|
if matches, err := corev1.MatchNodeSelectorTerms(node, terms); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user