Skip to content

Commit

Permalink
Merge pull request #506 from openshift-cherrypick-robot/cherry-pick-5…
Browse files Browse the repository at this point in the history
…01-to-release-4.14

[release-4.14] OCPBUGS-31332: UPSTREAM: 4670:Update awsmachine providerID and instanceID immediately after ec2:RunInstances is called
  • Loading branch information
openshift-merge-bot[bot] committed Mar 27, 2024
2 parents 5de2946 + 60a9ad1 commit 54a95bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/cloud/services/ec2/instances.go
Expand Up @@ -249,6 +249,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 @@ -260,15 +264,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 54a95bd

Please sign in to comment.