@@ -1337,6 +1337,12 @@ pub struct CredentialProvider {
13371337pub enum KubernetesCPUManagerPolicyOption {
13381338 #[ serde( rename = "full-pcpus-only" ) ]
13391339 FullPCPUsOnly ,
1340+ #[ serde( rename = "distribute-cpus-across-numa" ) ]
1341+ DistributeCPUsAcrossNUMA ,
1342+ #[ serde( rename = "prefer-align-cpus-by-uncorecache" ) ]
1343+ PreferAlignCPUsByUncorecache ,
1344+ #[ serde( rename = "strict-cpu-reservation" ) ]
1345+ StrictCPUReservation ,
13401346}
13411347
13421348#[ cfg( test) ]
@@ -1346,8 +1352,12 @@ mod test_kubernetes_cpu_manager_policy_option {
13461352
13471353 #[ test]
13481354 fn good_cpu_manager_policy_option ( ) {
1349- {
1350- let ok = & "full-pcpus-only" ;
1355+ for ok in & [
1356+ "full-pcpus-only" ,
1357+ "distribute-cpus-across-numa" ,
1358+ "prefer-align-cpus-by-uncorecache" ,
1359+ "strict-cpu-reservation" ,
1360+ ] {
13511361 KubernetesCPUManagerPolicyOption :: try_from ( * ok) . unwrap ( ) ;
13521362 }
13531363 }
@@ -1492,6 +1502,55 @@ mod test_kubernetes_memory_swap_behavior {
14921502
14931503// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
14941504
1505+ /// KubernetesIdsPerPodValue represents an integer that contains a valid Kubernetes idsPerPod value.
1506+ /// Must be a multiple of 65536 and less than 1<<32. Upstream validation:
1507+ /// https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/apis/config/validation/validation_linux.go
1508+ #[ derive( Debug , Clone , Eq , PartialEq , Hash , Serialize , Deserialize ) ]
1509+ #[ serde( try_from = "i64" , into = "i64" ) ]
1510+ pub struct KubernetesIdsPerPodValue {
1511+ inner : i64 ,
1512+ }
1513+
1514+ impl TryFrom < i64 > for KubernetesIdsPerPodValue {
1515+ type Error = error:: Error ;
1516+
1517+ fn try_from ( input : i64 ) -> Result < Self , Self :: Error > {
1518+ ensure ! (
1519+ input % 65536 == 0 && input < ( 1i64 << 32 ) ,
1520+ error:: InvalidKubernetesIdsPerPodValueSnafu { input }
1521+ ) ;
1522+ Ok ( KubernetesIdsPerPodValue { inner : input } )
1523+ }
1524+ }
1525+
1526+ impl From < KubernetesIdsPerPodValue > for i64 {
1527+ fn from ( val : KubernetesIdsPerPodValue ) -> Self {
1528+ val. inner
1529+ }
1530+ }
1531+
1532+ #[ cfg( test) ]
1533+ mod test_kubernetes_ids_per_pod_value {
1534+ use super :: KubernetesIdsPerPodValue ;
1535+ use std:: convert:: TryFrom ;
1536+
1537+ #[ test]
1538+ fn good_values ( ) {
1539+ for ok in & [ 0 , 65536 , 131072 , 196608 , 4294901760 ] {
1540+ KubernetesIdsPerPodValue :: try_from ( * ok) . unwrap ( ) ;
1541+ }
1542+ }
1543+
1544+ #[ test]
1545+ fn bad_values ( ) {
1546+ for err in & [ 1 , 65535 , 65537 , 4294967296 ] {
1547+ KubernetesIdsPerPodValue :: try_from ( * err) . unwrap_err ( ) ;
1548+ }
1549+ }
1550+ }
1551+
1552+ // =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
1553+
14951554/// NvidiaDevicePluginSettings contains the device sharing and partitioning related settings for Nvidia gpu.
14961555#[ model( impl_default = true ) ]
14971556pub struct NvidiaDevicePluginSettings {
0 commit comments