jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
487 stars 322 forks source link

[JENKINS-71959] Rename blank cloud names to be non-blank #1010

Closed MarkEWaite closed 10 months ago

MarkEWaite commented 10 months ago

[JENKINS-71959] Rename blank cloud names to be non-blank

https://github.com/jenkinsci/jenkins/pull/7658 reworks cloud management to use multiple pages instead of a single large page. That rework also requires that a cloud may not be named with an empty string.

The docker plugin previously tested that a cloud was allowed to have an empty string as its name, but performed no other operations with a cloud named with an empty string. Clouds named with an empty string may have worked prior to Jenkins 2.403, but they would have been complicated to manage, especially in a controller with multiple clouds defined.

A cloud named with an empty string is much more difficult to manage. It is better to mention in the changelog that clouds are no longer allowed to have an empty name rather than wrestling with all the ways that an empty name will break cloud administration.

Testing done

Confirmed that a Docker cloud named with an empty string can be edited in 2.401.3 with no apparent loss of functionality and when that cloud with the empty named string is loaded into the plugin changes with this pull request, it is assigned a name docker-cloud-[hashCode]. That cloud can be edited in Jenkins 2.414.1 without any issue.

Discovered that a Docker cloud name uniqueness check is not performed. I was able to create two distinct Docker clouds with the same name. Editing the Docker clouds that shared the same name resulted in erratic behavior. I could delete one of the two clouds that used the duplicate name, but immediately after that the other cloud with the same name would fail some operations. Handling duplicate Docker cloud names is out of scope for this pull request. Another pull request can be filed to handle that case.

Confirmed that Jenkins 2.421 automated tests fail as reported in JENKINS-71825 without this change.

Confirmed that Jenkins 2.421 automated tests pass with this change.

Confirmed that Jenkins 2.421 already rejects an empty cloud name from the cloud creation page, whether or not this change is implemented.

Confirmed that Jenkins 2.421 accepts an empty cloud name from an earlier version but then rejects all attempts to use the cloud configuration page to modify the definition. I modified the XML file that configures the cloud so that the cloud name was an empty string to perform that interactive test.

Submitter checklist

MarkEWaite commented 10 months ago

@gounthar and @Vlatombe I am sure there is a better way to handle this than telling the user to stop Jenkins and edit the name attribute in the conifig.xml file section for the docker plugin. However, I don't see it. There is a readResolve() method in DockerfCloud but I don't see how it can adjust the name attribute and have it applied correctly. Any suggestions?

I like the new cloud management UI very much but would like to make the transition smooth for users of the Docker cloud plugin. If they made the mistake of naming their docker cloud with an empty string, they won't be able to edit from the web page once they are using Jenkins 2.403 or newer.