Skip to content

Commit d95521e

Browse files
authored
Merge pull request #525 from oracle/ingress-clean
OWLS-69409 Remove operator creation of Ingress
2 parents acb6e08 + 4dcf771 commit d95521e

21 files changed

+5
-1337
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.kubernetes.client.models.V1Event;
99
import io.kubernetes.client.models.V1Pod;
1010
import io.kubernetes.client.models.V1Service;
11-
import io.kubernetes.client.models.V1beta1Ingress;
1211
import io.kubernetes.client.util.Watch;
1312
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
1413
import oracle.kubernetes.weblogic.domain.v2.Domain;
@@ -31,8 +30,6 @@ public void makeRightDomainPresence(
3130

3231
public void dispatchServiceWatch(Watch.Response<V1Service> item);
3332

34-
public void dispatchIngressWatch(Watch.Response<V1beta1Ingress> item);
35-
3633
public void dispatchConfigMapWatch(Watch.Response<V1ConfigMap> item);
3734

3835
public void dispatchEventWatch(Watch.Response<V1Event> item);

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

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import io.kubernetes.client.models.V1PodList;
1313
import io.kubernetes.client.models.V1Service;
1414
import io.kubernetes.client.models.V1ServiceList;
15-
import io.kubernetes.client.models.V1beta1Ingress;
16-
import io.kubernetes.client.models.V1beta1IngressList;
1715
import io.kubernetes.client.util.Watch;
1816
import java.util.ArrayList;
1917
import java.util.List;
@@ -336,68 +334,6 @@ public void dispatchServiceWatch(Watch.Response<V1Service> item) {
336334
}
337335
}
338336

339-
public void dispatchIngressWatch(Watch.Response<V1beta1Ingress> item) {
340-
V1beta1Ingress i = item.object;
341-
if (i != null) {
342-
V1ObjectMeta metadata = i.getMetadata();
343-
String domainUID = metadata.getLabels().get(LabelConstants.DOMAINUID_LABEL);
344-
String clusterName = metadata.getLabels().get(LabelConstants.CLUSTERNAME_LABEL);
345-
if (domainUID != null && clusterName != null) {
346-
DomainPresenceInfo existing = getExisting(metadata.getNamespace(), domainUID);
347-
if (existing != null) {
348-
switch (item.type) {
349-
case "ADDED":
350-
existing
351-
.getIngresses()
352-
.compute(
353-
clusterName,
354-
(key, current) -> {
355-
if (current != null) {
356-
if (isOutdated(current.getMetadata(), metadata)) {
357-
return current;
358-
}
359-
}
360-
return i;
361-
});
362-
break;
363-
case "MODIFIED":
364-
existing
365-
.getIngresses()
366-
.compute(
367-
clusterName,
368-
(key, current) -> {
369-
if (current != null) {
370-
if (!isOutdated(current.getMetadata(), metadata)) {
371-
return i;
372-
}
373-
}
374-
return current;
375-
});
376-
break;
377-
case "DELETED":
378-
boolean removed =
379-
removeIfPresentAnd(
380-
existing.getIngresses(),
381-
clusterName,
382-
(current) -> {
383-
return isOutdated(current.getMetadata(), metadata);
384-
});
385-
if (removed && !existing.isDeleting()) {
386-
// Ingress was deleted, but sko still contained a non-null entry
387-
LOGGER.info(
388-
MessageKeys.INGRESS_DELETED, domainUID, metadata.getNamespace(), clusterName);
389-
makeRightDomainPresence(existing, true, false, true);
390-
}
391-
break;
392-
393-
case "ERROR":
394-
default:
395-
}
396-
}
397-
}
398-
}
399-
}
400-
401337
private static <K, V> boolean removeIfPresentAnd(
402338
ConcurrentMap<K, V> map, K key, Predicate<? super V> predicateFunction) {
403339
Objects.requireNonNull(predicateFunction);
@@ -702,12 +638,7 @@ public StartPlanStep(DomainPresenceInfo info, Step next) {
702638
public NextAction apply(Packet packet) {
703639
Step strategy = new RegisterStep(info, getNext());
704640
if (!info.isPopulated()) {
705-
strategy =
706-
Step.chain(
707-
readExistingPods(info),
708-
readExistingServices(info),
709-
readExistingIngresses(info),
710-
strategy);
641+
strategy = Step.chain(readExistingPods(info), readExistingServices(info), strategy);
711642
}
712643
return doNext(strategy, packet);
713644
}
@@ -736,14 +667,6 @@ private static Step readExistingPods(DomainPresenceInfo info) {
736667
.listPodAsync(info.getNamespace(), new PodListStep(info));
737668
}
738669

739-
private static Step readExistingIngresses(DomainPresenceInfo info) {
740-
return new CallBuilder()
741-
.withLabelSelectors(
742-
LabelConstants.forDomainUid(info.getDomainUID()),
743-
LabelConstants.CREATEDBYOPERATOR_LABEL)
744-
.listIngressAsync(info.getNamespace(), new IngressListStep(info));
745-
}
746-
747670
private static Step readExistingServices(DomainPresenceInfo info) {
748671
return new CallBuilder()
749672
.withLabelSelectors(
@@ -783,36 +706,6 @@ public NextAction onSuccess(Packet packet, CallResponse<V1PodList> callResponse)
783706
}
784707
}
785708

786-
private static class IngressListStep extends ResponseStep<V1beta1IngressList> {
787-
private final DomainPresenceInfo info;
788-
789-
IngressListStep(DomainPresenceInfo info) {
790-
this.info = info;
791-
}
792-
793-
@Override
794-
public NextAction onFailure(Packet packet, CallResponse<V1beta1IngressList> callResponse) {
795-
return callResponse.getStatusCode() == CallBuilder.NOT_FOUND
796-
? onSuccess(packet, callResponse)
797-
: super.onFailure(packet, callResponse);
798-
}
799-
800-
@Override
801-
public NextAction onSuccess(Packet packet, CallResponse<V1beta1IngressList> callResponse) {
802-
V1beta1IngressList result = callResponse.getResult();
803-
if (result != null) {
804-
for (V1beta1Ingress ingress : result.getItems()) {
805-
String clusterName = IngressWatcher.getIngressClusterName(ingress);
806-
if (clusterName != null) {
807-
info.getIngresses().put(clusterName, ingress);
808-
}
809-
}
810-
}
811-
812-
return doNext(packet);
813-
}
814-
}
815-
816709
private static class ServiceListStep extends ResponseStep<V1ServiceList> {
817710
private final DomainPresenceInfo info;
818711

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

Lines changed: 0 additions & 68 deletions
This file was deleted.

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

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import io.kubernetes.client.models.V1PodList;
1111
import io.kubernetes.client.models.V1Service;
1212
import io.kubernetes.client.models.V1ServiceList;
13-
import io.kubernetes.client.models.V1beta1Ingress;
14-
import io.kubernetes.client.models.V1beta1IngressList;
1513
import java.io.IOException;
1614
import java.io.InputStream;
1715
import java.util.ArrayList;
@@ -122,7 +120,6 @@ public Thread newThread(Runnable r) {
122120
private static final Map<String, DomainWatcher> domainWatchers = new ConcurrentHashMap<>();
123121
private static final Map<String, EventWatcher> eventWatchers = new ConcurrentHashMap<>();
124122
private static final Map<String, ServiceWatcher> serviceWatchers = new ConcurrentHashMap<>();
125-
private static final Map<String, IngressWatcher> ingressWatchers = new ConcurrentHashMap<>();
126123

127124
static final Map<String, PodWatcher> podWatchers = new ConcurrentHashMap<>();
128125

@@ -329,7 +326,6 @@ static Step readExistingResources(String operatorNamespace, String ns) {
329326
readExistingPods(ns),
330327
readExistingEvents(ns),
331328
readExistingServices(ns),
332-
readExistingIngresses(ns),
333329
readExistingDomains(ns));
334330
}
335331

@@ -347,12 +343,6 @@ private static Step readExistingDomains(String ns) {
347343
return callBuilderFactory.create().listDomainAsync(ns, new DomainListStep(ns));
348344
}
349345

350-
private static Step readExistingIngresses(String ns) {
351-
return new CallBuilder()
352-
.withLabelSelectors(LabelConstants.DOMAINUID_LABEL, LabelConstants.CREATEDBYOPERATOR_LABEL)
353-
.listIngressAsync(ns, new IngressListStep(ns));
354-
}
355-
356346
private static Step readExistingServices(String ns) {
357347
return new CallBuilder()
358348
.withLabelSelectors(LabelConstants.DOMAINUID_LABEL, LabelConstants.CREATEDBYOPERATOR_LABEL)
@@ -466,15 +456,6 @@ private static ServiceWatcher createServiceWatcher(String ns, String initialReso
466456
isNamespaceStopping(ns));
467457
}
468458

469-
private static IngressWatcher createIngressWatcher(String ns, String initialResourceVersion) {
470-
return IngressWatcher.create(
471-
threadFactory,
472-
ns,
473-
initialResourceVersion,
474-
processor::dispatchIngressWatch,
475-
isNamespaceStopping(ns));
476-
}
477-
478459
private static DomainWatcher createDomainWatcher(String ns, String initialResourceVersion) {
479460
return DomainWatcher.create(
480461
threadFactory,
@@ -498,49 +479,6 @@ public static Collection<String> getTargetNamespaces() {
498479
return getTargetNamespaces(tuningAndConfig.get("targetNamespaces"), namespace);
499480
}
500481

501-
private static class IngressListStep extends ResponseStep<V1beta1IngressList> {
502-
private final String ns;
503-
504-
IngressListStep(String ns) {
505-
this.ns = ns;
506-
}
507-
508-
@Override
509-
public NextAction onFailure(Packet packet, CallResponse<V1beta1IngressList> callResponse) {
510-
return callResponse.getStatusCode() == CallBuilder.NOT_FOUND
511-
? onSuccess(packet, callResponse)
512-
: super.onFailure(packet, callResponse);
513-
}
514-
515-
@Override
516-
public NextAction onSuccess(Packet packet, CallResponse<V1beta1IngressList> callResponse) {
517-
@SuppressWarnings("unchecked")
518-
Map<String, DomainPresenceInfo> dpis = (Map<String, DomainPresenceInfo>) packet.get(DPI_MAP);
519-
520-
V1beta1IngressList result = callResponse.getResult();
521-
if (result != null) {
522-
for (V1beta1Ingress ingress : result.getItems()) {
523-
String domainUID = IngressWatcher.getIngressDomainUID(ingress);
524-
String clusterName = IngressWatcher.getIngressClusterName(ingress);
525-
if (domainUID != null && clusterName != null) {
526-
dpis.computeIfAbsent(domainUID, k -> new DomainPresenceInfo(ns, domainUID))
527-
.getIngresses()
528-
.put(clusterName, ingress);
529-
}
530-
}
531-
}
532-
533-
if (!ingressWatchers.containsKey(ns)) {
534-
ingressWatchers.put(ns, createIngressWatcher(ns, getInitialResourceVersion(result)));
535-
}
536-
return doNext(packet);
537-
}
538-
539-
private String getInitialResourceVersion(V1beta1IngressList result) {
540-
return result != null ? result.getMetadata().getResourceVersion() : "";
541-
}
542-
}
543-
544482
private static class DomainListStep extends ResponseStep<DomainList> {
545483
private final String ns;
546484

operator/src/main/java/oracle/kubernetes/operator/builders/WatchBuilder.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
import io.kubernetes.client.ProgressResponseBody;
1212
import io.kubernetes.client.apis.BatchV1Api;
1313
import io.kubernetes.client.apis.CoreV1Api;
14-
import io.kubernetes.client.apis.ExtensionsV1beta1Api;
1514
import io.kubernetes.client.models.V1ConfigMap;
1615
import io.kubernetes.client.models.V1Event;
1716
import io.kubernetes.client.models.V1Job;
1817
import io.kubernetes.client.models.V1Pod;
1918
import io.kubernetes.client.models.V1Service;
20-
import io.kubernetes.client.models.V1beta1Ingress;
2119
import io.kubernetes.client.util.Watch;
2220
import java.lang.reflect.ParameterizedType;
2321
import java.lang.reflect.Type;
@@ -257,51 +255,6 @@ public Call apply(ApiClient client, CallParams callParams) {
257255
}
258256
}
259257

260-
/**
261-
* Creates a web hook object to track changes to the cluster ingress
262-
*
263-
* @param namespace the namespace
264-
* @return the active web hook
265-
* @throws ApiException if there is an error on the call that sets up the web hook.
266-
*/
267-
public WatchI<V1beta1Ingress> createIngressWatch(String namespace) throws ApiException {
268-
return FACTORY.createWatch(
269-
ClientPool.getInstance(), callParams, V1beta1Ingress.class, new ListIngressCall(namespace));
270-
}
271-
272-
private class ListIngressCall implements BiFunction<ApiClient, CallParams, Call> {
273-
private String namespace;
274-
275-
ListIngressCall(String namespace) {
276-
this.namespace = namespace;
277-
}
278-
279-
@Override
280-
public Call apply(ApiClient client, CallParams callParams) {
281-
// Ensure that client doesn't time out before call or watch
282-
client.getHttpClient().setReadTimeout(callParams.getTimeoutSeconds(), TimeUnit.SECONDS);
283-
284-
try {
285-
return new ExtensionsV1beta1Api(client)
286-
.listNamespacedIngressCall(
287-
namespace,
288-
callParams.getPretty(),
289-
START_LIST,
290-
callParams.getFieldSelector(),
291-
callParams.getIncludeUninitialized(),
292-
callParams.getLabelSelector(),
293-
callParams.getLimit(),
294-
callParams.getResourceVersion(),
295-
callParams.getTimeoutSeconds(),
296-
WATCH,
297-
null,
298-
null);
299-
} catch (ApiException e) {
300-
throw new UncheckedApiException(e);
301-
}
302-
}
303-
}
304-
305258
/**
306259
* Creates a web hook object to track changes to weblogic domains in one namespaces
307260
*

0 commit comments

Comments
 (0)