From e13de2de474d6353d263b545e8c248a753efd7b6 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/updater/aws.go b/updater/aws.go index ad31b9d..88b1a37 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 { @@ -110,6 +111,7 @@ func (u *updater) filterAvailableUpdates(bottlerocketInstances []instance) ([]in log.Printf("failed to parse check command output %s: %v", string(commandOutput), err) } if output.UpdateState == "Available" { + inst.bottlerocketVersion = output.ActivePartition.Image.Version candidates = append(candidates, inst) } } @@ -261,16 +263,17 @@ func (u *updater) verifyUpdate(inst instance) error { } output, err := parseCommandOutput(updateResult) if err != nil { - return fmt.Errorf("failed to parse check command output %s, manual verification required: %v", string(updateResult), err) + return fmt.Errorf("failed to parse check command output '%s', manual verification required: %v", 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 %s 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 %s 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 }