mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: update replaced k8s.io modules to v0.33.0
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
dd77e72800
commit
107407b44b
53
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/devicetoleration.go
generated
vendored
Normal file
53
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/devicetoleration.go
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2025 The Kubernetes Authors.
|
||||
|
||||
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 resourceclaim
|
||||
|
||||
import (
|
||||
resourceapi "k8s.io/api/resource/v1beta1"
|
||||
)
|
||||
|
||||
// ToleratesTaint checks if the toleration tolerates the taint.
|
||||
// The matching follows the rules below:
|
||||
//
|
||||
// 1. Empty toleration.effect means to match all taint effects,
|
||||
// otherwise taint effect must equal to toleration.effect.
|
||||
// 2. If toleration.operator is 'Exists', it means to match all taint values.
|
||||
// 3. Empty toleration.key means to match all taint keys.
|
||||
// If toleration.key is empty, toleration.operator must be 'Exists';
|
||||
// this combination means to match all taint values and all taint keys.
|
||||
func ToleratesTaint(toleration resourceapi.DeviceToleration, taint resourceapi.DeviceTaint) bool {
|
||||
// This code was copied from https://github.com/kubernetes/kubernetes/blob/f007012f5fe49e40ae0596cf463a8e7b247b3357/staging/src/k8s.io/api/core/v1/toleration.go#L39-L56.
|
||||
// It wasn't placed in the resourceapi package because code related to logic
|
||||
// doesn't belong there.
|
||||
if toleration.Effect != "" && toleration.Effect != taint.Effect {
|
||||
return false
|
||||
}
|
||||
|
||||
if toleration.Key != "" && toleration.Key != taint.Key {
|
||||
return false
|
||||
}
|
||||
|
||||
switch toleration.Operator {
|
||||
// Empty operator means Equal, should be set because of defaulting.
|
||||
case "", resourceapi.DeviceTolerationOpEqual:
|
||||
return toleration.Value == taint.Value
|
||||
case resourceapi.DeviceTolerationOpExists:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
35
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/resourceclaim.go
generated
vendored
35
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/resourceclaim.go
generated
vendored
@ -26,6 +26,8 @@ package resourceclaim
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1beta1"
|
||||
@ -106,3 +108,36 @@ func CanBeReserved(claim *resourceapi.ResourceClaim) bool {
|
||||
// Currently no restrictions on sharing...
|
||||
return true
|
||||
}
|
||||
|
||||
// BaseRequestRef returns the request name if the reference is to a top-level
|
||||
// request and the name of the parent request if the reference is to a subrequest.
|
||||
func BaseRequestRef(requestRef string) string {
|
||||
segments := strings.Split(requestRef, "/")
|
||||
return segments[0]
|
||||
}
|
||||
|
||||
// ConfigForResult returns the configs that are applicable to device
|
||||
// allocated for the provided result.
|
||||
func ConfigForResult(deviceConfigurations []resourceapi.DeviceAllocationConfiguration, result resourceapi.DeviceRequestAllocationResult) []resourceapi.DeviceAllocationConfiguration {
|
||||
var configs []resourceapi.DeviceAllocationConfiguration
|
||||
for _, deviceConfiguration := range deviceConfigurations {
|
||||
if deviceConfiguration.Opaque != nil &&
|
||||
isMatch(deviceConfiguration.Requests, result.Request) {
|
||||
configs = append(configs, deviceConfiguration)
|
||||
}
|
||||
}
|
||||
return configs
|
||||
}
|
||||
|
||||
func isMatch(requests []string, requestRef string) bool {
|
||||
if len(requests) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
if slices.Contains(requests, requestRef) {
|
||||
return true
|
||||
}
|
||||
|
||||
baseRequestRef := BaseRequestRef(requestRef)
|
||||
return slices.Contains(requests, baseRequestRef)
|
||||
}
|
||||
|
Reference in New Issue
Block a user