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-39232] Walk the DelegatingComputerLauncher instances when checking if JNLPComputerLauncher #2602

Merged
merged 5 commits into from
Oct 29, 2016

Conversation

stephenc
Copy link
Member

See JENKINS-39232

@jenkinsci/code-reviewers @reviewbybees

Replaces #2601

@ghost
Copy link

ghost commented Oct 26, 2016

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.

@oleg-nenashev
Copy link
Member

I do not believe it's a perfect fix since anybody can implement his own launcher using ComputerLauncher API. And there are many examples: https://github.com/search?q=org%3Ajenkinsci+%22extends+computerlauncher%22&type=Code

I agree it worths adding support of Delegating launchers, but it does not fix the issue

@daniel-beck daniel-beck added the needs-more-reviews Complex change, which would benefit from more eyes label Oct 26, 2016
* {@link ComputerLauncher} when then should have extended {@link DelegatingComputerLauncher}
*
* @since FIXME
*/
Copy link
Member

Choose a reason for hiding this comment

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

@Extension(NoExternalUse.class)

Copy link
Member

Choose a reason for hiding this comment

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

fixed

@Override
public boolean owns(String clientName) {
Computer computer = Jenkins.getInstance().getComputer(clientName);
return computer != null;
}

private static ComputerLauncher getDelegate(ComputerLauncher launcher) {
Copy link
Member

Choose a reason for hiding this comment

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

CheckForNull

Copy link
Member

Choose a reason for hiding this comment

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

comment wasn't addressed?

Method getDelegate = launcher.getClass().getMethod("getDelegate");
return ComputerLauncher.class.isAssignableFrom(getDelegate.getReturnType()) ? (ComputerLauncher) getDelegate
.invoke(launcher) : null;
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
Copy link
Member

Choose a reason for hiding this comment

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

ReflectiveOperationException?

launcher = ((DelegatingComputerLauncher) launcher).getLauncher();
} else if (launcher instanceof ComputerLauncherFilter) {
launcher = ((ComputerLauncherFilter) launcher).getCore();
} else if (null != (l = getDelegate(launcher))) { // TODO remove when all plugins are fixed
Copy link
Member

Choose a reason for hiding this comment

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

Does not guarantee a success for old plugins from what I see

} else {
if (disableStrictVerification) {
LOGGER.log(Level.WARNING, "Connecting {0} as a JNLP agent where the launcher does not mark itself "
+ "correctly as being a JNLP agent", clientName);
Copy link
Member

Choose a reason for hiding this comment

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

Please explicitly provide a class of the launcher

+ "correctly as being a JNLP agent", clientName);
break;
} else {
event.reject(new ConnectionRefusalException(String.format("%s is not a JNLP agent", clientName)));
Copy link
Member

Choose a reason for hiding this comment

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

🐛 In the case of enforcement must contain more details. E.g. link to the Wiki page providing a workaround info. Or just in-text help

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

If we want to go in such way, we need better diagnostic messages. 🐛 for it.

I still have concerns about such approach due to impact on plugins, but it's a subject for voting by @jenkinsci/core

- Since the failure of strict verification is an issue, we should log it as a warning always
@oleg-nenashev
Copy link
Member

I approve the code change itself since it makes the situation better that it is in 2.27. So 🐝 and 👍 as a partial fix.

But I still do not feel it's a right approach to nuke so many instances. Hence as a community member I keep 👎 regarding the change as a complete fix of JENKINS-39232

@oleg-nenashev
Copy link
Member

@reviewbybees done
@jenkinsci/code-reviewers We really really really want to get it in the next weekly

@oleg-nenashev
Copy link
Member

P.S: I will follow-up on the default behavior

@oleg-nenashev oleg-nenashev added ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback and removed needs-more-reviews Complex change, which would benefit from more eyes labels Oct 28, 2016
@oleg-nenashev
Copy link
Member

I will merge it into the next weekly if nobody shouts

return (ComputerLauncher) getDelegate.invoke(launcher);
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
// ignore
Copy link
Member

Choose a reason for hiding this comment

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

you can name ignore instead e to disable warnings static analysing tools.

launcher = ((DelegatingComputerLauncher) launcher).getLauncher();
} else if (launcher instanceof ComputerLauncherFilter) {
launcher = ((ComputerLauncherFilter) launcher).getCore();
} else if (null != (l = getDelegate(launcher))) { // TODO remove when all plugins are fixed
Copy link
Member

Choose a reason for hiding this comment

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

TODO jenkins 3.x and don't break existing plugins.

Copy link
Member Author

Choose a reason for hiding this comment

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

While technically, it doesn't qualify as an S, there are issues of that nature removed by enforcing that only agents explicitly configured to use a JNLP launcher get to use a JNLP launcher... especially as only a JNLP launcher will have a cookie and hence any existing connection will be dropped in favour of an incoming JNLP connection with a valid secret (it's the valid that stops it being an S... because if you've let somebody else get the master key driving the JNLP secrets... well that's your problem right there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants