From 59dc47e82d03445e4dd8e462beeed1c7547f453b Mon Sep 17 00:00:00 2001 From: Shailesh Gothi Date: Thu, 13 May 2021 16:46:20 -0700 Subject: [PATCH] Fixed update verification Previously version before update was not stored, so it was hard to verify if update happened or not. This change stores the version and compares it with updated version to report approiate logs. --- updater/aws.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/updater/aws.go b/updater/aws.go index a509fd2..4ba21a0 100644 --- a/updater/aws.go +++ b/updater/aws.go @@ -19,6 +19,7 @@ const ( type instance struct { instanceID string containerInstanceID string + bottlerocketVersion string } type checkOutput struct { @@ -112,6 +113,7 @@ func (u *updater) filterAvailableUpdates(bottlerocketInstances []instance) ([]in continue } if output.UpdateState == "Available" { + inst.bottlerocketVersion = output.ActivePartition.Image.Version candidates = append(candidates, inst) } } @@ -265,14 +267,15 @@ func (u *updater) verifyUpdate(inst instance) error { if err != nil { return fmt.Errorf("failed to parse check command output %s, manual verification required: %w", string(updateResult), err) } - if output.UpdateState == "Available" { - return fmt.Errorf(" instance did not update, manual update advised") - } - log.Printf("Instance %#q updated successfully", inst) - if output.ActivePartition.Image.Version != "" { - log.Printf("Instance %#q running Bottlerocket: %s", inst, output.ActivePartition.Image.Version) + updatedVersion := output.ActivePartition.Image.Version + if updatedVersion == inst.bottlerocketVersion { + log.Printf("Container instance %q did not update, its current "+ + "version %s and updated version %s are same", inst.containerInstanceID, inst.bottlerocketVersion, updatedVersion) + } else if output.UpdateState == "Available" { + log.Printf("Update for container instance %q was successful, however another newer version %s was released recently."+ + " Instance will be updated to newer version in next iteration.", inst.containerInstanceID, updatedVersion) } else { - log.Printf("Unable to verify active version. Manual verification of %#q required.", inst) + log.Printf("Instance %#q successfully updated to version %s", inst, updatedVersion) } return nil }