awsmachine_controller: Log EC2 instance ID when available
@@ -179,15 +179,17 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
return reconcile.Result{}, nil
}
+ machineScope.V(3).Info("Instance found matching deleted AWSMachine", "instanceID", instance.ID)
+
// Check the instance state. If it's already shutting down or terminated,
// do nothing. Otherwise attempt to delete it.
// This decision is based on the ec2-instance-lifecycle graph at
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html
switch instance.State {
case infrav1.InstanceStateShuttingDown, infrav1.InstanceStateTerminated:
- machineScope.Info("Instance is shutting down or already terminated")
+ machineScope.Info("Instance is shutting down or already terminated", "instanceID", instance.ID)
default:
- machineScope.Info("Terminating instance")
+ machineScope.Info("Terminating instance", "instanceID", instance.ID)
if err := ec2Service.TerminateInstanceAndWait(instance.ID); err != nil {
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedTerminate", "Failed to terminate instance %q: %v", instance.ID, err)
return reconcile.Result{}, errors.Errorf("failed to terminate instance: %+v", err)
@@ -200,7 +202,11 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
return reconcile.Result{}, errors.Errorf("failed to get core security groups to detach from instance's network interfaces: %+v", err)
}
- machineScope.V(3).Info("Detaching security groups from provided network interface", "groups", core)
+ machineScope.V(3).Info(
+ "Detaching security groups from provided network interface",
+ "groups", core,
+ "instanceID", instance.ID,
+ )
for _, id := range machineScope.AWSMachine.Spec.NetworkInterfaces {
if err := ec2Service.DetachSecurityGroupsFromNetworkInterface(core, id); err != nil {
