[policy] Re-add logic to request case-id if not present#4020
Conversation
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
| # set or query for case id | ||
| if not cmdline_opts.batch and not \ | ||
| cmdline_opts.quiet: | ||
| if caseid: | ||
| self.commons['cmdlineopts'].case_id = caseid | ||
| else: | ||
| self.commons['cmdlineopts'].case_id = input( | ||
| _("Optionally, please enter the case id that you are " | ||
| "generating this report for [%s]: ") % caseid | ||
| ) |
There was a problem hiding this comment.
We have the same code in prompt_for_case_id method in https://github.com/sosreport/sos/blob/main/sos/upload/targets/redhat.py#L55-L72 . Shouldnt we have just one routine for that identical code block?
(wont this code block here make the prompt_for_case_id method redundant?)
|
Interesting; somewhere between sos-4.8.2 and sos-4.9.0, we stopped asking for the case ID. Is it worth having a test for this? That would need |
It got dropped in d75cef3#diff-e7b68e1e530790c6fe03b3482d895db01641b530a16acb9945bbb15d22f7023bL362 Because it was removed from the base distro class and moved solely to the upload component. This should live in
That would be a bit involved, though yes it would be best. I don't know off the top of my head if the existing test classes directly support this, but I'd wager not. |
TurboTurtle
left a comment
There was a problem hiding this comment.
As @pmoravec mentioned, this is a duplication of the code from prompt_for_case_id(), which was moved into upload from the base distro/__init__.py.
We shouldn't just copy code into multiple locations. The method needs to be removed from upload, and added back into the base policy class (as a whole method) so that case id is again prompted for across all relevant subcommands, not just upload.
| _("Optionally, please enter the case id that you are " | ||
| "generating this report for [%s]: ") % caseid |
928e759 to
ff75a91
Compare
ff75a91 to
6d02c2b
Compare
|
Hi @TurboTurtle and @arif-ali , could you please review this PR? It fixes a regression we would like to have closed. |
|
I'll have a look today, I've been in and out, and haven't had a chance to look. |
arif-ali
left a comment
There was a problem hiding this comment.
looks ok from me, other than a comment below
| return self.RH_SFTP_HOST | ||
| if not self.commons['cmdlineopts'].case_id and not\ | ||
| self.prompt_for_case_id(): | ||
| return self.RH_SFTP_HOST |
There was a problem hiding this comment.
I am presuming this was removed on purpose and you don't need this if a case id is not there?
There was a problem hiding this comment.
Also not sure why this is being removed.
There was a problem hiding this comment.
Indeed, quite basic use case sos report -o host --batch --upload diverts: it tries to upload to the customer portal while it should use SFTP (no case id).
Instead of 3 lines removal, there must be a change on 2nd line to:
self.commons['policy'].prompt_for_case_id(self.commons['cmdlineopts']):
I had to overview this removal, sorry for ACKing it.
There was a problem hiding this comment.
The reason why I removed it was to run some tests and then I pushed the commit without re-adding it, sorry.
Thank you @arif-ali ++ for spotting this :)
I've just pushed a new commit with the code back
|
Not sure why the sftp fallback is being removed, and would like to hold merge until that is answered. Aside from that, looks ok. |
6d02c2b to
c73ab3c
Compare
This commit re-adds the logic to ask for case-id if the user hasn't specified it in the command line explicitly. Related: RHEL-92071 Signed-off-by: Jose Castillo <jcastillo@redhat.com>
c73ab3c to
b8ec339
Compare
This commit re-adds the logic to ask for case-id if the user hasn't specified it in the command line
explicitly.
Related: RHEL-92071
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines