Skip to content

Commit 8114a0a

Browse files
committed
Revert to use of replaceDomain and remove status subresource from CRD
1 parent ce73182 commit 8114a0a

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,10 @@ public NextAction apply(Packet packet) {
682682
private static NextAction doDomainUpdate(
683683
Domain dom, DomainPresenceInfo info, Packet packet, Step conflictStep, Step next) {
684684
V1ObjectMeta meta = dom.getMetadata();
685-
686-
// remove spec
687-
dom.setSpec(null);
688-
689685
NextAction na = new NextAction();
690686
na.invoke(
691687
new CallBuilder()
692-
.replaceDomainStatusAsync(
688+
.replaceDomainAsync(
693689
meta.getName(),
694690
meta.getNamespace(),
695691
dom,
@@ -707,8 +703,9 @@ public NextAction onFailure(Packet packet, CallResponse<Domain> callResponse) {
707703

708704
@Override
709705
public NextAction onSuccess(Packet packet, CallResponse<Domain> callResponse) {
710-
// Do not set domain on info since status update is a PUT
711-
// info.setDomain(callResponse.getResult());
706+
// Update info only if using replaceDomain
707+
// Skip, if we switch to using replaceDomainStatus
708+
info.setDomain(callResponse.getResult());
712709
return doNext(packet);
713710
}
714711
}),

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import io.kubernetes.client.models.V1beta1CustomResourceValidation;
1818
import io.kubernetes.client.models.V1beta1JSONSchemaProps;
1919
import java.util.Collections;
20-
import java.util.HashMap;
2120
import oracle.kubernetes.json.SchemaGenerator;
2221
import oracle.kubernetes.operator.KubernetesConstants;
2322
import oracle.kubernetes.operator.LabelConstants;
@@ -104,8 +103,9 @@ static V1beta1CustomResourceDefinitionSpec createSpec(KubernetesVersion version)
104103
.scale(
105104
new V1beta1CustomResourceSubresourceScale()
106105
.specReplicasPath(".spec.replicas")
107-
.statusReplicasPath(".status.replicas"))
108-
.status(new HashMap<String, Object>()));
106+
.statusReplicasPath(".status.replicas")));
107+
// Remove status for now because seeing status not updated on some k8s environments
108+
// .status(new HashMap<String, Object>()));
109109
}
110110
return spec;
111111
}
@@ -251,7 +251,8 @@ public boolean isOutdatedCRD(
251251
return actual.getSpec().getVersion().equals("v1")
252252
|| (actual.getSpec().getVersion().equals("v2")
253253
&& (getSchemaValidation(actual) == null
254-
|| !getSchemaValidation(expected).equals(getSchemaValidation(actual))));
254+
|| !getSchemaValidation(expected).equals(getSchemaValidation(actual))
255+
|| !getSchemaSubresources(expected).equals(getSchemaSubresources(actual))));
255256
// Similarly, we will later want to check:
256257
// VersionHelper.matchesResourceVersion(existingCRD.getMetadata(), DEFAULT_OPERATOR_VERSION)
257258
}
@@ -262,5 +263,13 @@ private V1beta1JSONSchemaProps getSchemaValidation(V1beta1CustomResourceDefiniti
262263
}
263264
return null;
264265
}
266+
267+
private V1beta1CustomResourceSubresources getSchemaSubresources(
268+
V1beta1CustomResourceDefinition crd) {
269+
if (crd != null && crd.getSpec() != null) {
270+
return crd.getSpec().getSubresources();
271+
}
272+
return null;
273+
}
265274
}
266275
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ String getPodReplacedMessageKey() {
6969

7070
@Override
7171
void expectStepsAfterCreation() {
72-
expectReplaceDomainStatus();
72+
expectReplaceDomain();
7373
}
7474

7575
@Override
@@ -85,6 +85,14 @@ private void expectReplaceDomainStatus() {
8585
.returning(new Domain());
8686
}
8787

88+
private void expectReplaceDomain() {
89+
testSupport
90+
.createCannedResponse("replaceDomain")
91+
.withNamespace(NS)
92+
.ignoringBody()
93+
.returning(new Domain());
94+
}
95+
8896
@Override
8997
V1Pod createPodModel() {
9098
return new V1Pod().metadata(createPodMetadata()).spec(createPodSpec());

0 commit comments

Comments
 (0)