Skip to content

Add support for SageMaker HyperPod nodes by skipping them in cluster autoscaler #8195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

YQ-Wang
Copy link

@YQ-Wang YQ-Wang commented Jun 3, 2025

What type of PR is this?

What this PR does / why we need it:

/kind bug

Which issue(s) this PR fixes:

Fixes #7540

Special notes for your reviewer:

SageMaker HyperPod provides managed Kubernetes nodes, but these nodes break the cluster autoscaler because:

  • Provider ID parsing fails: HyperPod nodes use a different provider ID format aws:///region/sagemaker/cluster/instance-id that doesn't match the standard EC2 format expected by AwsRefFromProviderId()
  • Cluster autoscaler crashes: When the autoscaler encounters HyperPod nodes, it fails to parse their provider IDs and returns errors, preventing proper operation for the autoscaler for the entire EKS cluster.
  • HyperPod nodes shouldn't be autoscaled: These are managed nodes that should not be scaled by the cluster autoscaler anyway

Following the same pattern used for Fargate nodes, this PR adds support for SageMaker HyperPod nodes by:

  • Detecting SageMaker nodes: Check for /sagemaker in the provider ID string
  • Skipping autoscaling operations: Return early from methods that would otherwise try to manage these nodes
  • Graceful handling: Return appropriate responses (nil, ErrNotImplemented) instead of errors

Does this PR introduce a user-facing change?

"NONE"

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 3, 2025
Copy link

linux-foundation-easycla bot commented Jun 3, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. area/cluster-autoscaler labels Jun 3, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @YQ-Wang!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @YQ-Wang. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/provider/aws Issues or PRs related to aws provider labels Jun 3, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: YQ-Wang
Once this PR has been reviewed and has the lgtm label, please assign gjtempleton for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 3, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 3, 2025
@@ -115,6 +115,13 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
klog.Warningf("Node %v has no providerId", node.Name)
return nil, nil
}

// Skip SageMaker instances
if strings.Contains(node.Spec.ProviderID, "/sagemaker") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for submitting the PR. I work on SageMaker HyperPod and ignoring HyperPod nodes in cluster autoscaler is correct approach as cluster autoscaler integration is not supported.

Getting a review from folks who have expertise on this codebase would be helpful.

Question - Should this change be similar to fargate? hyperpod nodes have hyperpod- prefix
https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go#L142-L144

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we can change the logic to checking the hyperpod- prefix.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL

@@ -115,6 +115,13 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
klog.Warningf("Node %v has no providerId", node.Name)
return nil, nil
}

// Skip SageMaker instances
if strings.HasPrefix(node.GetName(), "hyperpod") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of prefix on the node name, can we rely on a custom tag on the node?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the aws hyperpod engineer @surajkota suggests me to check the prefix in order to match the current pattern for fargate so I modified it to the current approach that comparing the prefix.

https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go#L142-L144
#8195 (comment)

@@ -209,6 +221,14 @@ var validAwsRefIdRegex = regexp.MustCompile(fmt.Sprintf(`^aws\:\/\/\/[-0-9a-z]*\
// AwsRefFromProviderId creates AwsInstanceRef object from provider id which
// must be in format: aws:///zone/name
func AwsRefFromProviderId(id string) (*AwsInstanceRef, error) {
// Special case for SageMaker format: aws:///<region>/sagemaker/...
if strings.HasPrefix(id, "aws:///") && strings.Contains(id, "/sagemaker") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a pattern match here instead of prefix check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -143,6 +150,11 @@ func (aws *awsCloudProvider) HasInstance(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// Skip SageMaker instances
if strings.HasPrefix(node.GetName(), "hyperpod") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to understand why do you install CAS on the cluster when the worker nodes naming convention doesn't work properly with CAS scheduler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HyperPod is a sagemaker instance pool that supports working with the existing EKS cluster. While hyperpod currently doesn't work with CAS, the regular EC2 instances requires CAS in the EKS cluster.

@YQ-Wang YQ-Wang requested a review from ravisinha0506 June 10, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoscaler auto discover fails with sagemaker hyperpod
4 participants