Skip to content

Commit

Permalink
Merge pull request #4670 from mjlshen/4629-status
Browse files Browse the repository at this point in the history
🐛 Update awsmachine providerID and instanceID immediately after ec2:RunInstances is called
  • Loading branch information
k8s-ci-robot authored Dec 11, 2023
2 parents 50f605d + 0c62661 commit 5780796
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use
return nil, err
}

// Set the providerID and instanceID as soon as we create an instance so that we keep it in case of errors afterward
scope.SetProviderID(out.ID, out.AvailabilityZone)
scope.SetInstanceID(out.ID)

if len(input.NetworkInterfaces) > 0 {
for _, id := range input.NetworkInterfaces {
s.scope.Debug("Attaching security groups to provided network interface", "groups", input.SecurityGroupIDs, "interface", id)
Expand All @@ -261,15 +265,15 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use

s.scope.Debug("Adding tags on each network interface from resource", "resource-id", out.ID)

// Fetching the network interfaces attached to the specific instanace
// Fetching the network interfaces attached to the specific instance
networkInterfaces, err := s.getInstanceENIs(out.ID)
if err != nil {
return nil, err
}

s.scope.Debug("Fetched the network interfaces")

// Once all the network interfaces attached to the specific instanace are found, the similar tags of instance are created for network interfaces too
// Once all the network interfaces attached to the specific instance are found, the similar tags of instance are created for network interfaces too
if len(networkInterfaces) > 0 {
s.scope.Debug("Attempting to create tags from resource", "resource-id", out.ID)
for _, networkInterface := range networkInterfaces {
Expand Down

0 comments on commit 5780796

Please sign in to comment.