Skip to content

Commit 8f96855

Browse files
committed
Webhook handle lack of permission and skip installing webhook secret for operatorOnly
1 parent f19a864 commit 8f96855

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

kubernetes/charts/weblogic-operator/templates/_operator-secret.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorSecrets" }}
5+
{{- if not .webhookOnly }}
56
---
67
apiVersion: "v1"
78
kind: "Secret"
@@ -22,6 +23,8 @@ metadata:
2223
name: "weblogic-operator-secrets"
2324
namespace: {{ .Release.Namespace | quote }}
2425
type: "Opaque"
26+
{{- end }}
27+
{{- if not .operatorOnly }}
2528
---
2629
apiVersion: "v1"
2730
kind: "Secret"
@@ -44,3 +47,4 @@ metadata:
4447
namespace: {{ .Release.Namespace | quote }}
4548
type: "Opaque"
4649
{{- end }}
50+
{{- end }}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.helpers;
@@ -263,7 +263,8 @@ protected NextAction onFailureNoRetry(Packet packet,
263263
CallResponse<V1ValidatingWebhookConfiguration> callResponse) {
264264
LOGGER.info(MessageKeys.READ_VALIDATING_WEBHOOK_CONFIGURATION_FAILED,
265265
VALIDATING_WEBHOOK_NAME, callResponse.getE().getResponseBody());
266-
return super.onFailureNoRetry(packet, callResponse);
266+
return isNotAuthorizedOrForbidden(callResponse)
267+
? doNext(packet) : super.onFailureNoRetry(packet, callResponse);
267268
}
268269
}
269270

@@ -284,7 +285,8 @@ protected NextAction onFailureNoRetry(Packet packet,
284285
CallResponse<V1ValidatingWebhookConfiguration> callResponse) {
285286
LOGGER.info(MessageKeys.CREATE_VALIDATING_WEBHOOK_CONFIGURATION_FAILED,
286287
VALIDATING_WEBHOOK_NAME, callResponse.getE().getResponseBody());
287-
return super.onFailureNoRetry(packet, callResponse);
288+
return isNotAuthorizedOrForbidden(callResponse)
289+
? doNext(packet) : super.onFailureNoRetry(packet, callResponse);
288290
}
289291
}
290292

@@ -318,7 +320,8 @@ protected NextAction onFailureNoRetry(Packet packet,
318320
CallResponse<V1ValidatingWebhookConfiguration> callResponse) {
319321
LOGGER.info(MessageKeys.REPLACE_VALIDATING_WEBHOOK_CONFIGURATION_FAILED,
320322
VALIDATING_WEBHOOK_NAME, callResponse.getE().getResponseBody());
321-
return super.onFailureNoRetry(packet, callResponse);
323+
return isNotAuthorizedOrForbidden(callResponse)
324+
? doNext(packet) : super.onFailureNoRetry(packet, callResponse);
322325
}
323326
}
324327

0 commit comments

Comments
 (0)