mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	AWS: Don't pretend getSelfAWSInstance can return an error
It can't any more; this simplifies calling code.
This commit is contained in:
		@@ -370,10 +370,7 @@ func (self *AWSCloud) AddSSHKeyToAllInstances(user string, keyData []byte) error
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a *AWSCloud) CurrentNodeName(hostname string) (string, error) {
 | 
					func (a *AWSCloud) CurrentNodeName(hostname string) (string, error) {
 | 
				
			||||||
	selfInstance, err := a.getSelfAWSInstance()
 | 
						selfInstance := a.getSelfAWSInstance()
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return "", err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return selfInstance.nodeName, nil
 | 
						return selfInstance.nodeName, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -717,10 +714,7 @@ func (aws *AWSCloud) Routes() (cloudprovider.Routes, bool) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NodeAddresses is an implementation of Instances.NodeAddresses.
 | 
					// NodeAddresses is an implementation of Instances.NodeAddresses.
 | 
				
			||||||
func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
 | 
					func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
 | 
				
			||||||
	self, err := aws.getSelfAWSInstance()
 | 
						self := aws.getSelfAWSInstance()
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if self.nodeName == name || len(name) == 0 {
 | 
						if self.nodeName == name || len(name) == 0 {
 | 
				
			||||||
		addresses := []api.NodeAddress{}
 | 
							addresses := []api.NodeAddress{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -777,11 +771,7 @@ func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// ExternalID returns the cloud provider ID of the specified instance (deprecated).
 | 
					// ExternalID returns the cloud provider ID of the specified instance (deprecated).
 | 
				
			||||||
func (aws *AWSCloud) ExternalID(name string) (string, error) {
 | 
					func (aws *AWSCloud) ExternalID(name string) (string, error) {
 | 
				
			||||||
	awsInstance, err := aws.getSelfAWSInstance()
 | 
						awsInstance := aws.getSelfAWSInstance()
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return "", err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if awsInstance.nodeName == name {
 | 
						if awsInstance.nodeName == name {
 | 
				
			||||||
		// We assume that if this is run on the instance itself, the instance exists and is alive
 | 
							// We assume that if this is run on the instance itself, the instance exists and is alive
 | 
				
			||||||
		return awsInstance.awsID, nil
 | 
							return awsInstance.awsID, nil
 | 
				
			||||||
@@ -801,11 +791,7 @@ func (aws *AWSCloud) ExternalID(name string) (string, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// InstanceID returns the cloud provider ID of the specified instance.
 | 
					// InstanceID returns the cloud provider ID of the specified instance.
 | 
				
			||||||
func (aws *AWSCloud) InstanceID(name string) (string, error) {
 | 
					func (aws *AWSCloud) InstanceID(name string) (string, error) {
 | 
				
			||||||
	awsInstance, err := aws.getSelfAWSInstance()
 | 
						awsInstance := aws.getSelfAWSInstance()
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return "", err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// In the future it is possible to also return an endpoint as:
 | 
						// In the future it is possible to also return an endpoint as:
 | 
				
			||||||
	// <endpoint>/<zone>/<instanceid>
 | 
						// <endpoint>/<zone>/<instanceid>
 | 
				
			||||||
	if awsInstance.nodeName == name {
 | 
						if awsInstance.nodeName == name {
 | 
				
			||||||
@@ -821,11 +807,7 @@ func (aws *AWSCloud) InstanceID(name string) (string, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// InstanceType returns the type of the specified instance.
 | 
					// InstanceType returns the type of the specified instance.
 | 
				
			||||||
func (aws *AWSCloud) InstanceType(name string) (string, error) {
 | 
					func (aws *AWSCloud) InstanceType(name string) (string, error) {
 | 
				
			||||||
	awsInstance, err := aws.getSelfAWSInstance()
 | 
						awsInstance := aws.getSelfAWSInstance()
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return "", err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if awsInstance.nodeName == name {
 | 
						if awsInstance.nodeName == name {
 | 
				
			||||||
		return awsInstance.instanceType, nil
 | 
							return awsInstance.instanceType, nil
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
@@ -1237,9 +1219,9 @@ func (self *awsDisk) deleteVolume() (bool, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Gets the awsInstance for the EC2 instance on which we are running
 | 
					// Gets the awsInstance for the EC2 instance on which we are running
 | 
				
			||||||
// may return nil in case of error
 | 
					// may return nil in case of error
 | 
				
			||||||
func (c *AWSCloud) getSelfAWSInstance() (*awsInstance, error) {
 | 
					func (c *AWSCloud) getSelfAWSInstance() *awsInstance {
 | 
				
			||||||
	// Note that we cache some state in awsInstance (mountpoints), so we must preserve the instance
 | 
						// Note that we cache some state in awsInstance (mountpoints), so we must preserve the instance
 | 
				
			||||||
	return c.selfAWSInstance, nil
 | 
						return c.selfAWSInstance
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Builds the awsInstance for the EC2 instance on which we are running.
 | 
					// Builds the awsInstance for the EC2 instance on which we are running.
 | 
				
			||||||
@@ -1264,12 +1246,8 @@ func (c *AWSCloud) buildSelfAWSInstance() (*awsInstance, error) {
 | 
				
			|||||||
// Gets the awsInstance with node-name nodeName, or the 'self' instance if nodeName == ""
 | 
					// Gets the awsInstance with node-name nodeName, or the 'self' instance if nodeName == ""
 | 
				
			||||||
func (aws *AWSCloud) getAwsInstance(nodeName string) (*awsInstance, error) {
 | 
					func (aws *AWSCloud) getAwsInstance(nodeName string) (*awsInstance, error) {
 | 
				
			||||||
	var awsInstance *awsInstance
 | 
						var awsInstance *awsInstance
 | 
				
			||||||
	var err error
 | 
					 | 
				
			||||||
	if nodeName == "" {
 | 
						if nodeName == "" {
 | 
				
			||||||
		awsInstance, err = aws.getSelfAWSInstance()
 | 
							awsInstance = aws.getSelfAWSInstance()
 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return nil, fmt.Errorf("error getting self-instance: %v", err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		instance, err := aws.getInstanceByNodeName(nodeName)
 | 
							instance, err := aws.getInstanceByNodeName(nodeName)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user