Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#220 from ingvagabund/set-no-provid…
Browse files Browse the repository at this point in the history
…er-id-when-placement-is-nil

Check if placement is not nil before accessing AvailabilityZone field
  • Loading branch information
openshift-merge-robot authored Jun 3, 2019
2 parents 486b654 + 3fc30cb commit d502d4c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ func (a *Actuator) updateProviderID(machine *machinev1.Machine, instance *ec2.In
existingProviderID := machine.Spec.ProviderID
machineCopy := machine.DeepCopy()
if instance != nil {
providerID := fmt.Sprintf("aws:///%s/%s", aws.StringValue(instance.Placement.AvailabilityZone), aws.StringValue(instance.InstanceId))
availabilityZone := ""
if instance.Placement != nil {
availabilityZone = aws.StringValue(instance.Placement.AvailabilityZone)
}
providerID := fmt.Sprintf("aws:///%s/%s", availabilityZone, aws.StringValue(instance.InstanceId))

if existingProviderID != nil && *existingProviderID == providerID {
glog.Infof("ProviderID already set in the machine Spec with value:%s", *existingProviderID)
Expand Down

0 comments on commit d502d4c

Please sign in to comment.