mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-22 02:18:51 +00:00
non-preempting-priorityclass
Co-authored-by: Vallery Lancey <vallery@zeitgeistlabs.io> Co-authored-by: Tan shanshan <tan.shanshan@zte.com.cn>
This commit is contained in:
@@ -9,6 +9,7 @@ load(
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"annotations.go",
|
||||
"doc.go",
|
||||
"helpers.go",
|
||||
"register.go",
|
||||
|
21
pkg/apis/scheduling/annotations.go
Normal file
21
pkg/apis/scheduling/annotations.go
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2019 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 scheduling
|
||||
|
||||
// PreemptingAnnotation is the annotation which holds preempting
|
||||
// when converting the `Preempting` field from scheduling/v1
|
||||
const PreemptingAnnotation = "scheduling.k8s.io/preempting"
|
@@ -9,7 +9,11 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["fuzzer.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/scheduling/fuzzer",
|
||||
deps = ["//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library"],
|
||||
deps = [
|
||||
"//pkg/apis/scheduling:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
@@ -17,10 +17,20 @@ limitations under the License.
|
||||
package fuzzer
|
||||
|
||||
import (
|
||||
"github.com/google/gofuzz"
|
||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
)
|
||||
|
||||
// Funcs returns the fuzzer functions for the scheduling api group.
|
||||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
return []interface{}{}
|
||||
return []interface{}{
|
||||
func(s *scheduling.PriorityClass, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(s)
|
||||
if s.Preempting == nil {
|
||||
preempting := scheduling.DefaultPreempting
|
||||
s.Preempting = &preempting
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,8 @@ const (
|
||||
SystemClusterCritical = SystemPriorityClassPrefix + "cluster-critical"
|
||||
// SystemNodeCritical is the system priority class name that represents node-critical.
|
||||
SystemNodeCritical = SystemPriorityClassPrefix + "node-critical"
|
||||
// The default value for preempting attribute.
|
||||
DefaultPreempting = true
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@@ -64,6 +66,11 @@ type PriorityClass struct {
|
||||
// when this priority class should be used.
|
||||
// +optional
|
||||
Description string
|
||||
|
||||
// Preempting specifies whether a pod with this PriorityClass could start a preemption process.
|
||||
// If this field is missing, the PriorityClass is considered a preempting class by default.
|
||||
// +optional
|
||||
Preempting *bool
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
@@ -1,8 +1,9 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"defaults.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"zz_generated.conversion.go",
|
||||
@@ -32,3 +33,16 @@ filegroup(
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["defaults_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/api/testapi:go_default_library",
|
||||
"//pkg/apis/scheduling:go_default_library",
|
||||
"//staging/src/k8s.io/api/scheduling/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
37
pkg/apis/scheduling/v1/defaults.go
Normal file
37
pkg/apis/scheduling/v1/defaults.go
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2019 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 v1
|
||||
|
||||
import (
|
||||
"k8s.io/api/scheduling/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
// SetDefaults_PriorityClass sets additional defaults compared to its counterpart
|
||||
// in extensions.
|
||||
func SetDefaults_PriorityClass(obj *v1.PriorityClass) {
|
||||
if obj.Preempting == nil {
|
||||
// Set Preempting as true by default.
|
||||
Preempting := scheduling.DefaultPreempting
|
||||
obj.Preempting = &Preempting
|
||||
}
|
||||
}
|
59
pkg/apis/scheduling/v1/defaults_test.go
Normal file
59
pkg/apis/scheduling/v1/defaults_test.go
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2015 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 v1_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/scheduling/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
|
||||
// enforce that all types are installed
|
||||
_ "k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
)
|
||||
|
||||
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
codec := legacyscheme.Codecs.LegacyCodec(v1.SchemeGroupVersion)
|
||||
data, err := runtime.Encode(codec, obj)
|
||||
if err != nil {
|
||||
t.Errorf("%v\n %#v", err, obj)
|
||||
return nil
|
||||
}
|
||||
obj2, err := runtime.Decode(codec, data)
|
||||
if err != nil {
|
||||
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
|
||||
return nil
|
||||
}
|
||||
obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
|
||||
err = legacyscheme.Scheme.Convert(obj2, obj3, nil)
|
||||
if err != nil {
|
||||
t.Errorf("%v\nSource: %#v", err, obj2)
|
||||
return nil
|
||||
}
|
||||
return obj3
|
||||
}
|
||||
|
||||
func TestSetDefaultPreempting(t *testing.T) {
|
||||
priorityClass := &v1.PriorityClass{}
|
||||
output := roundTrip(t, runtime.Object(priorityClass)).(*v1.PriorityClass)
|
||||
if output.Preempting == nil || *output.Preempting != scheduling.DefaultPreempting {
|
||||
t.Errorf("Expected enableServiceLinks value: %+v\ngot: %+v\n", scheduling.DefaultPreempting, *output.Preempting)
|
||||
}
|
||||
}
|
@@ -42,5 +42,5 @@ func init() {
|
||||
// We only register manually written functions here. The registration of the
|
||||
// generated functions takes place in the generated files. The separation
|
||||
// makes the code compile even when the generated files are missing.
|
||||
localSchemeBuilder.Register(RegisterDefaults)
|
||||
localSchemeBuilder.Register(addDefaultingFuncs)
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ func autoConvert_v1_PriorityClass_To_scheduling_PriorityClass(in *v1.PriorityCla
|
||||
out.Value = in.Value
|
||||
out.GlobalDefault = in.GlobalDefault
|
||||
out.Description = in.Description
|
||||
out.Preempting = (*bool)(unsafe.Pointer(in.Preempting))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ func autoConvert_scheduling_PriorityClass_To_v1_PriorityClass(in *scheduling.Pri
|
||||
out.Value = in.Value
|
||||
out.GlobalDefault = in.GlobalDefault
|
||||
out.Description = in.Description
|
||||
out.Preempting = (*bool)(unsafe.Pointer(in.Preempting))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
14
pkg/apis/scheduling/v1/zz_generated.defaults.go
generated
14
pkg/apis/scheduling/v1/zz_generated.defaults.go
generated
@@ -21,6 +21,7 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/scheduling/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -28,5 +29,18 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v1.PriorityClass{}, func(obj interface{}) { SetObjectDefaults_PriorityClass(obj.(*v1.PriorityClass)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PriorityClassList{}, func(obj interface{}) { SetObjectDefaults_PriorityClassList(obj.(*v1.PriorityClassList)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PriorityClass(in *v1.PriorityClass) {
|
||||
SetDefaults_PriorityClass(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PriorityClassList(in *v1.PriorityClassList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_PriorityClass(a)
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ load(
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"zz_generated.conversion.go",
|
||||
|
70
pkg/apis/scheduling/v1alpha1/conversion.go
Normal file
70
pkg/apis/scheduling/v1alpha1/conversion.go
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright 2019 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 v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/api/scheduling/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Convert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(in *scheduling.PriorityClass, out *v1alpha1.PriorityClass, s conversion.Scope) error {
|
||||
if err := autoConvert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ObjectMeta.Annotations = deepCopyStringMap(out.Annotations)
|
||||
|
||||
if in.Preempting != nil {
|
||||
if out.ObjectMeta.Annotations == nil {
|
||||
out.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
out.ObjectMeta.Annotations[scheduling.PreemptingAnnotation] = strconv.FormatBool(*(in.Preempting))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(in *v1alpha1.PriorityClass, out *scheduling.PriorityClass, s conversion.Scope) error {
|
||||
if err := autoConvert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ObjectMeta.Annotations = deepCopyStringMap(out.Annotations)
|
||||
|
||||
if in.ObjectMeta.Annotations != nil {
|
||||
if _, ok := in.ObjectMeta.Annotations[scheduling.PreemptingAnnotation]; ok {
|
||||
preempting, err := strconv.ParseBool(in.ObjectMeta.Annotations[scheduling.PreemptingAnnotation])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Preempting = &preempting
|
||||
delete(out.ObjectMeta.Annotations, scheduling.PreemptingAnnotation)
|
||||
}
|
||||
} else {
|
||||
preempting := scheduling.DefaultPreempting
|
||||
out.Preempting = &preempting
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopyStringMap(m map[string]string) map[string]string {
|
||||
ret := make(map[string]string, len(m))
|
||||
for k, v := range m {
|
||||
ret[k] = v
|
||||
}
|
||||
return ret
|
||||
}
|
@@ -21,8 +21,6 @@ limitations under the License.
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -56,6 +54,16 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*scheduling.PriorityClass)(nil), (*v1alpha1.PriorityClass)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(a.(*scheduling.PriorityClass), b.(*v1alpha1.PriorityClass), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*v1alpha1.PriorityClass)(nil), (*scheduling.PriorityClass)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(a.(*v1alpha1.PriorityClass), b.(*scheduling.PriorityClass), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -67,27 +75,28 @@ func autoConvert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(in *v1alpha1
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_PriorityClass_To_scheduling_PriorityClass is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(in *v1alpha1.PriorityClass, out *scheduling.PriorityClass, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(in *scheduling.PriorityClass, out *v1alpha1.PriorityClass, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.Value = in.Value
|
||||
out.GlobalDefault = in.GlobalDefault
|
||||
out.Description = in.Description
|
||||
// WARNING: in.Preempting requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_scheduling_PriorityClass_To_v1alpha1_PriorityClass is an autogenerated conversion function.
|
||||
func Convert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(in *scheduling.PriorityClass, out *v1alpha1.PriorityClass, s conversion.Scope) error {
|
||||
return autoConvert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_PriorityClassList_To_scheduling_PriorityClassList(in *v1alpha1.PriorityClassList, out *scheduling.PriorityClassList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]scheduling.PriorityClass)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]scheduling.PriorityClass, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v1alpha1_PriorityClass_To_scheduling_PriorityClass(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -98,7 +107,17 @@ func Convert_v1alpha1_PriorityClassList_To_scheduling_PriorityClassList(in *v1al
|
||||
|
||||
func autoConvert_scheduling_PriorityClassList_To_v1alpha1_PriorityClassList(in *scheduling.PriorityClassList, out *v1alpha1.PriorityClassList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1alpha1.PriorityClass)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]v1alpha1.PriorityClass, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_scheduling_PriorityClass_To_v1alpha1_PriorityClass(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ load(
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"zz_generated.conversion.go",
|
||||
|
67
pkg/apis/scheduling/v1beta1/conversion.go
Normal file
67
pkg/apis/scheduling/v1beta1/conversion.go
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright 2019 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 v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/api/scheduling/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Convert_scheduling_PriorityClass_To_v1beta1_PriorityClass(in *scheduling.PriorityClass, out *v1beta1.PriorityClass, s conversion.Scope) error {
|
||||
if err := autoConvert_scheduling_PriorityClass_To_v1beta1_PriorityClass(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ObjectMeta.Annotations = deepCopyStringMap(out.Annotations)
|
||||
if in.Preempting != nil {
|
||||
if out.ObjectMeta.Annotations == nil {
|
||||
out.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
out.ObjectMeta.Annotations[scheduling.PreemptingAnnotation] = strconv.FormatBool(*(in.Preempting))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_PriorityClass_To_scheduling_PriorityClass(in *v1beta1.PriorityClass, out *scheduling.PriorityClass, s conversion.Scope) error {
|
||||
if err := autoConvert_v1beta1_PriorityClass_To_scheduling_PriorityClass(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.ObjectMeta.Annotations = deepCopyStringMap(out.Annotations)
|
||||
if out.ObjectMeta.Annotations != nil {
|
||||
if _, ok := out.ObjectMeta.Annotations[scheduling.PreemptingAnnotation]; ok {
|
||||
preempting, err := strconv.ParseBool(out.ObjectMeta.Annotations[scheduling.PreemptingAnnotation])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Preempting = &preempting
|
||||
delete(out.ObjectMeta.Annotations, scheduling.PreemptingAnnotation)
|
||||
}
|
||||
} else {
|
||||
preempting := scheduling.DefaultPreempting
|
||||
out.Preempting = &preempting
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deepCopyStringMap(m map[string]string) map[string]string {
|
||||
ret := make(map[string]string, len(m))
|
||||
for k, v := range m {
|
||||
ret[k] = v
|
||||
}
|
||||
return ret
|
||||
}
|
@@ -21,8 +21,6 @@ limitations under the License.
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -56,6 +54,16 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*scheduling.PriorityClass)(nil), (*v1beta1.PriorityClass)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_scheduling_PriorityClass_To_v1beta1_PriorityClass(a.(*scheduling.PriorityClass), b.(*v1beta1.PriorityClass), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*v1beta1.PriorityClass)(nil), (*scheduling.PriorityClass)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_PriorityClass_To_scheduling_PriorityClass(a.(*v1beta1.PriorityClass), b.(*scheduling.PriorityClass), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -67,27 +75,28 @@ func autoConvert_v1beta1_PriorityClass_To_scheduling_PriorityClass(in *v1beta1.P
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1beta1_PriorityClass_To_scheduling_PriorityClass is an autogenerated conversion function.
|
||||
func Convert_v1beta1_PriorityClass_To_scheduling_PriorityClass(in *v1beta1.PriorityClass, out *scheduling.PriorityClass, s conversion.Scope) error {
|
||||
return autoConvert_v1beta1_PriorityClass_To_scheduling_PriorityClass(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_scheduling_PriorityClass_To_v1beta1_PriorityClass(in *scheduling.PriorityClass, out *v1beta1.PriorityClass, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.Value = in.Value
|
||||
out.GlobalDefault = in.GlobalDefault
|
||||
out.Description = in.Description
|
||||
// WARNING: in.Preempting requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_scheduling_PriorityClass_To_v1beta1_PriorityClass is an autogenerated conversion function.
|
||||
func Convert_scheduling_PriorityClass_To_v1beta1_PriorityClass(in *scheduling.PriorityClass, out *v1beta1.PriorityClass, s conversion.Scope) error {
|
||||
return autoConvert_scheduling_PriorityClass_To_v1beta1_PriorityClass(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1beta1_PriorityClassList_To_scheduling_PriorityClassList(in *v1beta1.PriorityClassList, out *scheduling.PriorityClassList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]scheduling.PriorityClass)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]scheduling.PriorityClass, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v1beta1_PriorityClass_To_scheduling_PriorityClass(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -98,7 +107,17 @@ func Convert_v1beta1_PriorityClassList_To_scheduling_PriorityClassList(in *v1bet
|
||||
|
||||
func autoConvert_scheduling_PriorityClassList_To_v1beta1_PriorityClassList(in *scheduling.PriorityClassList, out *v1beta1.PriorityClassList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1beta1.PriorityClass)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]v1beta1.PriorityClass, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_scheduling_PriorityClass_To_v1beta1_PriorityClass(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
5
pkg/apis/scheduling/zz_generated.deepcopy.go
generated
5
pkg/apis/scheduling/zz_generated.deepcopy.go
generated
@@ -29,6 +29,11 @@ func (in *PriorityClass) DeepCopyInto(out *PriorityClass) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
if in.Preempting != nil {
|
||||
in, out := &in.Preempting, &out.Preempting
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user