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 #38191: Skip reassignment for multiCV in remove #11349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pavanshekar
Copy link
Contributor

What are the changes introduced in this pull request?

Updated the remove wizard to skip the reassignment selection step in remove version for multiCV. The change streamlines the process by automatically bypassing the unnecessary reassignment of cv/lce, ensuring that the user isn’t prompted to choose a replacement that will ultimately be ignored.

Considerations taken when implementing this change?

Ensured that the skipping logic remains intact while improving the user experience by eliminating steps which would be ignored. Special attention was given to maintaining backward compatibility for non-multiCV flows and updating tests to confirm that the wizard behaves as expected.

What are the testing steps for this pull request?

Create a multi-CV activation key

  1. Promote a CV Version to multiple environments
  2. Using Hammer CLI, update the activation key to use mutli CVE
    Example command: hammer activation-key update --organization="Default Organization" --id=1 --content-view-environments="ABC/cv1,XYZ/cv1"
  3. Confirm that the activation key uses multi CVEs

Assign and register multiple hosts using the multi-CV activation key

Remove the version from the environment

  1. Go to the CV associated with the activation key -> Versions
  2. Click on the 3 dots of the respective CV Version and select the option "Remove from environments"
  3. If a content view version is used solely by multi-environment hosts, it will simply be removed from those hosts, and the "Reassign affected hosts" step will be skipped.
  4. If an environment is used solely by multi-environment activation keys, it will be removed from those keys, and the "Reassign activation keys" step will be skipped.

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 for taking a look @pavanshekar! One concern below about the approach.

Comment on lines 30 to 35
dispatch(getHosts({ search: cvQuery }));

let akQuery = `content_view_id=${cvId}`;
const selectedEnvStringsForAK = selectedEnv.map(env => `lifecycle_environment_id=${env.id}`).join(' OR ');
if (selectedEnvStringsForAK.length) akQuery += ` AND (${selectedEnvStringsForAK})`;
dispatch(getActivationKeys({ search: akQuery }));
Copy link
Member

Choose a reason for hiding this comment

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

I feel uneasy about introducing two new API requests here when I don't think it should be necessary. Using scoped search may work okay, but I don't think this additional overhead is worth it.

The backend already knows every content view environment associated with the hosts and AKs, and we probably already have that info somewhere in the API response. Can we find a way to use the existing info 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.

Implemented a solution by adding backend properties to avoid additional API requests while still skipping reassignment when all hosts/AKs are multi-environment.

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.

I see the hosts and activation keys show up in the counts, but they do not appear on the Review step of the wizard. On the Review step, I would still expect the message that says the content view environments will be removed from the hosts/AKs.

@pavanshekar
Copy link
Contributor Author

I've implemented the fix so that the hosts and activation keys counts now appear correctly in the Review step as well.

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.

Looking good, just one more comment

@@ -73,9 +73,21 @@ child :sorted_organization_readable_environments => :environments do
::Host.authorized('view_hosts').in_content_view_environment(:content_view => version.content_view, :lifecycle_environment => env).count
end

node :multi_env_host_count do |env|
hosts = ::Host.authorized('view_hosts')
.in_content_view_environment(content_view: version.content_view, lifecycle_environment: env)
Copy link
Member

Choose a reason for hiding this comment

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

Should use the non-deprecated method.

Suggested change
.in_content_view_environment(content_view: version.content_view, lifecycle_environment: env)
.in_content_view_environments(content_views: [version.content_view], lifecycle_environments: [env])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have pushed the suggested change

@jeremylenz
Copy link
Member

When there's only multi-environment hosts, I still want to have access to the "Show hosts" / "Show activation keys" expansion. Otherwise I can't see what hosts/AKs are affected.

Can we duplicate "Show hosts" / "Show activation keys" on the Review step, maybe?

@pavanshekar
Copy link
Contributor Author

I've added the "Show hosts" / "Show activation keys" sections to the Review step.

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.

2 participants