Account for eventual double slahes in the conversion from legacy to poetry paths #2757 #2771
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2757
@phillxnet, @Hooverdan96: ready for review.
As detailed in #2757, we currently fail to convert legacy paths to poetry paths for our binaries if the legacy path somehow includes double slashes (
/opt/rockstor//bin
instead of/opt/rockstor/bin
).This pull-request simply updates the pattern used to find the legacy paths so that they are properly converted as they should.
Demonstration
/etc/cron.d/rockstortab
to use legacy path with a double slash (this mimics the error reported in Failure to correct poetry paths after update #2757)poetry initrock
to trigger the "conversion logic":The crontab is indeed looking as it should:
and a few minutes later, CRON was detected running the task:
and we can indeed see the snapshot in the webUI:
Unit testing
One new test was added to cover
system.osi.replace_inline_pattern()
, the function responsible to identify and correct these paths. NOTE, however, that the new test requires to manually set thepattern
in the test as it is set ininitrock.establish_poetry_paths()
. This was preferred over a test of the latter directly as it would have required extensive mocking and maybe some refactoring of that function itself. While this is sub-optimal, it still covers howreplace_inline_pattern()
should behave and avoid extensive effort for a function that won't be needed in the mid- to long-term.All tests still pass:
Note
@phillxnet, note that I left the Black formatting as a separate commit as it reformatted a lot of
test_osi.py
... All tests still pass so it seems OK but I wanted to point it to you in case it matters.