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-61161] Avoid infamous UI connection strategy warning #538

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

MRamonLeon
Copy link
Contributor

See https://issues.jenkins.io/browse/JENKINS-61161

Avoid the ugly and erroneous Could not find selected connection strategy every time one changes the connection strategy.

See:
Screenshot from 2020-11-24 14-16-51

@@ -2040,7 +2040,7 @@ public ListBoxModel doFillConnectionStrategyItems(@QueryParameter String connect

public FormValidation doCheckConnectionStrategy(@QueryParameter String connectionStrategy) {
return Stream.of(ConnectionStrategy.values())
.filter(v -> v.equalsName(connectionStrategy))
.filter(v -> v.name().equals(connectionStrategy))
Copy link
Contributor Author

@MRamonLeon MRamonLeon Nov 24, 2020

Choose a reason for hiding this comment

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

  • Previously: Public_IP == PUBLIC_IP ??
  • Now: PUBLIC_IP == PUBLIC_IP ??

See:

Copy link
Member

Choose a reason for hiding this comment

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

is it not the same? why is it fixing the error?

public boolean equalsName(String other) {
return this.name.equals(other);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I too am interested in Francisco's point

Copy link
Contributor Author

@MRamonLeon MRamonLeon Nov 25, 2020

Choose a reason for hiding this comment

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

equalsName is comparing the text added in the constructor (Public IP lowercase) as you can see above, but the connectionStrategy variable contains the declared name of the enum (PUBLIC IP uppercase), so they were never equals. With name() we use the declared name.

Copy link
Member

Choose a reason for hiding this comment

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

Oh! I see now! Really good point Ramon

Copy link
Contributor

@res0nance res0nance Nov 25, 2020

Choose a reason for hiding this comment

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

Interesting, then shouldn't equals() also produce the desired behaviour?
Edit: Forgot the the other object is simply a string, LGTM. thanks for the explaination

@@ -2040,7 +2040,7 @@ public ListBoxModel doFillConnectionStrategyItems(@QueryParameter String connect

public FormValidation doCheckConnectionStrategy(@QueryParameter String connectionStrategy) {
return Stream.of(ConnectionStrategy.values())
.filter(v -> v.equalsName(connectionStrategy))
.filter(v -> v.name().equals(connectionStrategy))
Copy link
Member

Choose a reason for hiding this comment

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

Oh! I see now! Really good point Ramon

@MRamonLeon MRamonLeon merged commit 1bd695f into jenkinsci:master Nov 25, 2020
@MRamonLeon MRamonLeon deleted the JENKINS-61161 branch November 25, 2020 09:08
@amedee
Copy link
Contributor

amedee commented Apr 13, 2021

Regression? I have this error again in EC2 plugin version 1.56

@jensenbox
Copy link

I can corroborate - this is still an issue. We use CasC and it will not work under any condition. The knock on effect is that after a configuration update and restart of Jenkins, no EC2 instance can be created. Perhaps the logic of this validation function is flawed? Frankly I do not mind seeing the actual enum value show up in as the form value PUBLIC_IP - it gives a clear understanding of the underlying value. So perhaps just yank the name property - it would sure make translations that much better too (do not compare the human value to the internal value) - just spitballing here as this is a real pain.

@radnov
Copy link

radnov commented Jun 2, 2021

This is still an issue in 1.59 🤕

@amedee, @jensenbox Have you guys found any intermediate solution to this?

Doing "Apply" on the Clouds configuration from the UI "fixes" the Connection Strategy problem. Having to POST $JENKINS_URL/configureClouds/configure on each JCasC reload is just nasty.

@res0nance
Copy link
Contributor

This is still an issue in 1.59 🤕

@amedee, @jensenbox Have you guys found any intermediate solution to this?

Doing "Apply" on the Clouds configuration from the UI "fixes" the Connection Strategy problem. Having to POST $JENKINS_URL/configureClouds/configure on each JCasC reload is just nasty.

I can recreate the issue when adding a new template which is fixed in #626

@radnov
Copy link

radnov commented Jun 2, 2021

@jensenbox See this comment in case you're still facing the JCasC issue. 👍

@amedee
Copy link
Contributor

amedee commented Jun 2, 2021 via email

@albertodebortoli
Copy link

This is more broken now with 1.60 than before. I literally tried every possible combination of fields but the connection strategy always falls back to "Public DNS".

@res0nance
Copy link
Contributor

This is more broken now with 1.60 than before. I literally tried every possible combination of fields but the connection strategy always falls back to "Public DNS".

Fixed in #627 has to do with a weird issue where the name of the variable was causing issues. I tested it locally and it seems to be fine now even when saving and loading. Will be making a new release 1.60.1 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants