Skip to content

Commit 3b37a24

Browse files
committed
Merge branch 'owls-121004' into 'main'
Account for dot in RFC 1123 legal name conversion See merge request weblogic-cloud/weblogic-kubernetes-operator!4794 (cherry picked from commit 348c28d) 49a6022 Account for dot in RFC 1123 legal name conversion
1 parent 710059f commit 3b37a24

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

common/src/main/java/oracle/kubernetes/common/utils/CommonUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private static boolean useLatestImage(String imageName) {
5252
* @return nearest DNS-1123 legal name
5353
*/
5454
public static String toDns1123LegalName(String value) {
55-
return value.toLowerCase().replace('_', '-');
55+
return value.toLowerCase().replace('_', '-').replace('.', '-');
5656
}
5757

5858
/**

common/src/main/java/oracle/kubernetes/common/utils/SchemaConversionUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,18 +1054,14 @@ private void generateClusters(Map<String, Object> domain, List<Map<String, Objec
10541054
}
10551055
}
10561056

1057-
public static String toDns1123LegalName(String value) {
1058-
return value.toLowerCase().replace('_', '-');
1059-
}
1060-
10611057
private Map<String, Object> generateCluster(Map<String, Object> domainMeta,
10621058
Map<String, Object> existingCluster) {
10631059
Map<String, Object> cluster = new LinkedHashMap<>();
10641060
cluster.put(API_VERSION, "weblogic.oracle/v1");
10651061
cluster.put("kind", "Cluster");
10661062
Map<String, Object> clusterMeta = new LinkedHashMap<>();
10671063
clusterMeta.put("name", domainMeta.get("name") + "-"
1068-
+ toDns1123LegalName((String) existingCluster.get(CLUSTER_NAME)));
1064+
+ CommonUtils.toDns1123LegalName((String) existingCluster.get(CLUSTER_NAME)));
10691065
clusterMeta.put(NAMESPACE, domainMeta.get(NAMESPACE));
10701066
Map<String, Object> labels = new LinkedHashMap<>();
10711067
labels.put("weblogic.createdByOperator", "true");

operator/src/main/java/oracle/kubernetes/operator/helpers/JobStepContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,10 @@ protected V1Container createPrimaryContainer() {
757757

758758
private String getVolumeName(String resourceName, String type) {
759759
try {
760-
return getLegalVolumeName(resourceName, type);
760+
return CommonUtils.toDns1123LegalName(getLegalVolumeName(resourceName, type));
761761
} catch (Exception ex) {
762762
LOGGER.severe(MessageKeys.EXCEPTION, ex);
763-
return resourceName;
763+
return CommonUtils.toDns1123LegalName(resourceName);
764764
}
765765
}
766766

operator/src/main/java/oracle/kubernetes/operator/helpers/LegalNames.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private static String getExternalServiceNameSuffix() {
141141
* @return nearest DNS-1123 legal name
142142
*/
143143
public static String toDns1123LegalName(String value) {
144-
return value.toLowerCase().replace('_', '-');
144+
return value.toLowerCase().replace('_', '-').replace('.', '-');
145145
}
146146

147147
public static boolean isDns1123LegalName(String value) {

operator/src/test/java/oracle/kubernetes/operator/helpers/DomainIntrospectorJobTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,18 +533,18 @@ void whenJobCreatedWithoutInitializeDomainOnPVDefined_dontHaveSecretsVolumeAndMo
533533

534534
@Test
535535
void whenJobCreatedWithInitializeDomainOnPVCreateDomainCMDefined_hasConfigMapVolumeAndMounts() {
536-
V1ConfigMap cm = new V1ConfigMap().metadata(new V1ObjectMeta().name("initPvDomainCM").namespace(NS));
536+
V1ConfigMap cm = new V1ConfigMap().metadata(new V1ObjectMeta().name("initpvdomaincm").namespace(NS));
537537
testSupport.defineResources(cm);
538-
getConfigurator().withDomainCreationConfigMap("initPvDomainCM");
538+
getConfigurator().withDomainCreationConfigMap("initpvdomaincm");
539539

540540
List<V1Job> jobs = runStepsAndGetJobs();
541541
V1Job job = jobs.get(0);
542542

543543
assertThat(getJobPodSpec(job).getVolumes(),
544-
hasItem(new V1Volume().name("initPvDomainCM-volume").configMap(
545-
new V1ConfigMapVolumeSource().name("initPvDomainCM").defaultMode(365))));
544+
hasItem(new V1Volume().name("initpvdomaincm-volume").configMap(
545+
new V1ConfigMapVolumeSource().name("initpvdomaincm").defaultMode(365))));
546546
assertThat(getCreatedPodSpecContainers(jobs).get(0).getVolumeMounts(),
547-
hasItem(new V1VolumeMount().name("initPvDomainCM-volume")
547+
hasItem(new V1VolumeMount().name("initpvdomaincm-volume")
548548
.mountPath(WDTCONFIGMAP_MOUNT_PATH).readOnly(true)));
549549
}
550550

0 commit comments

Comments
 (0)