Skip to content

Commit deec72a

Browse files
committed
Merge branch 'reduce-domain-incomplete-status' into 'main'
Add restful management api disabled option and reduce number of events for... See merge request weblogic-cloud/weblogic-kubernetes-operator!5031
2 parents 08aceef + ea20749 commit deec72a

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
import static oracle.kubernetes.operator.EventConstants.WEBHOOK_STARTUP_FAILED_EVENT;
9292
import static oracle.kubernetes.operator.EventConstants.WEBLOGIC_OPERATOR_COMPONENT;
9393
import static oracle.kubernetes.operator.calls.ResponseStep.isForbidden;
94+
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.DOMAIN_INCOMPLETE;
95+
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.DOMAIN_UNAVAILABLE;
9496
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.NAMESPACE_WATCHING_STARTED;
9597
import static oracle.kubernetes.operator.helpers.EventHelper.EventItem.NAMESPACE_WATCHING_STOPPED;
9698
import static oracle.kubernetes.operator.helpers.NamespaceHelper.getOperatorNamespace;
@@ -218,6 +220,11 @@ private Step createReplaceEventCall(EventsV1Event event, @NotNull EventsV1Event
218220
existingEvent.series(new EventsV1EventSeries()
219221
.lastObservedTime(event.getEventTime())
220222
.count(Optional.ofNullable(existingEvent.getSeries()).map(EventsV1EventSeries::getCount).orElse(1) + 1));
223+
// Short circuit domain incomplete unavailable events
224+
if (existingEvent.getSeries().getCount() > 5 && (DOMAIN_INCOMPLETE == eventData.eventItem
225+
|| DOMAIN_UNAVAILABLE == eventData.eventItem)) {
226+
return getNext();
227+
}
221228
return RequestBuilder.EVENT.update(existingEvent,
222229
new ReplaceEventResponseStep(this, existingEvent, getNext()));
223230
}

operator/src/main/java/oracle/kubernetes/operator/steps/ReadHealthStep.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ static final class ReadHealthWithHttpStep extends Step {
191191
@Override
192192
public @Nonnull Result apply(Packet packet) {
193193
ReadHealthProcessing processing = new ReadHealthProcessing(packet, service, pod);
194-
if (processing.getWlsServerConfig() == null) {
194+
195+
if (processing.getWlsServerConfig() == null
196+
|| "false".equalsIgnoreCase(processing.getWlsDomainConfig().getRestfulAPIEnabled())) {
197+
LOGGER.fine("Skipping read health request because wls server config is null or restful API is disabled");
195198
return doNext(packet);
196199
}
197200
return doNext(createRequestStep(processing.createRequest(), new RecordHealthStep(getNext())), packet);

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsDomainConfig.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class WlsDomainConfig implements WlsDomain {
3030

3131
private String adminServerName;
3232

33+
private String restfulAPIEnabled;
34+
3335
// Contains all configured WLS clusters in the WLS domain
3436
private List<WlsClusterConfig> configuredClusters = new ArrayList<>();
3537
// Contains all statically configured WLS servers in the WLS domain
@@ -62,6 +64,7 @@ public WlsDomainConfig(String name) {
6264
public WlsDomainConfig(
6365
String name,
6466
String adminServerName,
67+
String restfulAPIEnabled,
6568
Map<String, WlsClusterConfig> wlsClusterConfigs,
6669
Map<String, WlsServerConfig> wlsServerConfigs,
6770
Map<String, WlsServerConfig> wlsServerTemplates) {
@@ -72,6 +75,7 @@ public WlsDomainConfig(
7275
wlsServerTemplates != null ? new ArrayList<>(wlsServerTemplates.values()) : null;
7376
this.name = name;
7477
this.adminServerName = adminServerName;
78+
this.restfulAPIEnabled = restfulAPIEnabled;
7579
// set domainConfig for each WlsClusterConfig
7680
for (WlsClusterConfig wlsClusterConfig : this.configuredClusters) {
7781
wlsClusterConfig.setWlsDomainConfig(this);
@@ -113,6 +117,18 @@ public void setAdminServerName(String adminServerName) {
113117
this.adminServerName = adminServerName;
114118
}
115119

120+
/**
121+
* Return whether restful management api is enabled.
122+
* @return "true" if enabled, otherwise "false"
123+
*/
124+
public String getRestfulAPIEnabled() {
125+
return this.restfulAPIEnabled;
126+
}
127+
128+
public void setRestfulAPIEnabled(String restfulAPIEnabled) {
129+
this.restfulAPIEnabled = restfulAPIEnabled;
130+
}
131+
116132
/**
117133
* Returns all cluster configurations found in the WLS domain.
118134
*
@@ -354,6 +370,7 @@ public String toString() {
354370
return new ToStringBuilder(this)
355371
.append("name", name)
356372
.append("adminServerName", adminServerName)
373+
.append("restfulAPIEnabled", restfulAPIEnabled)
357374
.append("configuredClusters", configuredClusters)
358375
.append("servers", servers)
359376
.append("serverTemplates", serverTemplates)
@@ -366,6 +383,7 @@ public int hashCode() {
366383
new HashCodeBuilder()
367384
.append(name)
368385
.append(adminServerName)
386+
.append(restfulAPIEnabled)
369387
.append(configuredClusters)
370388
.append(servers)
371389
.append(serverTemplates);
@@ -385,6 +403,7 @@ public boolean equals(Object other) {
385403
new EqualsBuilder()
386404
.append(name, rhs.name)
387405
.append(adminServerName, rhs.adminServerName)
406+
.append(restfulAPIEnabled, rhs.restfulAPIEnabled)
388407
.append(configuredClusters, rhs.configuredClusters)
389408
.append(servers, rhs.servers)
390409
.append(serverTemplates, rhs.serverTemplates);

operator/src/main/resources/scripts/introspectDomain.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ def open(self):
194194
readDomain(self.getDomainHome())
195195
self.domain = cmo
196196
self.DOMAIN_NAME = self.getDomain().getName()
197+
self.RESTAPI_ENABLED = "true"
198+
mgmtsvc = self.getDomain().getRestfulManagementServices()
199+
if mgmtsvc != None and not mgmtsvc.isEnabled():
200+
self.RESTAPI_ENABLED = "false"
197201

198202
# this should only be done for model in image case
199203
if self.DOMAIN_SOURCE_TYPE == "FromModel" or self.INIT_DOMAIN_ON_PV is not None:
@@ -816,6 +820,7 @@ def addDomain(self):
816820
self.indent()
817821
self.writeln("name: " + self.name(self.env.getDomain()))
818822
self.writeln("adminServerName: " + self.quote(self.env.getDomain().getAdminServerName()))
823+
self.writeln('restfulAPIEnabled: ' + self.env.RESTAPI_ENABLED)
819824
self.addConfiguredClusters()
820825
self.addServerTemplates()
821826
self.addNonClusteredServers()

operator/src/test/java/oracle/kubernetes/operator/utils/WlsDomainConfigSupport.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class WlsDomainConfigSupport {
1919
public static final Integer DEFAULT_LISTEN_PORT = 7001;
2020
private final String domain;
2121
private String adminServerName;
22+
private String restfulAPIEnabled;
2223
private final Map<String, WlsClusterConfig> wlsClusters = new HashMap<>();
2324
private final Map<String, WlsServerConfig> wlsServers = new HashMap<>();
2425
private final Map<String, WlsServerConfig> templates = new HashMap<>();
@@ -56,6 +57,11 @@ public WlsDomainConfigSupport withAdminServerName(String adminServerName) {
5657
return this;
5758
}
5859

60+
public WlsDomainConfigSupport withRestfulAPIEnabled(String restfulAPIEnabled) {
61+
setAdminServerName(restfulAPIEnabled);
62+
return this;
63+
}
64+
5965
public void setAdminServerName(String adminServerName) {
6066
this.adminServerName = adminServerName;
6167
}
@@ -209,7 +215,7 @@ public WlsDomainConfig createDomainConfig() {
209215
}
210216
}
211217
return new WlsDomainConfig(
212-
domain, adminServerName, wlsClusters, wlsServers, templates);
218+
domain, adminServerName, restfulAPIEnabled, wlsClusters, wlsServers, templates);
213219
}
214220

215221
static class ServerConfigBuilder {

0 commit comments

Comments
 (0)