-
Notifications
You must be signed in to change notification settings - Fork 41.5k
api: add the ProviderID attribute to NodeSpec #7775
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
Changes from all commits
1943432
faba129
2a89428
466a7da
185d0e1
afcda70
154ecce
1a41082
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ import ( | |
"github.com/golang/glog" | ||
) | ||
|
||
const ProviderName = "aws" | ||
|
||
// Abstraction over EC2, to allow mocking/other implementations | ||
type EC2 interface { | ||
// Query EC2 for instances matching the filter | ||
|
@@ -250,7 +252,7 @@ func (s *awsSdkEC2) DeleteVolume(volumeID string) (resp *ec2.DeleteVolumeOutput, | |
} | ||
|
||
func init() { | ||
cloudprovider.RegisterCloudProvider("aws", func(config io.Reader) (cloudprovider.Interface, error) { | ||
cloudprovider.RegisterCloudProvider(ProviderName, func(config io.Reader) (cloudprovider.Interface, error) { | ||
metadata := &awsSdkMetadata{} | ||
return newAWSCloud(config, getAuth, metadata) | ||
}) | ||
|
@@ -366,6 +368,11 @@ func (aws *AWSCloud) Clusters() (cloudprovider.Clusters, bool) { | |
return nil, false | ||
} | ||
|
||
// ProviderName returns the cloud provider ID. | ||
func (aws *AWSCloud) ProviderName() string { | ||
return ProviderName | ||
} | ||
|
||
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for Amazon Web Services. | ||
func (aws *AWSCloud) TCPLoadBalancer() (cloudprovider.TCPLoadBalancer, bool) { | ||
return nil, false | ||
|
@@ -420,7 +427,7 @@ func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) { | |
return addresses, nil | ||
} | ||
|
||
// ExternalID returns the cloud provider ID of the specified instance. | ||
// ExternalID returns the cloud provider ID of the specified instance (deprecated). | ||
func (aws *AWSCloud) ExternalID(name string) (string, error) { | ||
inst, err := aws.getInstancesByDnsName(name) | ||
if err != nil { | ||
|
@@ -429,6 +436,17 @@ func (aws *AWSCloud) ExternalID(name string) (string, error) { | |
return *inst.InstanceID, nil | ||
} | ||
|
||
// InstanceID returns the cloud provider ID of the specified instance. | ||
func (aws *AWSCloud) InstanceID(name string) (string, error) { | ||
inst, err := aws.getInstancesByDnsName(name) | ||
if err != nil { | ||
return "", err | ||
} | ||
// In the future it is possible to also return an endpoint as: | ||
// <endpoint>/<zone>/<instanceid> | ||
return "/" + *inst.Placement.AvailabilityZone + "/" + *inst.InstanceID, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should InstanceID return a name with a leading slash (here and all other cloudproviders)? You prefix it with ProviderName() followed by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a comment above: in the future the format may be: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok. |
||
} | ||
|
||
// Return the instances matching the relevant private dns name. | ||
func (aws *AWSCloud) getInstancesByDnsName(name string) (*ec2.Instance, error) { | ||
f := &ec2InstanceFilter{} | ||
|
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.
@bgrant0607 do we want to put a deprecated field into the v1 api?
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. We'll rip it out when we rip out the beta API versions.