Skip to content

Commit

Permalink
[JENKINS-70729] Stop supporting an empty cloud name
Browse files Browse the repository at this point in the history
jenkinsci/jenkins#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 specifically tested that a cloud was allowed to have an
empty string as its name, but performed no other operations with a cloud
that is named with an empty string.  Cloud 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.

https://issues.jenkins.io/browse/JENKINS-70729 is the enhancement request
that implements the change.

https://issues.jenkins.io/browse/JENKINS-71825 is the bug report for
the automated test failure that started this investigation.
  • Loading branch information
MarkEWaite committed Sep 3, 2023
1 parent e364291 commit 1fc91ca
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ public class JenkinsUtilsTest {
public void getCloudByNameOrThrowGivenNameThenReturnsCloud() throws Exception {
// Given
final DockerAPI dockerApi = new DockerAPI(new DockerServerEndpoint("uri", "credentialsId"));
final DockerCloud cloudEmpty = new DockerCloud("", dockerApi, Collections.emptyList());
final String expectedCloudName = "expectedCloudName";
final DockerCloud cloudExpected = new DockerCloud(expectedCloudName, dockerApi, Collections.emptyList());
final DockerCloud cloudOther = new DockerCloud("otherCloudName", dockerApi, Collections.emptyList());
final OtherTypeOfCloud cloudForeign = new OtherTypeOfCloud("foreign");
final List<Cloud> clouds = List.of(cloudEmpty, cloudOther, cloudExpected, cloudForeign);
final List<Cloud> clouds = List.of(cloudOther, cloudExpected, cloudForeign);
jenkins.getInstance().clouds.replaceBy(clouds);

// When
Expand All @@ -47,14 +46,13 @@ public void getCloudByNameOrThrowGivenNameThenReturnsCloud() throws Exception {
public void getCloudByNameOrThrowGivenUnknownNameThenThrows() throws Exception {
// Given
final DockerAPI dockerApi = new DockerAPI(new DockerServerEndpoint("uri", "credentialsId"));
final DockerCloud cloudEmpty = new DockerCloud("", dockerApi, Collections.emptyList());
final String requestedCloudName = "anUnknownCloudName";
final String cloudName1 = "expectedCloudName";
final DockerCloud cloud1 = new DockerCloud(cloudName1, dockerApi, Collections.emptyList());
final String cloudName2 = "otherCloudName";
final DockerCloud cloud2 = new DockerCloud(cloudName2, dockerApi, Collections.emptyList());
final OtherTypeOfCloud cloudForeign = new OtherTypeOfCloud("foreign");
final List<Cloud> clouds = List.of(cloudEmpty, cloud2, cloud1, cloudForeign);
final List<Cloud> clouds = List.of(cloud2, cloud1, cloudForeign);
jenkins.getInstance().clouds.replaceBy(clouds);

try {
Expand All @@ -75,14 +73,13 @@ public void getCloudByNameOrThrowGivenUnknownNameThenThrows() throws Exception {
public void getCloudByNameOrThrowGivenForeignCloudNameThenThrows() throws Exception {
// Given
final DockerAPI dockerApi = new DockerAPI(new DockerServerEndpoint("uri", "credentialsId"));
final DockerCloud cloudEmpty = new DockerCloud("", dockerApi, Collections.emptyList());
final String requestedCloudName = "foreign";
final String cloudName1 = "DockerCloud1Name";
final DockerCloud cloud1 = new DockerCloud(cloudName1, dockerApi, Collections.emptyList());
final String cloudName2 = "DockerCloud2Name";
final DockerCloud cloud2 = new DockerCloud(cloudName2, dockerApi, Collections.emptyList());
final OtherTypeOfCloud cloudForeign = new OtherTypeOfCloud(requestedCloudName);
final List<Cloud> clouds = List.of(cloudEmpty, cloud2, cloud1, cloudForeign);
final List<Cloud> clouds = List.of(cloud2, cloud1, cloudForeign);
jenkins.getInstance().clouds.replaceBy(clouds);

try {
Expand Down

0 comments on commit 1fc91ca

Please sign in to comment.