-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[Azure VMs Pool] Support mixed agentpool types in Azure Cache #6689
[Azure VMs Pool] Support mixed agentpool types in Azure Cache #6689
Conversation
Hi @wenxuan0923. 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 Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
// GetOptions returns NodeGroupAutoscalingOptions that should be used for this particular | ||
// NodeGroup. Returning a nil will result in using default options. | ||
func (agentPool *VMsPool) GetOptions(defaults config.NodeGroupAutoscalingOptions) (*config.NodeGroupAutoscalingOptions, error) { | ||
// TODO(wenxuan): Implement this method | ||
return nil, cloudprovider.ErrNotImplemented | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'm aware. This whole file is now mostly place holders without any real implementation. I will add the required methods in the following PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern. Thank you.
@@ -137,7 +137,24 @@ func (m *AzureManager) fetchExplicitNodeGroups(specs []string) error { | |||
return nil | |||
} | |||
|
|||
// this pattern is for vms pool only "<minSize>:<maxSize>:<name>:vms" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the name of the nodepool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see from reading tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this spec change so we don't expose AKS internal terms to the public
@@ -32,6 +34,36 @@ type NodeGroupSpec struct { | |||
MaxSize int `json:"maxSize"` | |||
// Specifies whether this node group can scale to zero nodes. | |||
SupportScaleToZero bool | |||
// specifies the agentpool type, used for vms pool only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agentpool and vm pool is an AKS specific concept. config/dynamic falls outside of our cloudprovider, so when adding changes we should consider how the behavior will affect other cloud providers.
I wonder if we can call it PoolType instead since it will the the homogenous type of the pool, and that seems more cloud neutral vs vmtype which means something to aks but not anyone else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that makes sense! okay I will use a different approach them.
: change to use azure cache to track vms pools
c9255d9
to
d665ce6
Compare
vmPoolName := tags[agentpoolNameTag] | ||
// fall back to legacy tag name if not found | ||
if vmPoolName == nil { | ||
vmPoolName = tags["poolName"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add this as a const as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -51,6 +51,7 @@ type azureCache struct { | |||
// Cache content. | |||
resourceGroup string | |||
vmType string | |||
vmsPoolMap map[string]struct{} // track the nodepools that're vms pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a more defined type as opposed to just using struct? VMpools? I observe that we have defined this inside azure_vm_pool.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This map[string]struct{}
is just being used as set here, since golang doesn't have set
data structure. It is a common pattern as you can see many of such usage in rp code base.
The purpose is only to be able to find out if an agentpool is vms pool, given its name, so we don't need to use any specific data type here.
We are setting value like this:
vmsPoolMap[to.String(vmPoolName)] = struct{}{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/go.mod#L40 api machinery should have sets iirc you can use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All go implementations of set will use map[T]EmptyStruct for zero bytes.
https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets#Set is the location of the set package though that works with all types. Set in pkg/fields isn't one i have heard of before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the field to vmsPoolSet to make it much more clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
// GetOptions returns NodeGroupAutoscalingOptions that should be used for this particular | ||
// NodeGroup. Returning a nil will result in using default options. | ||
func (agentPool *VMsPool) GetOptions(defaults config.NodeGroupAutoscalingOptions) (*config.NodeGroupAutoscalingOptions, error) { | ||
// TODO(wenxuan): Implement this method | ||
return nil, cloudprovider.ErrNotImplemented | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern. Thank you.
// number is different from the number of nodes registered in Kubernetes. | ||
func (agentPool *VMsPool) TargetSize() (int, error) { | ||
// TODO(wenxuan): Implement this method | ||
return -1, cloudprovider.ErrNotImplemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we'll be implementing all of these in follow-up PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's right, to implement all the methods we will need the agentpool client PR to be merged first.
I'm trying to keep the PR small and self-contained, so it's easier to review. There will be more PRs coming next.
/lgtm |
/retest |
@wenxuan0923: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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/test-infra repository. |
/ok-to-test |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tallaxes, wenxuan0923 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
a7b4386
into
kubernetes:cluster-autoscaler-release-1.29
What type of PR is this?
/kind feature
What this PR does / why we need it:
Use Azure cache to track VMs pools. As of today, CAS can only be used for single type of agentpool - either vmss or standard. We need to support vms pool and mixed agentpool types (vmss + vms). During the cache generation, we will fetch all resources regardless of the vmType, and also track the vms pools using a set (implemented with golang map) so we can distinguish between vmss vm instances and vms instances.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Right now the file
azure_vms_pool.go
is just a place holder without real implementation.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: