Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35713 - Host details tab for Debian packages #10744

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

nadjaheitmann
Copy link
Contributor

@nadjaheitmann nadjaheitmann commented Sep 19, 2023

What are the changes introduced in this pull request?

Host details tab for Debian packages

What are the testing steps for this pull request?

Try viewing, installing, removing and updating deb packages for hosts.

For code review: There are actually a lot of code pieces that were taken from the PackagesTab. Any re-structuring of the code needed?

What is missing:

  • Tests

@theforeman-bot
Copy link

Issues: #35713

@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch from 284b57f to 4d861db Compare September 21, 2023 11:53
@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch 2 times, most recently from 4a8c724 to d97b173 Compare September 21, 2023 12:15
@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch 2 times, most recently from a3e56c3 to 51969bb Compare October 26, 2023 12:06
@nadjaheitmann
Copy link
Contributor Author

Hey @lfu , I saw that you created most of the host details packages tab and I am trying to reuse your code for Debian packages, but I got stuck at the tests. Do you have any idea what needs adjustment? Any hints are highly appreciated!

@nadjaheitmann
Copy link
Contributor Author

Hey @lfu , I saw that you created most of the host details packages tab and I am trying to reuse your code for Debian packages, but I got stuck at the tests. Do you have any idea what needs adjustment? Any hints are highly appreciated!

Or maybe @jturel ? Not sure, who would be the right person to ping.

@lfu
Copy link
Member

lfu commented Oct 27, 2023

cc @jeremylenz

@jeremylenz
Copy link
Member

Error: Error: Nock: No match for request {

means the test is making an API request that wasn't planned for with a Nock instance. Each API request in a test must have a corresponding scope that matches the request, and then an assertNockRequest at the end of the test. You can run the tests with

DEBUG=nock.* npx jest <filename>

to see how Nock is doing its matching. Probably some adjustment of the nock .query is needed.

@nadjaheitmann
Copy link
Contributor Author

Thanks @jeremylenz That debug output helped me a lot!

@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch from 51969bb to a9d347d Compare October 31, 2023 11:41
Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Haven't tested this yet but here's a couple things I noticed :)

app/controllers/katello/api/v2/debs_controller.rb Outdated Show resolved Hide resolved
import { urlBuilder } from 'foremanReact/common/urlHelpers';
import SelectableDropdown from '../../../../SelectableDropdown';
import TableWrapper from '../../../../../components/Table/TableWrapper';
import { useBulkSelect, useTableSort, useUrlParams, useSet } from '../../../../../components/Table/TableHooks';
Copy link
Member

Choose a reason for hiding this comment

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

After #10783 is merged you'll have to import these from foremanReact, just fyi

Copy link
Contributor Author

@nadjaheitmann nadjaheitmann Nov 10, 2023

Choose a reason for hiding this comment

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

Thanks, applied! (at least where it was giving me an error)

@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch 6 times, most recently from df17355 to bdb5865 Compare November 10, 2023 12:49
@nadjaheitmann
Copy link
Contributor Author

@jeremylenz Got the react tests running! Might need some Ruby tests, though. I copied a lot of code from the packages tab. Shall I mention the developer - mostly @lfu I think - in the commit message? I think this should be credited. Another option is to have a common packages tab component for rpm packages and for deb packages and re-use it for the specific tabs. Would be the cleaner implementation, I guess, but would require quite some afford to change the code.

@lfu
Copy link
Member

lfu commented Nov 10, 2023

... Shall I mention the developer - mostly @lfu I think - in the commit message? I think this should be credited...

Not necessary at all :)

@jeremylenz
Copy link
Member

Another option is to have a common packages tab component for rpm packages and for deb packages and re-use it for the specific tabs. Would be the cleaner implementation, I guess, but would require quite some afford to change the code.

In our downstream product we rip out or disable most of the Debian-related stuff anyway, so this implementation with separate Deb components and files actually seems cleaner to me with that in mind. 👍

@nadjaheitmann
Copy link
Contributor Author

In our downstream product we rip out or disable most of the Debian-related stuff anyway, so this implementation with separate Deb components and files actually seems cleaner to me with that in mind. 👍

Okay, then let's leave the structure as is then. Theoretically, the PR should not affect rpm repos if it works correctly. It just adds a package tab to Debian repositories.

@nadjaheitmann nadjaheitmann changed the title WIP: Fixes #35713 - Host details tab for Debian packages Fixes #35713 - Host details tab for Debian packages Nov 14, 2023
@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch 2 times, most recently from 6fa8d38 to c818918 Compare November 16, 2023 10:38
@nadjaheitmann nadjaheitmann force-pushed the add_host_details_debs_tab branch from c818918 to f9ba1a9 Compare November 17, 2023 09:54
@nadjaheitmann
Copy link
Contributor Author

@jeremylenz This is ready for review :)

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Thanks @nadjaheitmann !

Spun up a Debian 11 host and everything seems to work ok. Some minor comments below.

app/models/katello/concerns/host_managed_extensions.rb Outdated Show resolved Hide resolved
app/models/katello/deb.rb Outdated Show resolved Hide resolved
@@ -560,6 +560,24 @@ def package_names_for_job_template(action:, search:, versions: nil)
end
end

def deb_names_for_job_template(action:, search:)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could avoid adding a new method here, and just check self.operatingsystem.family within package_names_for_job_template instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeremylenz I think, it is a good idea and I have a added a commit on top of the actual commit for the host details page. However, rubocop does not like the changes. Not sure if I can make this any simpler.

[2024-01-05T09:07:35.947Z] Offenses:

[2024-01-05T09:07:35.947Z] /home/jenkins/workspace/katello-pr-test/app/models/katello/concerns/host_managed_extensions.rb:541:7: C: Metrics/AbcSize: Assignment Branch Condition size for package_names_for_job_template is too high. [<9, 56, 21> 60.48/60]

[2024-01-05T09:07:35.947Z] def package_names_for_job_template(action:, search:, versions: nil) ...

[2024-01-05T09:07:35.947Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[2024-01-05T09:07:35.947Z] /home/jenkins/workspace/katello-pr-test/app/models/katello/concerns/host_managed_extensions.rb:541:7: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for package_names_for_job_template is too high. [16/14]

[2024-01-05T09:07:35.947Z] def package_names_for_job_template(action:, search:, versions: nil) ...

[2024-01-05T09:07:35.947Z] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[2024-01-05T09:07:35.947Z] /home/jenkins/workspace/katello-pr-test/app/models/katello/concerns/host_managed_extensions.rb:541:7: C: Metrics/MethodLength: Method has too many lines. [34/30]

[2024-01-05T09:07:35.947Z] def package_names_for_job_template(action:, search:, versions: nil) ...

Copy link
Member

Choose a reason for hiding this comment

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

@nadjaheitmann Two options here. I would be fine with either one:

  1. Extract your if / else block to its own method. I would probably also do it as a case statement (case operatingsystem.family)
  2. Or, just disable that cop and enable it at the end of the method. We do that in several places.

Copy link
Contributor Author

@nadjaheitmann nadjaheitmann Jan 9, 2024

Choose a reason for hiding this comment

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

I tried option one, although I did not want to use a case statement. Seems safer to me to have Debian and everything else :)

@jeremylenz
Copy link
Member

@nadjaheitmann Please squash and/or rename your commit to add 'Refs #35713', then we can merge.

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Thanks @nadjaheitmann!

ACK 👍

@jeremylenz jeremylenz merged commit e48bd5b into Katello:master Jan 10, 2024
6 checks passed
@maximiliankolb maximiliankolb deleted the add_host_details_debs_tab branch January 10, 2024 16:15
sbernhard pushed a commit to ATIX-AG/katello that referenced this pull request Feb 29, 2024
sbernhard pushed a commit to ATIX-AG/katello that referenced this pull request Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants