mirror of https://github.com/kubernetes/kops.git
Merge pull request #27 from justinsb/upup_aws_image_aliases
upup: Map matching image ids to source name
This commit is contained in:
commit
01590a9704
|
@ -232,6 +232,19 @@ func (e *AutoscalingGroup) findLaunchConfiguration(c *fi.Context, name string, d
|
|||
dest.IAMInstanceProfile = &IAMInstanceProfile{Name: i.IamInstanceProfile}
|
||||
dest.AssociatePublicIP = i.AssociatePublicIpAddress
|
||||
|
||||
// Avoid spurious changes on ImageId
|
||||
if e.ImageID != nil && dest.ImageID != nil && *dest.ImageID != *e.ImageID {
|
||||
image, err := cloud.ResolveImage(*e.ImageID)
|
||||
if err != nil {
|
||||
glog.Warningf("unable to resolve image: %q: %v", *e.ImageID, err)
|
||||
} else if image == nil {
|
||||
glog.Warningf("unable to resolve image: %q: not found", *e.ImageID)
|
||||
} else if aws.StringValue(image.ImageId) == *dest.ImageID {
|
||||
glog.V(4).Infof("Returning matching ImageId as expected name: %q -> %q", *dest.ImageID, *e.ImageID)
|
||||
dest.ImageID = e.ImageID
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,19 @@ func (e *Instance) Find(c *fi.Context) (*Instance, error) {
|
|||
|
||||
e.ID = actual.ID
|
||||
|
||||
// Avoid spurious changes on ImageId
|
||||
if e.ImageID != nil && actual.ImageID != nil && *actual.ImageID != *e.ImageID {
|
||||
image, err := cloud.ResolveImage(*e.ImageID)
|
||||
if err != nil {
|
||||
glog.Warningf("unable to resolve image: %q: %v", *e.ImageID, err)
|
||||
} else if image == nil {
|
||||
glog.Warningf("unable to resolve image: %q: not found", *e.ImageID)
|
||||
} else if aws.StringValue(image.ImageId) == *actual.ImageID {
|
||||
glog.V(4).Infof("Returning matching ImageId as expected name: %q -> %q", *actual.ImageID, *e.ImageID)
|
||||
actual.ImageID = e.ImageID
|
||||
}
|
||||
}
|
||||
|
||||
return actual, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ func (t *AWSCloud) DescribeVPC(vpcID string) (*ec2.Vpc, error) {
|
|||
// owner/name in which case we find the image with the specified name, owned by owner
|
||||
// name in which case we find the image with the specified name, with the current owner
|
||||
func (c *AWSCloud) ResolveImage(name string) (*ec2.Image, error) {
|
||||
// TODO: Cache this result during a single execution (we get called multiple times)
|
||||
glog.V(2).Infof("Calilng DescribeImages to resolve name %q", name)
|
||||
request := &ec2.DescribeImagesInput{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue