elegant-beach-10818
04/14/2023, 8:11 PM<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>: false to the argo pods but that doesn't prevent the issueancient-application-36103
04/14/2023, 11:05 PMuser
04/15/2023, 4:58 AMforeach )mammoth-rainbow-82717
04/15/2023, 6:39 AMuser
04/17/2023, 2:49 PMuser
04/17/2023, 2:50 PMAZRebalance option on the auto-scaling group: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-suspend-resume-processes.htmlelegant-beach-10818
04/17/2023, 9:19 PMis there a specific scenario when you see these failuresWe've seen this when one job is long running, and then another job is kicked off which causes the cluster to scale up. If the 2nd job completes and the cluster is now in need to scale down, occasionally it will pick the node that the first job is running on to terminate thus causing it to fail.
Are you running on any public cloud?Yes, this is on AWS using EKS Really appreciate the tips all. I'll test out suspending the AZRebalance process and report back
user
04/17/2023, 9:45 PMActivity tab in the AWS console to see if AWS terminated some nodes for rebalancing zones.elegant-beach-10818
04/18/2023, 1:36 AM--balance-similar-node-groups flag on the autoscaler being enabled. We deployed our EKS cluster using an internally customized version of the terraform aws eks module, and it had this flag hardcoded in it.
Thanks again for the directionuser
04/18/2023, 1:56 AMelegant-beach-10818
04/24/2023, 10:46 PMdefault 41m Normal ScaleDown node/ip-10-100-213-20.ec2.internal marked the node as toBeDeleted/unschedulable
kube-system 41m Normal ScaleDown configmap/cluster-autoscaler-status Scale-down: removing node ip-10-100-213-20.ec2.internal, utilization: {0.458712715855573 0.585732366900626 0 memory 0.585732366900626}, pods to reschedule: kube-system/overprovisioning-95bf6758f-m76xf ...* argo/t-f8rp5-swbqx ...*
argo 41m Normal ScaleDown pod/t-f8rp5-swbqx deleting pod for node scale down
(* There were several copies of the overprovisioning pod that I truncated)
And then this is from the autoscaling group:
At 2023-04-24T21:43:32Z instance i-001f39cb3f5de5e55 was taken out of service in response to a user request, shrinking the capacity from 4 to 3
This is with the AZRebalance process disabled on all 3 nodegroups we have running
Any thoughts of where to look next?elegant-beach-10818
04/24/2023, 10:50 PMresource "helm_release" "cluster_autoscaler" {
name = "cluster-autoscaler"
repository = "<https://kubernetes.github.io/autoscaler/>"
chart = "cluster-autoscaler"
namespace = var.namespace
version = var.chart_version
timeout = 600
provider = helm
set {
name = "image.tag"
value = "v1.23.0"
}
set {
name = "autoDiscovery.enabled"
value = "true"
}
set {
name = "autoDiscovery.clusterName"
value = var.cluster_name
}
set {
name = "autoDiscovery.tags"
value = "{${join(",", ["<http://k8s.io/cluster-autoscaler/enabled=true|k8s.io/cluster-autoscaler/enabled=true>", "<http://k8s.io/cluster-autoscaler/${var.cluster_name}=owned|k8s.io/cluster-autoscaler/${var.cluster_name}=owned>"])}}"
}
set {
name = "cloudProvider"
value = "aws"
}
set {
name = "awsRegion"
value = var.region
}
set {
name = "rbac.create"
value = "true"
}
set {
name = "rbac.serviceAccount.name"
value = var.service_account
}
set {
name = "rbac.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = module.iam_assumable_role_admin.iam_role_arn
}
set {
name = "extraArgs.expander"
value = local.ca_expander
}
set {
name = "expanderPriorities"
value = local.expander_config
}
set {
name = "extraArgs.balance-similar-node-groups"
value = "false"
}
set {
name = "extraArgs.balancing-ignore-label_1"
value = "<http://topology.ebs.csi.aws.com/zone|topology.ebs.csi.aws.com/zone>"
}
set {
name = "extraArgs.balancing-ignore-label_2"
value = "<http://vpc.amazonaws.com/eniConfig|vpc.amazonaws.com/eniConfig>"
}
set {
name = "extraArgs.balancing-ignore-label_3"
value = "<http://beta.kubernetes.io/instance-type|beta.kubernetes.io/instance-type>"
}
set {
name = "extraArgs.balancing-ignore-label_4"
value = "<http://node.kubernetes.io/instance-type|node.kubernetes.io/instance-type>"
}
set {
name = "extraArgs.balancing-ignore-label_5"
value = "<http://eks.amazonaws.com/sourceLaunchTemplateId|eks.amazonaws.com/sourceLaunchTemplateId>"
}
set {
name = "extraArgs.balancing-ignore-label_6"
value = "<http://eks.amazonaws.com/sourceLaunchTemplateVersion|eks.amazonaws.com/sourceLaunchTemplateVersion>"
}
set {
name = "extraArgs.balancing-ignore-label_7"
value = "<http://eks.amazonaws.com/capacityType|eks.amazonaws.com/capacityType>"
}
set {
name = "extraArgs.skip-nodes-with-system-pods"
value = "false"
}
set {
name = "extraArgs.scale-down-unneeded-time"
value = "5m0s"
}
set {
name = "extraArgs.scale-down-unready-time"
value = "10m0s"
}
# Reduce provision time 15->5 to fallback to ondemand quickly
set {
name = "extraArgs.max-node-provision-time"
value = "5m0s"
}
set {
name = "extraArgs.scale-down-utilization-threshold"
value = "0.75"
}
set {
name = "extraArgs.skip-nodes-with-local-storage"
value = "false"
}elegant-beach-10818
04/24/2023, 11:28 PM0.75 utilization threshold and the 5 min unneeded timeuser
04/25/2023, 2:05 AMproud-eye-90172
04/25/2023, 4:26 AMscaleDownUtilizationThreshold option might be a place to start. You can see the actual utilization in that autoscaler log output. So, keeping the threshold below that might be a good experiment. But, it will affect other autoscaling behavior and maybe increase costs.
One other option is to add a small piece of code in the step to disable autoscaler from scaling down a node on which the step is running. You can add the following annotation to the node:
<http://cluster-autoscaler.kubernetes.io/scale-down-disabled|cluster-autoscaler.kubernetes.io/scale-down-disabled>: trueelegant-beach-10818
04/25/2023, 2:14 PM"<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>": "false"ancient-application-36103
04/25/2023, 2:41 PMmammoth-rainbow-82717
04/25/2023, 3:08 PMmammoth-rainbow-82717
04/25/2023, 3:09 PMelegant-beach-10818
04/25/2023, 3:13 PMkube-system 41m Normal ScaleDown configmap/cluster-autoscaler-status Scale-down: removing node ip-10-100-213-20.ec2.internal, utilization: {0.458712715855573 0.585732366900626 0 memory 0.585732366900626}
Our threshold is pretty high (0.75) so I think that's the reason for this.
@square-wire-39606 Would it make sense to add this annotation to all jobs created by metaflow by adding the below? I can't think of a use case where it would be useful for a running metaflow job to be targeted for scale down by the autoscaler:
job.annotation("<http://autoscaler.kubernetes.io/safe-to-evict|autoscaler.kubernetes.io/safe-to-evict>", "false"),
https://github.com/Netflix/metaflow/blob/master/metaflow/plugins/kubernetes/kubernetes.py#L272mammoth-rainbow-82717
04/25/2023, 3:18 PMuser
04/25/2023, 3:19 PM@resources or @kubernetes). We can ensure that if the pod had resources > autoscaler threshold, the flows complete. Then, it could come down to adding the annotation or changing the autoscaler config.user
04/25/2023, 3:39 PMWe've tried adding the annotationto the argo pods but that doesn't prevent the issue<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>: false
elegant-beach-10818
04/25/2023, 5:27 PMWe've tried adding the annotationThis was before I disabled the AZRebalance process in the autoscaling groups. I'm pretty sure the AZRebalance doesn't respect pod annotations I was able to reproduce the error with the following setup: 2 nodegroups that both only have the 6mi.4xlarge instances (both nodegroups have the AZRebalance process disabled) Used the decoratorto the argo pods but that doesn't prevent the issue<http://cluster-autoscaler.kubernetes.io/safe-to-evict|cluster-autoscaler.kubernetes.io/safe-to-evict>: false
@kubernetes(cpu=2, memory=33000) on a foreach step that would create 4 children steps. Because the instance has 64 GB of RAM, it wouldn't be possible to schedule multiple foreach steps on the same Node. Ran this flow 4 times in parallel so that there were 16 total nodes. After all the pods had been scheduled, I killed 2 of the flows so there are only 8 steps running. After a 5 minutes one of the remaining 8 steps failed and I observed this kubernetes event:
kube-system 43m Normal ScaleDown configmap/cluster-autoscaler-status Scale-down: removing node ip-10-100-181-71.ec2.internal, utilization: {0.3530522341095028 0.6419678241519629 0 memory 0.6419678241519629}, pods to reschedule: argo/t-2w9zh-2tkb ...
followed by this
argo 43m Warning BackoffLimitExceeded job/t-2w9zh Job has reached the specified backoff limit
It seems that it is indeed related to the autoscaler
In a 2nd test, I added the annotation .annotation("<http://autoscaler.kubernetes.io/safe-to-evict|autoscaler.kubernetes.io/safe-to-evict>", "false") to this file:
https://github.com/Netflix/metaflow/blob/master/metaflow/plugins/kubernetes/kubernetes.py#L273
I then pip installed this fork of metaflow. I ran the same test as above and didn't have any of the remaining 8 steps fail after killing 2 flows. I also noticed this in the autoscaler logs:
I0425 17:03:32.707952 1 cluster.go:192] Fast evaluation: node ip-10-100-181-254.ec2.internal is not suitable for removal: failed to find place for argo/t-8zwsn-gkgxh
It seems that the annotation successfully prevented the autoscaler from trying to reschedule the poduser
04/25/2023, 6:22 PM@retry and are okay with their pods restarting on a different node in order to save costs. But, it'll be best to ask.elegant-beach-10818
04/25/2023, 6:33 PMelegant-beach-10818
04/25/2023, 9:29 PMI0425 21:25:38.435423 1 cluster.go:169] Fast evaluation: node ip-10-100-177-47.ec2.internal cannot be removed: pod annotated as not safe to evict present: t-r5qgg-fgjv7