Skip to content

Commit 9fa9d85

Browse files
authored
Consistently manage domain resources using name rather than domainUid (#3741)
1 parent ac94ef1 commit 9fa9d85

File tree

7 files changed

+28
-18
lines changed

7 files changed

+28
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class WaitForReadyStep<T> extends Step {
3434

3535
protected static Step createMakeDomainRightStep(WaitForReadyStep<?>.Callback callback,
3636
DomainPresenceInfo info, Step next) {
37-
return new CallBuilder().readDomainAsync(info.getDomainUid(),
37+
return new CallBuilder().readDomainAsync(info.getDomainName(),
3838
info.getNamespace(), new MakeRightDomainStep<>(callback, null));
3939
}
4040

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ public Object createClusterUntyped(String namespace, Map<String, Object> body) t
800800
/**
801801
* Patch cluster.
802802
*
803-
* @param name the domain uid (unique within the k8s cluster)
803+
* @param name the domain name
804804
* @param namespace the namespace containing the domain
805805
* @param patchBody the patch to apply
806806
* @return Updated cluster
@@ -921,41 +921,41 @@ public Step readDomainAsync(String name, String namespace, ResponseStep<DomainRe
921921
/**
922922
* Read domain synchronously.
923923
*
924-
* @param uid the domain uid (unique within the k8s cluster)
924+
* @param name the domain name
925925
* @param namespace Namespace
926926
* @return Replaced domain
927927
* @throws ApiException APIException
928928
*/
929-
public DomainResource readDomain(String uid, String namespace) throws ApiException {
930-
RequestParams requestParams = new RequestParams("readDomain", namespace, uid, null, (String)null);
929+
public DomainResource readDomain(String name, String namespace) throws ApiException {
930+
RequestParams requestParams = new RequestParams("readDomain", namespace, name, null, (String)null);
931931
return executeSynchronousCall(requestParams, readDomainCall);
932932
}
933933

934934
/**
935935
* Replace domain.
936936
*
937-
* @param uid the domain uid (unique within the k8s cluster)
937+
* @param name the domain name
938938
* @param namespace Namespace
939939
* @param body Body
940940
* @return Replaced domain
941941
* @throws ApiException APIException
942942
*/
943-
public DomainResource replaceDomain(String uid, String namespace, DomainResource body) throws ApiException {
944-
RequestParams requestParams = new RequestParams("replaceDomain", namespace, uid, body, uid);
943+
public DomainResource replaceDomain(String name, String namespace, DomainResource body) throws ApiException {
944+
RequestParams requestParams = new RequestParams("replaceDomain", namespace, name, body, name);
945945
return executeSynchronousCall(requestParams, replaceDomainCall);
946946
}
947947

948948
/**
949949
* Replace domain status.
950950
*
951-
* @param uid the domain uid (unique within the k8s cluster)
951+
* @param name the domain name
952952
* @param namespace Namespace
953953
* @param body Body
954954
* @return Replaced domain
955955
* @throws ApiException APIException
956956
*/
957-
public DomainResource replaceDomainStatus(String uid, String namespace, DomainResource body) throws ApiException {
958-
RequestParams requestParams = new RequestParams("replaceDomainStatus", namespace, uid, body, uid);
957+
public DomainResource replaceDomainStatus(String name, String namespace, DomainResource body) throws ApiException {
958+
RequestParams requestParams = new RequestParams("replaceDomainStatus", namespace, name, body, name);
959959
return executeSynchronousCall(requestParams, replaceDomainStatusCall);
960960
}
961961

@@ -984,15 +984,15 @@ public Step replaceDomainAsync(
984984
/**
985985
* Patch domain.
986986
*
987-
* @param uid the domain uid (unique within the k8s cluster)
987+
* @param name the domain name
988988
* @param namespace the namespace containing the domain
989989
* @param patchBody the patch to apply
990990
* @return Updated domain
991991
* @throws ApiException APIException
992992
*/
993-
public DomainResource patchDomain(String uid, String namespace, V1Patch patchBody) throws ApiException {
993+
public DomainResource patchDomain(String name, String namespace, V1Patch patchBody) throws ApiException {
994994
RequestParams requestParams =
995-
new RequestParams("patchDomain", namespace, uid, patchBody, uid);
995+
new RequestParams("patchDomain", namespace, name, patchBody, name);
996996
return executeSynchronousCall(requestParams, patchDomainCall);
997997
}
998998

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,15 @@ public String getDomainUid() {
741741
return domainUid;
742742
}
743743

744+
/**
745+
* Gets the Domain name.
746+
*
747+
* @return Domain name
748+
*/
749+
public String getDomainName() {
750+
return getDomain().getMetadata().getName();
751+
}
752+
744753
@Override
745754
public String getResourceName() {
746755
return getDomainUid();

operator/src/main/java/oracle/kubernetes/operator/http/rest/RestBackendImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ private void patchDomain(DomainResource domain, JsonPatchBuilder patchBuilder) {
457457
try {
458458
callBuilder
459459
.patchDomain(
460-
domain.getDomainUid(), domain.getMetadata().getNamespace(),
460+
domain.getMetadata().getName(), domain.getMetadata().getNamespace(),
461461
new V1Patch(patchBuilder.build().toString()));
462462
} catch (ApiException e) {
463463
throw handleApiException(e);

operator/src/main/java/oracle/kubernetes/operator/makeright/MakeRightDomainOperationImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private class UpHeadStep extends Step {
348348
@Override
349349
public NextAction apply(Packet packet) {
350350
DomainPresenceInfo info = packet.getSpi(DomainPresenceInfo.class);
351-
return doNext(new CallBuilder().readDomainAsync(info.getDomainUid(), info.getNamespace(),
351+
return doNext(new CallBuilder().readDomainAsync(info.getDomainName(), info.getNamespace(),
352352
new ReadDomainResponseStep(getNext())), packet);
353353
}
354354
}

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ public static boolean isAdminChannelPortForwardingEnabled(DomainSpec domainSpec)
611611
* @return domain home
612612
*/
613613
public String getDomainHome() {
614-
return emptyToNull(spec.getDomainHome());
614+
return emptyToNull(Optional.ofNullable(spec.getDomainHome())
615+
.orElse(getDomainHomeSourceType().getDefaultDomainHome(getDomainUid())));
615616
}
616617

617618
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public DomainSpec withDomainUid(String domainUid) {
518518
* @return domain home
519519
*/
520520
String getDomainHome() {
521-
return Optional.ofNullable(domainHome).orElse(getDomainHomeSourceType().getDefaultDomainHome(getDomainUid()));
521+
return domainHome;
522522
}
523523

524524
public String getLivenessProbeCustomScript() {

0 commit comments

Comments
 (0)