Skip to content

[policy] Re-add logic to request case-id if not present#4020

Merged
arif-ali merged 1 commit into
sosreport:mainfrom
jcastill:jcastillo-case-id-upload-protocol
May 30, 2025
Merged

[policy] Re-add logic to request case-id if not present#4020
arif-ali merged 1 commit into
sosreport:mainfrom
jcastill:jcastillo-case-id-upload-protocol

Conversation

@jcastill

Copy link
Copy Markdown
Member

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

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

@jcastill jcastill requested a review from pmoravec May 21, 2025 09:24
@packit-as-a-service

Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-4020
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

Comment on lines +305 to +314
# 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
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?)

@pmoravec

Copy link
Copy Markdown
Contributor

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 expect or something similar to interact with non-batched sos report, which can be tricky. So I am not sure..

@TurboTurtle

Copy link
Copy Markdown
Member

Interesting; somewhere between sos-4.8.2 and sos-4.9.0, we stopped asking for the case ID.

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 distro/__init__.py and be removed from upload.

Is it worth having a test for this? That would need expect or something similar to interact with non-batched sos report, which can be tricky. So I am not sure..

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 TurboTurtle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread sos/policies/distros/__init__.py Outdated
Comment on lines +312 to +313
_("Optionally, please enter the case id that you are "
"generating this report for [%s]: ") % caseid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be an f-string.

@jcastill jcastill force-pushed the jcastillo-case-id-upload-protocol branch from 928e759 to ff75a91 Compare May 27, 2025 11:54
Comment thread sos/policies/distros/__init__.py Outdated
@jcastill jcastill force-pushed the jcastillo-case-id-upload-protocol branch from ff75a91 to 6d02c2b Compare May 27, 2025 12:05
@pmoravec pmoravec added Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer Kind/Bug Something is not working, and this fixes the issue labels May 27, 2025
@pmoravec

Copy link
Copy Markdown
Contributor

Hi @TurboTurtle and @arif-ali , could you please review this PR? It fixes a regression we would like to have closed.

@jcastill jcastill requested a review from arif-ali May 29, 2025 07:07
@arif-ali

Copy link
Copy Markdown
Member

I'll have a look today, I've been in and out, and haven't had a chance to look.

@arif-ali arif-ali left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am presuming this was removed on purpose and you don't need this if a case id is not there?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure why this is being removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@arif-ali arif-ali added Reviewed/Ready for Merge Has been reviewed, ready for merge and removed Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer labels May 29, 2025
@TurboTurtle

Copy link
Copy Markdown
Member

Not sure why the sftp fallback is being removed, and would like to hold merge until that is answered. Aside from that, looks ok.

@jcastill jcastill force-pushed the jcastillo-case-id-upload-protocol branch from 6d02c2b to c73ab3c Compare May 30, 2025 08:20
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>
@jcastill jcastill force-pushed the jcastillo-case-id-upload-protocol branch from c73ab3c to b8ec339 Compare May 30, 2025 08:23
@arif-ali arif-ali merged commit 369e65a into sosreport:main May 30, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kind/Bug Something is not working, and this fixes the issue Reviewed/Ready for Merge Has been reviewed, ready for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants