Skip to content

Commit 020079e

Browse files
committed
DRA: remove immediate allocation
As agreed in kubernetes/enhancements#4709, immediate allocation is one of those features which can be removed because it makes no sense for structured parameters and the justification for classic DRA is weak.
1 parent 637f10d commit 020079e

File tree

50 files changed

+1125
-1190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1125
-1190
lines changed

api/openapi-spec/swagger.json

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__resource.k8s.io__v1alpha2_openapi.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,6 @@
762762
"io.k8s.api.resource.v1alpha2.ResourceClaimSpec": {
763763
"description": "ResourceClaimSpec defines how a resource is to be allocated.",
764764
"properties": {
765-
"allocationMode": {
766-
"description": "Allocation can start immediately or when a Pod wants to use the resource. \"WaitForFirstConsumer\" is the default.",
767-
"type": "string"
768-
},
769765
"parametersRef": {
770766
"allOf": [
771767
{

pkg/api/testing/defaulting_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ func TestDefaulting(t *testing.T) {
135135
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "ClusterRoleBindingList"}: {},
136136
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "RoleBinding"}: {},
137137
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "RoleBindingList"}: {},
138-
{Group: "resource.k8s.io", Version: "v1alpha2", Kind: "ResourceClaim"}: {},
139-
{Group: "resource.k8s.io", Version: "v1alpha2", Kind: "ResourceClaimList"}: {},
140-
{Group: "resource.k8s.io", Version: "v1alpha2", Kind: "ResourceClaimTemplate"}: {},
141-
{Group: "resource.k8s.io", Version: "v1alpha2", Kind: "ResourceClaimTemplateList"}: {},
142138
{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "ValidatingAdmissionPolicy"}: {},
143139
{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "ValidatingAdmissionPolicyList"}: {},
144140
{Group: "admissionregistration.k8s.io", Version: "v1alpha1", Kind: "ValidatingAdmissionPolicyBinding"}: {},

pkg/apis/resource/fuzzer/fuzzer.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,10 @@ limitations under the License.
1717
package fuzzer
1818

1919
import (
20-
fuzz "github.com/google/gofuzz"
21-
2220
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
23-
"k8s.io/kubernetes/pkg/apis/resource"
2421
)
2522

2623
// Funcs contains the fuzzer functions for the resource group.
2724
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28-
return []interface{}{
29-
func(obj *resource.ResourceClaimSpec, c fuzz.Continue) {
30-
c.FuzzNoCustom(obj) // fuzz self without calling this function again
31-
32-
// Custom fuzzing for allocation mode: pick one valid mode randomly.
33-
modes := []resource.AllocationMode{
34-
resource.AllocationModeImmediate,
35-
resource.AllocationModeWaitForFirstConsumer,
36-
}
37-
obj.AllocationMode = modes[c.Rand.Intn(len(modes))]
38-
},
39-
}
25+
return nil
4026
}

pkg/apis/resource/types.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,33 +62,7 @@ type ResourceClaimSpec struct {
6262
// The object must be in the same namespace as the ResourceClaim.
6363
// +optional
6464
ParametersRef *ResourceClaimParametersReference
65-
66-
// Allocation can start immediately or when a Pod wants to use the
67-
// resource. "WaitForFirstConsumer" is the default.
68-
// +optional
69-
AllocationMode AllocationMode
70-
}
71-
72-
// AllocationMode describes whether a ResourceClaim gets allocated immediately
73-
// when it gets created (AllocationModeImmediate) or whether allocation is
74-
// delayed until it is needed for a Pod
75-
// (AllocationModeWaitForFirstConsumer). Other modes might get added in the
76-
// future.
77-
type AllocationMode string
78-
79-
const (
80-
// When a ResourceClaim has AllocationModeWaitForFirstConsumer, allocation is
81-
// delayed until a Pod gets scheduled that needs the ResourceClaim. The
82-
// scheduler will consider all resource requirements of that Pod and
83-
// trigger allocation for a node that fits the Pod.
84-
AllocationModeWaitForFirstConsumer AllocationMode = "WaitForFirstConsumer"
85-
86-
// When a ResourceClaim has AllocationModeImmediate, allocation starts
87-
// as soon as the ResourceClaim gets created. This is done without
88-
// considering the needs of Pods that will use the ResourceClaim
89-
// because those Pods are not known yet.
90-
AllocationModeImmediate AllocationMode = "Immediate"
91-
)
65+
}
9266

9367
// ResourceClaimStatus tracks whether the resource has been allocated and what
9468
// the resulting attributes are.

pkg/apis/resource/v1alpha2/defaults.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,9 @@ limitations under the License.
1717
package v1alpha2
1818

1919
import (
20-
"k8s.io/api/resource/v1alpha2"
2120
"k8s.io/apimachinery/pkg/runtime"
2221
)
2322

2423
func addDefaultingFuncs(scheme *runtime.Scheme) error {
2524
return RegisterDefaults(scheme)
2625
}
27-
28-
func SetDefaults_ResourceClaimSpec(obj *v1alpha2.ResourceClaimSpec) {
29-
if obj.AllocationMode == "" {
30-
obj.AllocationMode = v1alpha2.AllocationModeWaitForFirstConsumer
31-
}
32-
}

pkg/apis/resource/v1alpha2/defaults_test.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

pkg/apis/resource/v1alpha2/zz_generated.conversion.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/v1alpha2/zz_generated.defaults.go

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/validation/validation.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,9 @@ func validateResourceClaimSpec(spec *resource.ResourceClaimSpec, fldPath *field.
4646
allErrs = append(allErrs, field.Invalid(fldPath.Child("resourceClassName"), spec.ResourceClassName, msg))
4747
}
4848
allErrs = append(allErrs, validateResourceClaimParametersRef(spec.ParametersRef, fldPath.Child("parametersRef"))...)
49-
if !supportedAllocationModes.Has(string(spec.AllocationMode)) {
50-
allErrs = append(allErrs, field.NotSupported(fldPath.Child("allocationMode"), spec.AllocationMode, supportedAllocationModes.List()))
51-
}
5249
return allErrs
5350
}
5451

55-
var supportedAllocationModes = sets.NewString(string(resource.AllocationModeImmediate), string(resource.AllocationModeWaitForFirstConsumer))
56-
5752
// It would have been nice to use Go generics to reuse the same validation
5853
// function for Kind and Name in both types, but generics cannot be used to
5954
// access common fields in structs.

0 commit comments

Comments
 (0)