Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.15] OCPBUGS-31036: UPSTREAM: 4670:Update awsmachine providerID and instanceID immediately after ec2:RunInstances is called #501

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
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