k8s.io/kubernetes@v1.29.3/pkg/apis/flowcontrol/v1beta2/defaults.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1beta2 18 19 import ( 20 "k8s.io/api/flowcontrol/v1beta2" 21 ) 22 23 // Default settings for flow-schema 24 const ( 25 FlowSchemaDefaultMatchingPrecedence int32 = 1000 26 ) 27 28 // Default settings for priority-level-configuration 29 const ( 30 PriorityLevelConfigurationDefaultHandSize int32 = 8 31 PriorityLevelConfigurationDefaultQueues int32 = 64 32 PriorityLevelConfigurationDefaultQueueLengthLimit int32 = 50 33 PriorityLevelConfigurationDefaultAssuredConcurrencyShares int32 = 30 34 ) 35 36 // SetDefaults_FlowSchema sets default values for flow schema 37 func SetDefaults_FlowSchemaSpec(spec *v1beta2.FlowSchemaSpec) { 38 if spec.MatchingPrecedence == 0 { 39 spec.MatchingPrecedence = FlowSchemaDefaultMatchingPrecedence 40 } 41 } 42 43 func SetDefaults_ExemptPriorityLevelConfiguration(eplc *v1beta2.ExemptPriorityLevelConfiguration) { 44 if eplc.NominalConcurrencyShares == nil { 45 eplc.NominalConcurrencyShares = new(int32) 46 *eplc.NominalConcurrencyShares = 0 47 } 48 if eplc.LendablePercent == nil { 49 eplc.LendablePercent = new(int32) 50 *eplc.LendablePercent = 0 51 } 52 } 53 54 func SetDefaults_LimitedPriorityLevelConfiguration(lplc *v1beta2.LimitedPriorityLevelConfiguration) { 55 if lplc.AssuredConcurrencyShares == 0 { 56 lplc.AssuredConcurrencyShares = PriorityLevelConfigurationDefaultAssuredConcurrencyShares 57 } 58 if lplc.LendablePercent == nil { 59 lplc.LendablePercent = new(int32) 60 *lplc.LendablePercent = 0 61 } 62 } 63 64 // SetDefaults_FlowSchema sets default values for flow schema 65 func SetDefaults_QueuingConfiguration(cfg *v1beta2.QueuingConfiguration) { 66 if cfg.HandSize == 0 { 67 cfg.HandSize = PriorityLevelConfigurationDefaultHandSize 68 } 69 if cfg.Queues == 0 { 70 cfg.Queues = PriorityLevelConfigurationDefaultQueues 71 } 72 if cfg.QueueLengthLimit == 0 { 73 cfg.QueueLengthLimit = PriorityLevelConfigurationDefaultQueueLengthLimit 74 } 75 }