Skip to content

Commit

Permalink
Fixed update verification
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
srgothi92 committed May 17, 2021
1 parent f033cb6 commit 59dc47e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions updater/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
type instance struct {
instanceID string
containerInstanceID string
bottlerocketVersion string
}

type checkOutput struct {
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 59dc47e

Please sign in to comment.