rackerlabs / auter

Automatic updates for RHEL, Debian, and their derivatives, with the ability to run pre/post hooks & reboot afterwards.
Apache License 2.0
65 stars 18 forks source link

Auter Pre & Post Snapshot conflict (with timestamps) #237

Open solo786 opened 4 years ago

solo786 commented 4 years ago

BUG:

Auter is configured to run and apply updates before midnight say at 11:30pm on 20th July 1997 , it creates its .pre snapshot files before midnight passes and auter is then instructed to post midnight reboot (18th July 1997), on reboot the .post snapshot fails and is unable to run since its looking for the same timestamp .pre entries ( from the previous day) to check against which it believes does not exist.becuase a new day has already come into effect.

solo786 commented 4 years ago

closing this off moving it to auter manager.

mark-hyde commented 1 year ago

I think this belongs here rather than auter-manager so I'll re-open it and we'll have a look at the issue when we have the opportunity.

mark-hyde commented 3 weeks ago

I think that this is related to the contrib/configsnap scripts rather than the main auter script.

In the README.md for that contrib it says: """ The tag has been set to auter-configsnap-$(date +%Y-%m-%d)

Note that this will need to be adjusted if updates span over the change of a day ie: apply runs at 23:00 reboot runs at 02:00

""" So the solution to avoid the issue here would be to either schedule the phases at the start of the day rather than the end (avoiding the issue) OR to edit your version of the configsnap scripts to calculate a different tag which is invariant over the period of the maintenance.

(For example, you could generate the tag using a different timezone than the server is running in where both times to be compared are in the same day.)

e.g If server time is in UTC then you could calculate the date to be used in US/Central time.

start time 23:30 
Calculate epoch seconds for that time:
# TZ=UTC date -d '1997-07-20 23:30:00' +%s
869441400
Convert epoch seconds to date in US/Central timezone
# TZ='US/Central' date -d @869441400 +%Y-%m-%d
1997-07-20
(so start day stays the same)

End time 00:30 next day:
Calculate epoch seconds for that time:
# TZ=UTC date -d '1997-07-21 00:30:00' +%s
869445000
Convert epoch seconds to date in US/Central timezone
TZ='US/Central' date -d @869445000 +%Y-%m-%d
1997-07-20

configsnap tag could thus be set to auter-configsnap-$(TZ='US/Central' date +%Y-%m-%d) which would generate the same date string for both 11:30pm and 00:30am on a UTC based server.