Skip to content

Conversation

mperea
Copy link

@mperea mperea commented Oct 12, 2025

This commit adds support for the optional project-id parameter in CloudStack cloud provider configuration. This is required for clusters running in CloudStack projects, as the listKubernetesClusters API returns empty results when querying by cluster ID without the projectid parameter in multi-project environments.

Changes:

  • Add ProjectID field to service.Config struct
  • Pass ProjectID from cloud-config to service configuration
  • Include projectid parameter in all CKS API calls when configured:
    • listKubernetesClusters (GetClusterDetails)
    • scaleKubernetesCluster (ScaleCluster and RemoveNodesFromCluster)
  • Update README.md to document the optional project-id parameter

The project-id parameter is optional and backwards compatible. If not specified, the API uses the default project associated with the credentials.

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes a critical issue where the cluster-autoscaler fails to work with Kubernetes clusters running in CloudStack projects.

Problem: The autoscaler currently ignores the project-id configured in the cloud-config and doesn't include the projectid parameter in API calls to CloudStack. This causes the listKubernetesClusters API to return empty results even when the cluster exists, resulting in continuous errors:

Failed to refresh cloud provider config: Unable to fetch cluster with id: <cluster-id>

Solution: This PR adds support for the optional project-id parameter by:

  1. Adding a ProjectID field to the service configuration
  2. Including the projectid parameter in all CloudStack API calls when configured
  3. Maintaining backward compatibility (parameter is optional)

Which issue(s) this PR fixes:

Special notes for your reviewer:

  • The project-id parameter is optional and maintains full backward compatibility
  • If not specified, the API uses the default project associated with the credentials
  • All existing unit tests pass successfully (35 tests)
  • The fix has been validated in a production CloudStack environment (Linube) with Kubernetes v1.33.1
  • The implementation follows the same pattern used in other CloudStack API calls

Testing performed:

cd cluster-autoscaler
go test ./cloudprovider/cloudstack/... -v
# Result: PASS (all 35 tests passed)

Does this PR introduce a user-facing change?

cluster-autoscaler/cloudstack: Add optional project-id support for multi-project CloudStack environments. Users can now specify project-id in cloud-config to use autoscaler with clusters in CloudStack projects.

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

- [CloudStack API Documentation](https://cloudstack.apache.org/api/apidocs-4.21/)
- [Updated README with project-id configuration](https://github.com/kubernetes/autoscaler/blob/fix/cloudstack-project-id-support/cluster-autoscaler/cloudprovider/cloudstack/README.md)

…ct environments

This commit adds support for the optional project-id parameter in CloudStack
cloud provider configuration. This is required for clusters running in
CloudStack projects, as the listKubernetesClusters API returns empty results
when querying by cluster ID without the projectid parameter in multi-project
environments.

Changes:
- Add ProjectID field to service.Config struct
- Pass ProjectID from cloud-config to service configuration
- Include projectid parameter in all CKS API calls when configured:
  * listKubernetesClusters (GetClusterDetails)
  * scaleKubernetesCluster (ScaleCluster and RemoveNodesFromCluster)
- Update README.md to document the optional project-id parameter

The project-id parameter is optional and backwards compatible. If not
specified, the API uses the default project associated with the credentials.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Oct 12, 2025
Copy link

linux-foundation-easycla bot commented Oct 12, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: mperea / name: Mario Perea (d843c11)

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mperea
Once this PR has been reviewed and has the lgtm label, please assign bigdarkclown 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
Copy link
Contributor

Hi @mperea. 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 12, 2025
@k8s-ci-robot k8s-ci-robot requested review from feiskyer and x13n October 12, 2025 17:15
@k8s-ci-robot k8s-ci-robot added area/cluster-autoscaler size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-area cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 12, 2025
@jackfrancis
Copy link
Contributor

/label area/cloudstack

@k8s-ci-robot
Copy link
Contributor

@jackfrancis: The label(s) /label area/cloudstack cannot be applied. These labels are supported: api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor, ci-short, ci-extended, ci-full. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

/label area/cloudstack

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.

@jackfrancis jackfrancis added the area/cloudstack Issues or PRs related to the CloudStack cloud provider implementation label Oct 13, 2025
@jackfrancis
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cloudstack Issues or PRs related to the CloudStack cloud provider implementation area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

3 participants