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

[JENKINS-71737] fix redirect when submitting cloud changes #8505

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

car-roll
Copy link
Contributor

@car-roll car-roll commented Sep 19, 2023

See JENKINS-71737.

#8310 first started as simple redirect fixes, but they never worked for downstream plugins (particularly ec2 and azure-vm-agents). The solution then evolved to make a separate rename page that was consistent with the rename logic of AbstractItem introduced in #3289 .

Eventually it was discovered that the use of cloudName instead of name in the downstream plugins, along with a hardcoded workaround in core was what made my initial attempts at redirect fail.

This PR is an alternative to the more complicated #8310
Fixes the redirect so that save goes to the new cloud name page and it removes the apply button from cloud configuration

Testing done

Tested manually in ec2 and azure-vm-agents
TODO: Create PRs with incremental generated by this PR

Proposed changelog entries

  • Fix redirect when renaming a cloud

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

@timja timja added bug For changelog: Minor bug. Will be listed after features alternative This PR is one of several options to address a given issue regression-fix Pull request that fixes a regression in one of the previous Jenkins releases and removed bug For changelog: Minor bug. Will be listed after features labels Sep 19, 2023
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

doesn't work if someone clicks apply and then makes another change.

(the main reason for the rename page I thought was to avoid the apply button being present)

@car-roll
Copy link
Contributor Author

@timja you are right, in my excitement I forgot about that part 🤦

@timja
Copy link
Member

timja commented Sep 24, 2023

@timja you are right, in my excitement I forgot about that part 🤦

Basil suggested on the other PR you could just remove the apply button and that may be the simplest fix and then going with this

@@ -331,7 +331,8 @@ public HttpResponse doConfigSubmit(StaplerRequest req, StaplerResponse rsp) thro
j.clouds.replace(this, result);
j.save();
// take the user back to the cloud top page.
return FormApply.success(".");
return FormApply.success("../" + result.name + '/');
Copy link
Contributor

@scherler scherler Oct 20, 2023

Choose a reason for hiding this comment

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

for what it's worth, I think return FormApply.success("../.."); is the quick fix for the issue. Due to the underlying url manage/cloud/xyz/configure. You will always be in .../configure so you are forced to get back to the overall cloud listing page. If you want some elegance you test whether the name has not changed, then use the old way. However, since index.jelly is e.g. in kubernetes plugin a blank page and doing "." leads to it I would rather be redirected to the overall cloud page, but that is me as a user.

Copy link
Contributor Author

@car-roll car-roll Oct 20, 2023

Choose a reason for hiding this comment

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

@scherler .. was the original fix, but I think the main issue with that was that a quick fix was not desired, but rather a proper way to address the UX behavior
See #8310 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

a bug is a bug and should be fixed. Any follow-up should be addressed after that. That is just my 2 cents being a fan of iterations. The follow-up cost for any downstream plugin/code is to fix it themselves while we boil the ocean, which does not make sense at all. I know there will be a lot of "the follow-up never will come" excuses to not fix a BUG but that is a completely different discussion IMHO if the fix is ../.. and the behavior before the breaking change is back, there should not be a discussion. Really questionable why the fix has not landed 24 h after the PR had been filed. 🤷‍♂️

@scherler
Copy link
Contributor

https://github.com/scherler/jenkins/tree/JENKINS-71737 is the test that should pass

@Vlatombe
Copy link
Member

Basil suggested on the other PR you could just remove the apply button and that may be the simplest fix and then going with this

Can we go with this and forget about this bug?

@timja
Copy link
Member

timja commented Nov 15, 2023

Basil suggested on the other PR you could just remove the apply button and that may be the simplest fix and then going with this

Can we go with this and forget about this bug?

Why not just remove the apply button?

@Vlatombe
Copy link
Member

Yes, this is what I meant.

@timja
Copy link
Member

timja commented Nov 15, 2023

Yes, this is what I meant.

go for it

@@ -231,7 +231,6 @@ private void handleNewCloudPage(Descriptor<Cloud> descriptor, String name, Stapl
checkName(name);
JSONObject formData = req.getSubmittedForm();
formData.put("name", name);
formData.put("cloudName", name); // ec2 uses that field name
Copy link
Contributor Author

@car-roll car-roll Nov 17, 2023

Choose a reason for hiding this comment

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

ec2 no longer uses that filed name
jenkinsci/ec2-plugin#892
also azure-vm-agents
jenkinsci/azure-vm-agents-plugin#462

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

LGTM

@timja timja requested review from scherler and a team November 28, 2023 09:02
@timja
Copy link
Member

timja commented Nov 28, 2023

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Nov 28, 2023
@car-roll car-roll changed the title [JENKINS-71737] Simpler fix of redirect when submitting cloud changes [JENKINS-71737] fix redirect when submitting cloud changes Nov 28, 2023
@timja timja merged commit ec27a07 into jenkinsci:master Nov 29, 2023
17 checks passed
krisstern pushed a commit to krisstern/jenkins that referenced this pull request Jan 8, 2024
…#8505)

Co-authored-by: Alexander Brandes <mc.cache@web.de>
(cherry picked from commit ec27a07)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alternative This PR is one of several options to address a given issue ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback regression-fix Pull request that fixes a regression in one of the previous Jenkins releases
Projects
None yet
5 participants