Skip to content

Commit f9d576a

Browse files
committed
Added validation error message for illegal channel name length as per Ryan's PR review comment.
1 parent a3cae56 commit f9d576a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import static oracle.kubernetes.operator.helpers.CompatibilityCheck.CompatibilityScope.UNKNOWN;
9393
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.DOMAIN_ROLL_STARTING;
9494
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.POD_CYCLE_STARTING;
95+
import static oracle.kubernetes.operator.helpers.LegalNames.LEGAL_CONTAINER_PORT_NAME_MAX_LENGTH;
9596

9697
public abstract class PodStepContext extends BasePodStepContext {
9798

@@ -314,7 +315,7 @@ private void addContainerPort(List<V1ContainerPort> ports, String name,
314315

315316
private String createContainerPortName(List<V1ContainerPort> ports, String name) {
316317
//Container port names can be a maximum of 15 characters in length
317-
if (name.length() > LegalNames.LEGAL_CONTAINER_PORT_NAME_MAX_LENGTH) {
318+
if (name.length() > LEGAL_CONTAINER_PORT_NAME_MAX_LENGTH) {
318319
String portNamePrefix = getPortNamePrefix(name);
319320
// Find ports with the name having the same first 12 characters
320321
List<V1ContainerPort> containerPortsWithSamePrefix = ports.stream().filter(port ->
@@ -324,6 +325,10 @@ private String createContainerPortName(List<V1ContainerPort> ports, String name)
324325
// zero fill to the left for single digit index (e.g. 01)
325326
if (index < 10) {
326327
indexStr = "0" + index;
328+
} else if (index >= 100) {
329+
LOGGER.severe(MessageKeys.ILLEGAL_NETWORK_CHANNEL_NAME_LENGTH, getDomainUid(), getServerName(),
330+
name, LEGAL_CONTAINER_PORT_NAME_MAX_LENGTH);
331+
return name;
327332
}
328333
name = portNamePrefix + "-" + indexStr;
329334
}

operator/src/main/java/oracle/kubernetes/operator/logging/MessageKeys.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public class MessageKeys {
144144
public static final String LOG_WAITING_COUNT = "WLSKO-0193";
145145
public static final String INTERNAL_IDENTITY_INITIALIZATION_FAILED = "WLSKO-0194";
146146

147-
148147
// domain status messages
149148
public static final String DUPLICATE_SERVER_NAME_FOUND = "WLSDO-0001";
150149
public static final String DUPLICATE_CLUSTER_NAME_FOUND = "WLSDO-0002";
@@ -177,6 +176,7 @@ public class MessageKeys {
177176
public static final String INVALID_LIVENESS_PROBE_SUCCESS_THRESHOLD_VALUE = "WLSDO-0029";
178177
public static final String RESERVED_CONTAINER_NAME = "WLSDO-0030";
179178
public static final String ILLEGAL_CONTAINER_PORT_NAME_LENGTH = "WLSDO-0031";
179+
public static final String ILLEGAL_NETWORK_CHANNEL_NAME_LENGTH = "WLSDO-0032";
180180

181181
private MessageKeys() {
182182
}

operator/src/main/resources/Operator.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ WLSDO-0028=The Monitoring Exporter port ''{0}'' specified by ''spec.monitoringEx
185185
WLSDO-0029=Invalid value ''{0}'' for the liveness probe success threshold under ''{1}''. The liveness probe successThreshold value must be 1.
186186
WLSDO-0030=The container name ''{0}'' specified under ''{1}'' is reserved for use by the operator.
187187
WLSDO-0031=Container port name ''{2}'' for domain with domainUID ''{0}'' and container name ''{1}'' exceeds maximum allowed length ''{3}''.
188+
WLSDO-0032=Network channel name ''{2}'' for domain with domainUID ''{0}'' and server with \
189+
name ''{1}'' exceeds maximum allowed length ''{3}''. Please specify a shorter channel name.
188190

189191
oneEnvVar=variable
190192
multipleEnvVars=variables

0 commit comments

Comments
 (0)