watchtower icon indicating copy to clipboard operation
watchtower copied to clipboard

refactor(update): clean up actions/update

Open piksel opened this issue 1 year ago • 4 comments

This PR tries to refactor the update code flow to make it easier to understand, maintain and extend.

actions/update:

  • move common arguments to a shared struct (updateSession)
  • remove unused fields
  • fix outdated names
  • improve logging/error handling

lifecycle:

  • removes unwieldy SkipUpdate return value in favor of errors.Is
  • generalizes the code for all four phases
  • allows timeout to be defined for all phases
  • enables explicit unit in timeout label values (in addition to implicit minutes)

container:

  • rename Stale to MarkedForUpdate renames the container.Stale field to what it's actually used for, as staleness is not the only factor used to decide whether a container should be updated anymore

piksel avatar Jan 06 '24 13:01 piksel

Codecov Report

Attention: 67 lines in your changes are missing coverage. Please review.

Comparison is base (76f9cea) 70.55% compared to head (a42eb28) 69.97%.

Files Patch % Lines
internal/actions/update.go 64.04% 18 Missing and 14 partials :warning:
pkg/container/metadata.go 48.27% 13 Missing and 2 partials :warning:
pkg/container/client.go 42.85% 8 Missing :warning:
pkg/container/container.go 0.00% 7 Missing :warning:
internal/util/time.go 0.00% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1895      +/-   ##
==========================================
- Coverage   70.55%   69.97%   -0.59%     
==========================================
  Files          26       27       +1     
  Lines        2493     2498       +5     
==========================================
- Hits         1759     1748      -11     
- Misses        633      648      +15     
- Partials      101      102       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 06 '24 13:01 codecov[bot]

Hi @piksel . Just curious if there was any movement on this PR? Would love to update my other PR for deferred updates to match this code and get that resolved too whenever you're ready. LMK if there's anything else I can do to help here!

pjdubya avatar Jan 24 '24 19:01 pjdubya

It would be nice to finish this work

minscof avatar Feb 20 '24 13:02 minscof

@piksel would also be interested in this too for defer functionality

MattBlackOnly avatar Jun 19 '24 18:06 MattBlackOnly