Skip to content

Commit 8d4f47f

Browse files
committed
Change the AWSMachine controller behavior to not block and confirm ec2 termination or ec2 creation and wait for a future reconcile if necessary
1 parent f409449 commit 8d4f47f

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

controllers/awsmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
352352
return ctrl.Result{}, err
353353
}
354354

355-
if err := ec2Service.TerminateInstanceAndWait(instance.ID); err != nil {
355+
if err := ec2Service.TerminateInstance(instance.ID); err != nil {
356356
machineScope.Error(err, "failed to terminate instance")
357357
conditions.MarkFalse(machineScope.AWSMachine, infrav1.InstanceReadyCondition, "DeletingFailed", clusterv1.ConditionSeverityWarning, err.Error())
358358
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedTerminate", "Failed to terminate instance %q: %v", instance.ID, err)

pkg/cloud/services/ec2/instances.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ limitations under the License.
1717
package ec2
1818

1919
import (
20-
"context"
2120
"encoding/base64"
2221
"fmt"
2322
"sort"
2423
"strings"
25-
"time"
2624

2725
"github.com/aws/aws-sdk-go/aws"
28-
"github.com/aws/aws-sdk-go/aws/request"
2926
"github.com/aws/aws-sdk-go/service/ec2"
3027
"github.com/pkg/errors"
3128
"k8s.io/utils/pointer"
@@ -34,7 +31,6 @@ import (
3431
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/awserrors"
3532
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/converters"
3633
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/filter"
37-
awslogs "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/logs"
3834
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
3935
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/userdata"
4036
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/record"
@@ -591,19 +587,6 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan
591587
return nil, errors.Errorf("no instance returned for reservation %v", out.GoString())
592588
}
593589

594-
waitTimeout := 1 * time.Minute
595-
s.scope.Debug("Waiting for instance to be in running state", "instance-id", *out.Instances[0].InstanceId, "timeout", waitTimeout.String())
596-
ctx, cancel := context.WithTimeout(aws.BackgroundContext(), waitTimeout)
597-
defer cancel()
598-
599-
if err := s.EC2Client.WaitUntilInstanceRunningWithContext(
600-
ctx,
601-
&ec2.DescribeInstancesInput{InstanceIds: []*string{out.Instances[0].InstanceId}},
602-
request.WithWaiterLogger(awslogs.NewWrapLogr(s.scope.GetLogger())),
603-
); err != nil {
604-
s.scope.Debug("Could not determine if Machine is running. Machine state might be unavailable until next renconciliation.")
605-
}
606-
607590
return s.SDKToInstance(out.Instances[0])
608591
}
609592

0 commit comments

Comments
 (0)