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

fix FQDN machine name mapping on proxy configuration #7672

Merged

Conversation

rjpmestre
Copy link
Contributor

@rjpmestre rjpmestre commented Oct 11, 2023

What does this PR change?

It was noticed that configuring a proxy sometimes would fail and just display a generic error.
Analysis can be split in two:

GUI diff

No difference.

  • DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • DONE

Test coverage

  • Unit tests were added

  • DONE

Links

Fixes: #7610

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

@rjpmestre rjpmestre requested a review from a team as a code owner October 11, 2023 10:09
@rjpmestre rjpmestre requested review from lucidd, cbosdo and mbussolotto and removed request for a team and lucidd October 11, 2023 10:09
@github-actions
Copy link
Contributor

Suggested tests to cover this Pull Request
  • minssh_salt_install_package
  • min_deblike_monitoring
  • srv_power_management
  • min_salt_mgrcompat_state
  • srv_sync_channels
  • proxy_cobbler_pxeboot
  • allcli_software_channels_dependencies
  • srv_content_lifecycle
  • minkvm_guests
  • srv_task_status_engine
  • srv_patches_page
  • srv_logfile
  • srv_rename_hostname
  • srv_docker_cve_audit
  • srv_enable_sync_products
  • srv_create_repository
  • srv_cobbler_profile
  • min_empty_system_profiles
  • min_ansible_control_node
  • srv_reportdb
  • min_retracted_patches
  • srv_add_rocky8_repositories
  • srv_organization_credentials
  • allcli_reboot
  • min_bootstrap_ssh_key
  • min_deblike_salt_install_package
  • buildhost_docker_build_image
  • minssh_bootstrap_api
  • srv_advanced_search
  • srv_cobbler_distro
  • srv_scc_user_credentials
  • min_rhlike_ssh
  • allcli_update_activationkeys
  • srv_datepicker
  • min_salt_openscap_audit
  • srv_change_password
  • srv_user_preferences
  • srv_cobbler_sync
  • min_salt_install_with_staging
  • allcli_config_channel
  • min_salt_software_states
  • srv_channels_add
  • min_bootstrap_api
  • min_bootstrap_reactivation
  • min_rhlike_monitoring
  • srv_distro_cobbler
  • min_rhlike_salt_install_package_and_patch
  • buildhost_osimage_build_image
  • srv_group_union_intersection
  • allcli_action_chain
  • min_salt_pkgset_beacon
  • buildhost_bootstrap
  • proxy_branch_network
  • min_cve_id_new_syntax
  • allcli_sanity
  • min_deblike_ssh
  • srv_check_channels_page
  • srv_dist_channel_mapping
  • min_config_state_channel
  • srv_change_task_schedule
  • min_salt_minions_page
  • srv_delete_channel_with_tool
  • srv_notifications
  • min_deblike_remote_command
  • sle_ssh_minion
  • srv_salt
  • min_custom_pkg_download_endpoint
  • allcli_software_channels
  • srv_maintenance_windows
  • sle_minion
  • srv_cobbler_buildiso
  • minssh_move_from_and_to_proxy
  • srv_users
  • srv_push_package
  • min_docker_api
  • srv_check_sync_source_packages
  • allcli_system_group
  • srv_handle_config_channels_with_ISS_v2
  • srv_delete_channel_from_ui
  • srv_restart
  • srv_power_management_redfish
  • srv_user_configuration_salt_states
  • min_bootstrap_negative
  • min_activationkey
  • srv_clone_channel_npn
  • min_rhlike_salt
  • min_salt_formulas_advanced
  • srv_handle_software_channels_with_ISS_v2
  • srv_manage_channels_page
  • srv_mainpage
  • min_salt_migration
  • min_recurring_action
  • proxy_as_pod_basic_tests
  • min_salt_minion_details
  • min_salt_lock_packages
  • min_deblike_openscap_audit
  • srv_check_reposync
  • min_check_patches_install
  • min_virthost
  • srv_power_management_api
  • min_move_from_and_to_proxy
  • min_project_lotus
  • min_config_state_channel_subscriptions
  • srv_payg_ssh_connection
  • min_timezone
  • min_salt_user_states
  • srv_activationkey_api
  • min_deblike_salt
  • srv_monitoring
  • min_deblike_salt_install_with_staging
  • min_cve_audit
  • min_rhlike_remote_command
  • srv_channel_api
  • proxy_retail_pxeboot_and_mass_import
  • min_bootstrap_script
  • min_rhlike_openscap_audit
  • srv_docker_advanced_content_management
  • srv_salt_download_endpoint
  • proxy_register_as_minion_with_script
  • min_salt_install_package
  • srv_menu
  • min_monitoring
  • min_change_software_channel
  • min_action_chain
  • srv_osimage
  • srv_first_settings
  • minssh_action_chain
  • srv_create_activationkey
  • min_salt_formulas
  • allcli_overview_systems_details
  • srv_disable_local_repos_off
  • min_ssh_tunnel

Copy link
Contributor

@cbosdo cbosdo left a comment

Choose a reason for hiding this comment

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

I like how you document what was the issue in the PR description. Since it's fairly hard to find the PR from a given commit, would you mind adding it to the commit description too? In such cases if there is only one commit GH adds the description to the PR when you create it.

Comment on lines 1 to 2
- fix FQDN machine name mapping on proxy configuration
- fix proxy configuration error display
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for users to read: you don't have to be too specific. Think about you would like to see here as a user that indicates your bug is fixed. And I wouldn't have 2 entries here: one is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got you! To see it as end user is a good hint.

else {
return String.join(".");
}
String[] hostnameParts = this.getCn().replace("*", "_star_").split("\\.");
Copy link
Contributor

Choose a reason for hiding this comment

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

What I don't understand here is why this is needed... Was the bug only if there is a * in the proxy FDQN? or is that character added somehow? The proxy FQDN should not contain such a character: it's a single name.

Copy link
Contributor Author

@rjpmestre rjpmestre Oct 13, 2023

Choose a reason for hiding this comment

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

I am not sure why you'd use asterisk, ie, specifying/restricting domain in this context.
I wasn't expecting this to be a valid input, but it doesn't even fail any validation. For me, this could even have been a slip.
But the fact they were specifically handled by python's machine name mapping is what made me think asterisks are expected.

As far as i see we have 2 options:

  • keep the solution, focusing on the original failure when accessing the uploaded files
  • add a validation to the fqdn inputs 'Proxy FQDN' and 'Parent FQDN' when they contain

what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding validation of the FQDNs couldn't be a bad thing, but I had the issue here even without any invalid one... so I think the truth is somewhere else

@cbosdo
Copy link
Contributor

cbosdo commented Oct 14, 2023

After some quick debugging here, I found that we miss a LOG.error("Failed to generate proxy configuration", e) in

return json(response, HttpStatus.SC_BAD_REQUEST, e.getMessage());

@cbosdo
Copy link
Contributor

cbosdo commented Oct 14, 2023

After trying again I figured out I was mistyping my CA password. Once set right I got the config generated correctly. Could you please add the missing log and add the verification of the FQDNs on the Java side? I can show you later how to add them on the TSX side if you are interested in that 😜

@rjpmestre rjpmestre force-pushed the fix_proxy_config_fqdn_mapping branch from d2ffa4a to 0ba0550 Compare October 17, 2023 10:21
@rjpmestre rjpmestre requested a review from a team as a code owner October 17, 2023 10:21
@rjpmestre rjpmestre requested review from parlt91 and removed request for a team October 17, 2023 10:21
@rjpmestre rjpmestre force-pushed the fix_proxy_config_fqdn_mapping branch 2 times, most recently from 4cfeef7 to a09df8b Compare October 17, 2023 10:31
@rjpmestre rjpmestre requested a review from cbosdo October 17, 2023 11:16
@rjpmestre rjpmestre force-pushed the fix_proxy_config_fqdn_mapping branch from a09df8b to a4071bf Compare October 20, 2023 10:01
It was noticed that configuring a proxy sometimes would fail and just display a generic error.
Analysis can be split in two:
- what was causing the problem
Files uploaded during configuration are stored and moved based on a 'machine name' mapping based on the provided 'Proxy FQDN'.
https://github.com/uyuni-project/uyuni/blob/32465f6efccd319926ae1897e14d9d20d4d89c39/spacewalk/certs-tools/sslToolLib.py#L73
Current solution based on a slightly more generic occurrence:
 https://github.com/uyuni-project/uyuni/blob/f1f62028c363f8ea95b0cc080b4fa9eddf9fbaa0/spacewalk/certs-tools/rhn_ssl_tool.py#L205
- why was just a generic error
This had to do with our (rhn) custom FileUtils throwing generic RTEs while RhnRuntimeException is expected
https://github.com/uyuni-project/uyuni/blob/32465f6efccd319926ae1897e14d9d20d4d89c39/java/code/src/com/redhat/rhn/common/util/FileUtils.java#L130
@rjpmestre rjpmestre force-pushed the fix_proxy_config_fqdn_mapping branch from a4071bf to 966629a Compare October 20, 2023 11:11
@rjpmestre rjpmestre merged commit f7aff89 into uyuni-project:master Oct 20, 2023
15 of 18 checks passed
@rjpmestre rjpmestre deleted the fix_proxy_config_fqdn_mapping branch December 18, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a containerized proxy config on containerized proxy fails
2 participants