Skip to content

Commit

Permalink
Merge pull request kubernetes#3815 from jayantjain93/additional_os_di…
Browse files Browse the repository at this point in the history
…stribution

added additional os-distributions
  • Loading branch information
k8s-ci-robot authored Jan 13, 2021
2 parents 93d5705 + d1ea9f4 commit dd9c0cf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cluster-autoscaler/cloudprovider/gce/reserved.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ func parsePercentageToRatio(percentString string) (float64, error) {
// CalculateOSReservedEphemeralStorage estimates how much ephemeral storage OS will reserve and eviction threshold
func CalculateOSReservedEphemeralStorage(diskSize int64, osDistribution OperatingSystemDistribution) int64 {
switch osDistribution {
case OperatingSystemDistributionCOS:
case OperatingSystemDistributionCOS, OperatingSystemDistributionCOSContainerd:
storage := int64(math.Ceil(0.015635*float64(diskSize))) + int64(math.Ceil(4.148*GiB)) // os partition estimation
storage += int64(math.Min(100*MiB, math.Ceil(0.001*float64(diskSize)))) // over-provisioning buffer
return storage
case OperatingSystemDistributionUbuntu:
case OperatingSystemDistributionUbuntu, OperatingSystemDistributionUbuntuContainerd:
storage := int64(math.Ceil(0.03083*float64(diskSize))) + int64(math.Ceil(0.171*GiB)) // os partition estimation
storage += int64(math.Min(100*MiB, math.Ceil(0.001*float64(diskSize)))) // over-provisioning buffer
return storage
Expand Down
8 changes: 8 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ const (
OperatingSystemDistributionWindowsSAC OperatingSystemDistribution = "windows_sac"
// OperatingSystemDistributionCOS is used if operating distribution system is COS
OperatingSystemDistributionCOS OperatingSystemDistribution = "cos"
// OperatingSystemDistributionCOSContainerd is used if operating distribution system is COS Containerd
OperatingSystemDistributionCOSContainerd OperatingSystemDistribution = "cos_containerd"
// OperatingSystemDistributionUbuntuContainerd is used if operating distribution system is Ubuntu Containerd
OperatingSystemDistributionUbuntuContainerd OperatingSystemDistribution = "ubuntu_containerd"

// OperatingSystemDistributionDefault defines which operating system will be assumed if not explicitly passed via AUTOSCALER_ENV_VARS
OperatingSystemDistributionDefault = OperatingSystemDistributionCOS
Expand Down Expand Up @@ -445,6 +449,10 @@ func extractOperatingSystemDistributionFromKubeEnv(kubeEnv string) OperatingSyst
return OperatingSystemDistributionWindowsSAC
case string(OperatingSystemDistributionCOS):
return OperatingSystemDistributionCOS
case string(OperatingSystemDistributionCOSContainerd):
return OperatingSystemDistributionCOSContainerd
case string(OperatingSystemDistributionUbuntuContainerd):
return OperatingSystemDistributionUbuntuContainerd
default:
klog.Errorf("unexpected os-distribution=%v passed via AUTOSCALER_ENV_VARS", osDistributionValue)
return OperatingSystemDistributionUnknown
Expand Down
22 changes: 22 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,28 @@ func TestExtractOperatingSystemDistributionFromKubeEnv(t *testing.T) {
"KUBELET_TEST_ARGS: --experimental-allocatable-ignore-eviction\n",
expectedOperatingSystemDistribution: OperatingSystemDistributionCOS,
},
{
name: "cos containerd",
kubeEnv: "ENABLE_NODE_PROBLEM_DETECTOR: 'daemonset'\n" +
"DNS_SERVER_IP: '10.0.0.10'\n" +
"AUTOSCALER_ENV_VARS: node_labels=a=b,c=d,cloud.google.com/gke-nodepool=pool-3,cloud.google.com/gke-preemptible=true;" +
"node_taints='dedicated=ml:NoSchedule,test=dev:PreferNoSchedule,a=b:c';" +
"kube_reserved=cpu=1000m,memory=300000Mi;" +
"os_distribution=cos_containerd\n" +
"KUBELET_TEST_ARGS: --experimental-allocatable-ignore-eviction\n",
expectedOperatingSystemDistribution: OperatingSystemDistributionCOSContainerd,
},
{
name: "ubuntu containerd",
kubeEnv: "ENABLE_NODE_PROBLEM_DETECTOR: 'daemonset'\n" +
"DNS_SERVER_IP: '10.0.0.10'\n" +
"AUTOSCALER_ENV_VARS: node_labels=a=b,c=d,cloud.google.com/gke-nodepool=pool-3,cloud.google.com/gke-preemptible=true;" +
"node_taints='dedicated=ml:NoSchedule,test=dev:PreferNoSchedule,a=b:c';" +
"kube_reserved=cpu=1000m,memory=300000Mi;" +
"os_distribution=ubuntu_containerd\n" +
"KUBELET_TEST_ARGS: --experimental-allocatable-ignore-eviction\n",
expectedOperatingSystemDistribution: OperatingSystemDistributionUbuntuContainerd,
},
{
name: "ubuntu",
kubeEnv: "ENABLE_NODE_PROBLEM_DETECTOR: 'daemonset'\n" +
Expand Down

0 comments on commit dd9c0cf

Please sign in to comment.