Skip to content

Commit 014f133

Browse files
committed
Make domainUID optional and remove unneeded values from samples
1 parent b64689d commit 014f133

File tree

16 files changed

+43
-87
lines changed

16 files changed

+43
-87
lines changed

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ function createFiles {
285285
echo Generating ${domainPropertiesOutput}
286286

287287
cp ${domainPropertiesInput} ${domainPropertiesOutput}
288-
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPropertiesOutput}
289-
sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${domainPropertiesOutput}
290-
sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${domainPropertiesOutput}
291-
sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${domainPropertiesOutput}
292-
sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${domainPropertiesOutput}
293288
sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${domainPropertiesOutput}
294289
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${domainPropertiesOutput}
295290
sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${domainPropertiesOutput}

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/domain-template.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ metadata:
1111
labels:
1212
weblogic.resourceVersion: domain-v2
1313
weblogic.domainUID: %DOMAIN_UID%
14-
weblogic.domainName: %DOMAIN_NAME%
1514
spec:
16-
# The domainUID must be unique across the entire Kubernetes Cluster. Each WebLogic Domain must
17-
# have its own unique domainUID. This does not have to be the same as the Domain Name. It is allowed
18-
# to have multiple Domains with the same Domain Name, but they MUST have different domainUID's.
19-
# The domainUID is also used to identify the Persistent Volume that belongs to/with this Domain.
20-
domainUID: %DOMAIN_UID%
21-
# The WebLogic Domain Name
22-
domainName: %DOMAIN_NAME%
2315
# The WebLogic Domain Home
2416
domainHome: %DOMAIN_HOME%
2517
# If the domain home is in the image
@@ -32,10 +24,6 @@ spec:
3224
# how to create that Secret at the end of this file)
3325
adminSecret:
3426
name: %WEBLOGIC_CREDENTIALS_SECRET_NAME%
35-
# The name of the Admin Server
36-
asName: "%ADMIN_SERVER_NAME%"
37-
# The Admin Server's ListenPort
38-
asPort: %ADMIN_PORT%
3927
# Whether to include the server out file into the pod's stdout, default is true
4028
includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG%
4129
# serverStartPolicy legal values are "NEVER", "ALWAYS", "IF_NEEDED", or "ADMIN_ONLY"

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,10 @@ function createYamlFiles {
390390
sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${dcrOutput}
391391
sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${dcrOutput}
392392
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${dcrOutput}
393-
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${dcrOutput}
394393
sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${dcrOutput}
395-
sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${dcrOutput}
396394
sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${dcrOutput}
397395
sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${dcrOutput}
398396
sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${dcrOutput}
399-
sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${dcrOutput}
400397
sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput}
401398
sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${dcrOutput}
402399
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${dcrOutput}

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/domain-template.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ metadata:
1212
labels:
1313
weblogic.resourceVersion: domain-v2
1414
weblogic.domainUID: %DOMAIN_UID%
15-
weblogic.domainName: %DOMAIN_NAME%
1615
spec:
17-
# The domainUID must be unique across the entire Kubernetes Cluster. Each WebLogic Domain must
18-
# have its own unique domainUID. This does not have to be the same as the Domain Name. It is allowed
19-
# to have multiple Domains with the same Domain Name, but they MUST have different domainUID's.
20-
# The domainUID is also used to identify the Persistent Volume that belongs to/with this Domain.
21-
domainUID: %DOMAIN_UID%
22-
# The WebLogic Domain Name
23-
domainName: %DOMAIN_NAME%
2416
# The WebLogic Domain Home
2517
domainHome: %DOMAIN_HOME%
2618
# If the domain home is in the image
@@ -36,10 +28,6 @@ spec:
3628
# how to create that Secret at the end of this file)
3729
adminSecret:
3830
name: %WEBLOGIC_CREDENTIALS_SECRET_NAME%
39-
# The name of the Admin Server
40-
asName: "%ADMIN_SERVER_NAME%"
41-
# The Admin Server's ListenPort
42-
asPort: %ADMIN_PORT%
4331
# Whether to include the server out file into the pod's stdout, default is true
4432
includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG%
4533
# The in-pod name of the directory to store the domain, node manager, server logs, and server .out

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/Domain.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.kubernetes.client.models.V1SecretReference;
1313
import java.util.List;
1414
import java.util.Map;
15+
import java.util.Optional;
1516
import javax.annotation.Nonnull;
1617
import javax.validation.Valid;
1718
import oracle.kubernetes.json.Description;
@@ -25,6 +26,11 @@
2526
/** Domain represents a WebLogic domain and how it will be realized in the Kubernetes cluster. */
2627
@SuppressWarnings("deprecation")
2728
public class Domain {
29+
/** The pattern for computing the default persistent volume claim name. */
30+
private static final String PVC_NAME_PATTERN = "%s-weblogic-domain-pvc";
31+
32+
/** The pattern for computing the default shared logs directory. */
33+
private static final String LOG_HOME_DEFAULT_PATTERN = "/shared/logs/%s";
2834

2935
/**
3036
* APIVersion defines the versioned schema of this representation of an object. Servers should
@@ -277,11 +283,12 @@ public V1SecretReference getAdminSecret() {
277283
* @return domain UID
278284
*/
279285
public String getDomainUID() {
280-
return spec.getDomainUID();
286+
return spec.getDomainUID() != null ? spec.getDomainUID() : getMetadata().getName();
281287
}
282288

283289
public String getLogHome() {
284-
return spec.getLogHome();
290+
return Optional.ofNullable(spec.getLogHome())
291+
.orElse(String.format(LOG_HOME_DEFAULT_PATTERN, getDomainUID()));
285292
}
286293

287294
public boolean isIncludeServerOutInPodLog() {
@@ -332,7 +339,12 @@ public Map<String, String> getChannelServiceAnnotations(String channel) {
332339
* @return volume claim
333340
*/
334341
public String getPersistentVolumeClaimName() {
335-
return spec.getPersistentVolumeClaimName();
342+
return spec.getStorage() == null ? null : getConfiguredClaimName(spec.getStorage());
343+
}
344+
345+
private String getConfiguredClaimName(@Nonnull DomainStorage storage) {
346+
return Optional.ofNullable(storage.getPersistentVolumeClaimName())
347+
.orElse(String.format(PVC_NAME_PATTERN, getDomainUID()));
336348
}
337349

338350
/**

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainSpec.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.kubernetes.client.models.V1LocalObjectReference;
1010
import io.kubernetes.client.models.V1SecretReference;
1111
import java.util.*;
12-
import javax.annotation.Nonnull;
1312
import javax.annotation.Nullable;
1413
import javax.validation.Valid;
1514
import javax.validation.constraints.NotNull;
@@ -27,14 +26,10 @@
2726
/** DomainSpec is a description of a domain. */
2827
public class DomainSpec extends BaseConfiguration {
2928

30-
/** The pattern for computing the default persistent volume claim name. */
31-
private static final String PVC_NAME_PATTERN = "%s-weblogic-domain-pvc";
32-
33-
/** The pattern for computing the default shared logs directory. */
34-
private static final String LOG_HOME_DEFAULT_PATTERN = "/shared/logs/%s";
35-
36-
/** Domain unique identifier. Must be unique across the Kubernetes cluster. (Required) */
37-
@NotNull
29+
/** Domain unique identifier. Must be unique across the Kubernetes cluster. */
30+
@Description(
31+
"Domain unique identifier. Must be unique across the Kubernetes cluster. (Not required)"
32+
+ "Defaults to the value of metadata.name")
3833
@Pattern("^[a-z0-9_.]{1,253}$")
3934
private String domainUID;
4035

@@ -208,7 +203,8 @@ EffectiveConfigurationFactory getEffectiveConfigurationFactory(String resourceVe
208203
}
209204

210205
/**
211-
* Domain unique identifier. Must be unique across the Kubernetes cluster. (Required)
206+
* Domain unique identifier. Must be unique across the Kubernetes cluster. (Not required) Defaults
207+
* to the value of metadata.name
212208
*
213209
* @return domain UID
214210
*/
@@ -217,7 +213,8 @@ public String getDomainUID() {
217213
}
218214

219215
/**
220-
* Domain unique identifier. Must be unique across the Kubernetes cluster. (Required)
216+
* Domain unique identifier. Must be unique across the Kubernetes cluster. (Not required) Defaults
217+
* to the value of metadata.name
221218
*
222219
* @param domainUID domain UID
223220
*/
@@ -331,7 +328,7 @@ public void setImagePullSecrets(@Nullable List<V1LocalObjectReference> imagePull
331328
* server .out files in.
332329
*/
333330
String getLogHome() {
334-
return Optional.ofNullable(logHome).orElse(String.format(LOG_HOME_DEFAULT_PATTERN, domainUID));
331+
return logHome;
335332
}
336333

337334
public void setLogHome(String logHome) {
@@ -466,20 +463,6 @@ public void setConfigOverrideSecrets(@Nullable List<String> overridesSecretNames
466463
this.configOverrideSecrets = overridesSecretNames;
467464
}
468465

469-
/**
470-
* Returns the name of the persistent volume claim for the logs and PV-based domain.
471-
*
472-
* @return volume claim
473-
*/
474-
String getPersistentVolumeClaimName() {
475-
return storage == null ? null : getConfiguredClaimName(storage);
476-
}
477-
478-
private String getConfiguredClaimName(@Nonnull DomainStorage storage) {
479-
return Optional.ofNullable(storage.getPersistentVolumeClaimName())
480-
.orElse(String.format(PVC_NAME_PATTERN, domainUID));
481-
}
482-
483466
@Nullable
484467
@Override
485468
protected String getServerStartPolicy() {

model/src/test/java/oracle/kubernetes/weblogic/domain/v2/DomainV2Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,14 +1343,14 @@ public void whenDomainHomeInImageSpecified_useValue() {
13431343
public void whenLogHomeNotSet_useDefault() {
13441344
configureDomain(domain);
13451345

1346-
assertThat(domain.getSpec().getLogHome(), equalTo("/shared/logs/uid1"));
1346+
assertThat(domain.getLogHome(), equalTo("/shared/logs/uid1"));
13471347
}
13481348

13491349
@Test
13501350
public void whenLogHomeSet_useValue() {
13511351
configureDomain(domain).withLogHome("/custom/logs");
13521352

1353-
assertThat(domain.getSpec().getLogHome(), equalTo("/custom/logs"));
1353+
assertThat(domain.getLogHome(), equalTo("/custom/logs"));
13541354
}
13551355

13561356
@Test

operator/src/main/java/oracle/kubernetes/operator/DomainProcessorImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,19 +482,19 @@ public void dispatchDomainWatch(Watch.Response<Domain> item) {
482482
switch (item.type) {
483483
case "ADDED":
484484
d = item.object;
485-
domainUID = d.getSpec().getDomainUID();
485+
domainUID = d.getDomainUID();
486486
LOGGER.info(MessageKeys.WATCH_DOMAIN, domainUID);
487487
makeRightDomainPresence(new DomainPresenceInfo(d), true, false, true);
488488
break;
489489
case "MODIFIED":
490490
d = item.object;
491-
domainUID = d.getSpec().getDomainUID();
491+
domainUID = d.getDomainUID();
492492
LOGGER.info(MessageKeys.WATCH_DOMAIN, domainUID);
493493
makeRightDomainPresence(new DomainPresenceInfo(d), false, false, true);
494494
break;
495495
case "DELETED":
496496
d = item.object;
497-
domainUID = d.getSpec().getDomainUID();
497+
domainUID = d.getDomainUID();
498498
LOGGER.info(MessageKeys.WATCH_DOMAIN_DELETED, domainUID);
499499
makeRightDomainPresence(new DomainPresenceInfo(d), true, true, true);
500500
break;

operator/src/main/java/oracle/kubernetes/operator/DomainStatusUpdater.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public NextAction apply(Packet packet) {
442442
madeChange = true;
443443
}
444444

445-
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getSpec().getDomainUID(), status);
445+
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getDomainUID(), status);
446446
LOGGER.exiting();
447447

448448
return madeChange == true
@@ -510,7 +510,7 @@ public NextAction apply(Packet packet) {
510510
}
511511
}
512512

513-
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getSpec().getDomainUID(), status);
513+
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getDomainUID(), status);
514514
LOGGER.exiting();
515515

516516
return madeChange == true
@@ -627,7 +627,7 @@ public NextAction apply(Packet packet) {
627627
madeChange = true;
628628
}
629629

630-
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getSpec().getDomainUID(), status);
630+
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getDomainUID(), status);
631631
LOGGER.exiting();
632632
return madeChange == true
633633
? doDomainUpdate(dom, info, packet, AvailableStep.this, getNext())
@@ -795,7 +795,7 @@ public NextAction apply(Packet packet) {
795795
madeChange = true;
796796
}
797797

798-
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getSpec().getDomainUID(), status);
798+
LOGGER.info(MessageKeys.DOMAIN_STATUS, dom.getDomainUID(), status);
799799
LOGGER.exiting();
800800

801801
return madeChange == true

operator/src/main/java/oracle/kubernetes/operator/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public NextAction onSuccess(Packet packet, CallResponse<DomainList> callResponse
534534
Set<String> domainUIDs = new HashSet<>();
535535
if (callResponse.getResult() != null) {
536536
for (Domain dom : callResponse.getResult().getItems()) {
537-
String domainUID = dom.getSpec().getDomainUID();
537+
String domainUID = dom.getDomainUID();
538538
domainUIDs.add(domainUID);
539539
DomainPresenceInfo info =
540540
dpis.compute(

0 commit comments

Comments
 (0)