Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[JENKINS-31661] Check the root url (Admin monitor + Wizard) #3082
Conversation
reviewbybees
commented
Oct 13, 2017
|
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
|
|
| * Normally this root URL is set during SetupWizard phase, this monitor is there to ensure that behavior. | ||
| * Potential exceptions are the dev environment, if someone disable the wizard or | ||
| * the administrator put an empty string on the configuration page. | ||
| */ |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -1,3 +1,4 @@ | |||
| CompletedInitializationMonitor.DisplayName=Jenkins Initialization Monitor | |||
| SecurityIsOffMonitor.DisplayName=Disabled Security | |||
| URICheckEncodingMonitor.DisplayName=Check URI Encoding | |||
| RootUrlNotSetMonitor.DisplayName=Root URL configured Monitor | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| assertTrue(StringUtils.isNotBlank(JenkinsLocationConfiguration.get().getUrl())); | ||
|
|
||
| RootUrlNotSetMonitor monitor = j.jenkins.getExtensionList(AdministrativeMonitor.class).get(RootUrlNotSetMonitor.class); | ||
| assertFalse("Monitor must be activated", monitor.isActivated()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| JenkinsLocationConfiguration.get().setUrl(null); | ||
|
|
||
| RootUrlNotSetMonitor monitor = j.jenkins.getExtensionList(AdministrativeMonitor.class).get(RootUrlNotSetMonitor.class); | ||
| assertTrue("Monitor must not be activated", monitor.isActivated()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @Test | ||
| @Issue("JENKINS-31661") | ||
| public void testWithRootUrl_configured() { | ||
| assertTrue(StringUtils.isNotBlank(JenkinsLocationConfiguration.get().getUrl())); |
This comment has been minimized.
This comment has been minimized.
oleg-nenashev
Oct 15, 2017
Member
The test relies on the default JTH behavior. Maybe it makes sense to mention it
This comment has been minimized.
This comment has been minimized.
|
|
|
@reviewbybees not do-ne edit: to show it in PR list to review |
|
I just tried with the PR build: Going through the setup wizard leaves Jenkins without a defined root URL. While I think this admin monitor is a good idea, Jenkins should not be showing warnings (other than "newer Jenkins is available") to someone who just went through the setup wizard. For that reason, I strongly disagree with merging this change as is. The setup wizard should be extended to allow defining a Jenkins URL (or could perhaps infer one from the URL used to access Jenkins in the setup wizard, similar to how the form field determines its default value?). Only then would this change make sense. |
|
See previous comment; this does not make sense if the setup wizard leaves the root URL undefined. |
|
@kzantow do you have time to review those modifications ? |
|
@Wadeck After "werk in progress" I rather expected to see a German translation :D |
|
I am a bit aware about the "Proceed as current admin" hyperlink. If I click this button, will the local URL change be applied? P.S: I would be happy to remove this button at all. It causes too many issues with unintended clicks |
|
@oleg-nenashev Yes, I put my "save action" for both the skip and save first user. And as it's a button and not a link, no risk to see anybody doing some ctrl+click or right-click open in a new tab, etc. So normally it should be called all the time. |
Predates major changes.
| @Override | ||
| public boolean isActivated() { | ||
| JenkinsLocationConfiguration loc = JenkinsLocationConfiguration.get(); | ||
| return loc == null || loc.getUrl() == null; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| Jenkins j = Jenkins.getInstance(); | ||
| j.checkPermission(Jenkins.ADMINISTER); | ||
|
|
||
| String rootUrl = req.getParameter("rootUrl"); |
This comment has been minimized.
This comment has been minimized.
jglick
Oct 27, 2017
Member
Just replace the current method parameters with
@QueryParameter String rootUrl
This comment has been minimized.
This comment has been minimized.
| @@ -44,6 +51,29 @@ | |||
| <script> | |||
| $('username').focus(); | |||
| </script> | |||
| </form> | |||
| <form action="${rootURL}/setupWizard/configureRootUrl" class="root-url no-json" method="post"> | |||
This comment has been minimized.
This comment has been minimized.
jglick
Oct 27, 2017
Member
saveRootUrl specifies the URL to post to, so I suspect action and method could just be deleted.
This comment has been minimized.
This comment has been minimized.
| Create\ First\ Admin\ User=Create First Admin User | ||
| Other\ Configuration=Other Configuration | ||
| Jenkins\ URL=Jenkins URL |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @Test | ||
| @Issue("JENKINS-31661") | ||
| public void testWithRootUrl_notConfigured() { | ||
| JenkinsLocationConfiguration.get().setUrl(null); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I do not see any obvious issues in the code |
| <dependency> | ||
| <groupId>commons-validator</groupId> | ||
| <artifactId>commons-validator</artifactId> | ||
| <version>1.6</version> |
This comment has been minimized.
This comment has been minimized.
daniel-beck
Apr 4, 2018
Member
Could we get this without adding a dependency that will be available to dependent plugins? E.g. integrate the relevant class into Jenkins with @Restricted?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| * | ||
| * @since TODO | ||
| */ | ||
| public static HttpResponse errorJSON(@Nonnull String message, @Nonnull Map<?,?> data) { |
This comment has been minimized.
This comment has been minimized.
| * Please DO NOT ADD ITEM TO THIS LIST. <p> | ||
| * If you add an item here, the deserialization process will break | ||
| * because it is used for serialized state like "jenkins.install.InstallState$4" | ||
| * before the change from anonymous class to named class. If you need to add a new InstallState, you can just add a new inner named class but nothing to change in this list. |
This comment has been minimized.
This comment has been minimized.
| <!-- | ||
| The MIT License | ||
| Copyright (c) 2018, CloudBees, Inc. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,101 @@ | |||
|
|
|||
This comment has been minimized.
This comment has been minimized.
|
Manually tested behavior looks good. I'm on-holding this for another week though due to the upcoming core security update. I don't think the risk here is huge, but it's still a substantial change. |
|
LGTM |
|
Looks good to me. Maybe the imported classes could be moved into a different package since |
@dwnusbaum it was based on the same concept as used in hudson/org/apache/tools/tar/TarInputStream.java |
|
@daniel-beck are we good with this one ? |
|
To be merged later this week. |
|
@reviewbybees done |
| $('root-url').focus(); | ||
| (function setInitialRootUrlFieldValue(){ | ||
| var iframeUrl = window.location.href; | ||
| var iframeRelativeUrl = '/setupWizard/setupWizardConfigureInstance'; |
This comment has been minimized.
This comment has been minimized.
|
@jglick a follow-up PR would be much appreciated |
|
Due to Jenkins:2247 for read and JenkinsLocationConfiguration:123 for write it does not seem to have a real impact. Related change: #3474 |
Wadeck commentedOct 13, 2017
•
edited
The problem is that the application has some little issues when there is no rootURL configured. Example: JENKINS-47426.
Normally with the Setup Wizard, this should not be the case. But there are some exceptions like development instance, administrator that disabled the wizard or if the administrator simply clear the root URL in the config.
There was already a PR (#1921) for the issue but as the PR went too far in the correction it was not merged (as I understand). This PR focuses only on the monitor part.
See JENKINS-31661.
Proposed changelog entries
HttpResponsesfor sending an error.Submitter checklist
* Use the
Internal:prefix if the change has no user-visible impact (API, test frameworks, etc.)Desired reviewers
@reviewbybees @oleg-nenashev @amuniz
Screenshot