1
- // Copyright (c) 2020, 2023 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 2024 , Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .kubernetes .operator ;
@@ -154,7 +154,7 @@ private void addOperatorEventList(CoreV1EventList list) {
154
154
private void addPod (V1Pod pod ) {
155
155
String domainUid = PodHelper .getPodDomainUid (pod );
156
156
String serverName = PodHelper .getPodServerName (pod );
157
- DomainPresenceInfo info = getExistingDomainPresenceInfo (domainUid );
157
+ DomainPresenceInfo info = getOrComputeDomainPresenceInfo (domainUid );
158
158
Optional .ofNullable (info ).ifPresent (i -> i .addServerNameFromPodList (serverName ));
159
159
160
160
if (domainUid != null && serverName != null ) {
@@ -173,10 +173,6 @@ private DomainPresenceInfo getOrComputeDomainPresenceInfo(String domainUid) {
173
173
return getDomainPresenceInfoMap ().computeIfAbsent (domainUid , k -> new DomainPresenceInfo (namespace , domainUid ));
174
174
}
175
175
176
- private DomainPresenceInfo getExistingDomainPresenceInfo (String domainUid ) {
177
- return getDomainPresenceInfoMap ().get (domainUid );
178
- }
179
-
180
176
private Map <String , DomainPresenceInfo > getDomainPresenceInfoMap () {
181
177
return processor .getDomainPresenceInfoMap ().computeIfAbsent (namespace , k -> new ConcurrentHashMap <>());
182
178
}
@@ -192,7 +188,7 @@ private void addServiceList(V1ServiceList list) {
192
188
private void addService (V1Service service ) {
193
189
String domainUid = ServiceHelper .getServiceDomainUid (service );
194
190
if (domainUid != null ) {
195
- ServiceHelper .addToPresence (getExistingDomainPresenceInfo (domainUid ), service );
191
+ ServiceHelper .addToPresence (getOrComputeDomainPresenceInfo (domainUid ), service );
196
192
}
197
193
}
198
194
@@ -203,7 +199,7 @@ private void addPodDisruptionBudgetList(V1PodDisruptionBudgetList list) {
203
199
private void addPodDisruptionBudget (V1PodDisruptionBudget pdb ) {
204
200
String domainUid = PodDisruptionBudgetHelper .getDomainUid (pdb );
205
201
if (domainUid != null ) {
206
- PodDisruptionBudgetHelper .addToPresence (getExistingDomainPresenceInfo (domainUid ), pdb );
202
+ PodDisruptionBudgetHelper .addToPresence (getOrComputeDomainPresenceInfo (domainUid ), pdb );
207
203
}
208
204
}
209
205
@@ -231,7 +227,8 @@ private void addDomain(DomainResource domain) {
231
227
DomainPresenceInfo cachedInfo = getDomainPresenceInfoMap ().get (domain .getDomainUid ());
232
228
if (domain .getStatus () == null ) {
233
229
newDomainNames .add (domain .getDomainUid ());
234
- } else if (cachedInfo != null && domain .isGenerationChanged (cachedInfo .getDomain ())) {
230
+ } else if (cachedInfo != null && cachedInfo .getDomain () != null
231
+ && domain .isGenerationChanged (cachedInfo .getDomain ())) {
235
232
modifiedDomainNames .add (domain .getDomainUid ());
236
233
}
237
234
getOrComputeDomainPresenceInfo (domain .getDomainUid ()).setDomain (domain );
0 commit comments