This PR fixes an issue that causes octorpki to return the 'File not ready yet' state after previously achieving a stable state.
There are two functions that lead me to believe reverting to the 'File not ready yet' state is not the intended behavior of octorpki. In both ServeROAs and ServeHealth the code checks for s.Stable and s.HasPreviousStable, seemingly to continue serving ROAs if the state was once stable but isn't currently. The only place s.HasPreviousStable is set is immediately after s.Stable is set on octorpki.go#L1254 so whenever s.Stable reverts to false after s.MainReduce() so will s.HasPreviousStable. Both s.Stable and s.HasPreviousStable being false will cause octorpki to revert to a state where no ROAs are served and instead a message is returned: 'File not ready yet'. s.Stable is also set after the validation interval expires but that will result in s.HasPreviousStable only being true for a single additional iteration, after which it may revert to false (based on the result of s.MainReduce()).
The fix adds check to only set s.HasPreviousStable when s.Stable is true.
While I was making this change I also noticed that s.HasPreviousStable isn't set after MaxIterations is reached which similarly would result in the ROA list switching back and forth between available and 'File not ready yet'. I updated that to also set s.HasPreviousStable.
Happy to make any adjustments to this PR as needed. Please let me know if I'm misunderstanding the intended use of s.HasPreviousStable at all. Thanks!
This PR fixes an issue that causes octorpki to return the 'File not ready yet' state after previously achieving a stable state.
There are two functions that lead me to believe reverting to the 'File not ready yet' state is not the intended behavior of octorpki. In both
ServeROAs
andServeHealth
the code checks fors.Stable
ands.HasPreviousStable
, seemingly to continue serving ROAs if the state was once stable but isn't currently. The only places.HasPreviousStable
is set is immediately after s.Stable is set on octorpki.go#L1254 so whenevers.Stable
reverts to false afters.MainReduce()
so wills.HasPreviousStable
. Boths.Stable
ands.HasPreviousStable
being false will cause octorpki to revert to a state where no ROAs are served and instead a message is returned: 'File not ready yet'.s.Stable
is also set after the validation interval expires but that will result ins.HasPreviousStable
only being true for a single additional iteration, after which it may revert to false (based on the result ofs.MainReduce()
).The fix adds check to only set
s.HasPreviousStable
whens.Stable
is true.While I was making this change I also noticed that
s.HasPreviousStable
isn't set afterMaxIterations
is reached which similarly would result in the ROA list switching back and forth between available and 'File not ready yet'. I updated that to also sets.HasPreviousStable
.Happy to make any adjustments to this PR as needed. Please let me know if I'm misunderstanding the intended use of
s.HasPreviousStable
at all. Thanks!