Commit 63dfd147 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51513 from yastij/aws-support-byProviderID

Automatic merge from submit-queue (batch tested with PRs 51513, 51515, 50570, 51482, 51448) implementation of GetZoneByProviderID and GetZoneByNodeName for AWS This a part of the #50926 effort cc @luxas **Release note**: ```release-note None ```
parents 1a3a0713 9585658e
...@@ -1240,14 +1240,38 @@ func (c *Cloud) GetZone() (cloudprovider.Zone, error) { ...@@ -1240,14 +1240,38 @@ func (c *Cloud) GetZone() (cloudprovider.Zone, error) {
// This is particularly useful in external cloud providers where the kubelet // This is particularly useful in external cloud providers where the kubelet
// does not initialize node data. // does not initialize node data.
func (c *Cloud) GetZoneByProviderID(providerID string) (cloudprovider.Zone, error) { func (c *Cloud) GetZoneByProviderID(providerID string) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByProviderID not implemented") instanceID, err := kubernetesInstanceID(providerID).mapToAWSInstanceID()
if err != nil {
return cloudprovider.Zone{}, err
}
instance, err := c.getInstanceByID(string(instanceID))
if err != nil {
return cloudprovider.Zone{}, err
}
zone := cloudprovider.Zone{
FailureDomain: *(instance.Placement.AvailabilityZone),
Region: c.region,
}
return zone, nil
} }
// GetZoneByNodeName implements Zones.GetZoneByNodeName // GetZoneByNodeName implements Zones.GetZoneByNodeName
// This is particularly useful in external cloud providers where the kubelet // This is particularly useful in external cloud providers where the kubelet
// does not initialize node data. // does not initialize node data.
func (c *Cloud) GetZoneByNodeName(nodeName types.NodeName) (cloudprovider.Zone, error) { func (c *Cloud) GetZoneByNodeName(nodeName types.NodeName) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not imeplemented") instance, err := c.getInstanceByNodeName(nodeName)
if err != nil {
return cloudprovider.Zone{}, err
}
zone := cloudprovider.Zone{
FailureDomain: *(instance.Placement.AvailabilityZone),
Region: c.region,
}
return zone, nil
} }
// Abstraction around AWS Instance Types // Abstraction around AWS Instance Types
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment