You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c50f673
Browse filesBrowse the repository at this point in the historyBrowse files
fix: event recorder aggregation, long names and cluster scoped events (#3665)
Correctness fixes of the event recorder, found while reviewing the virtual
thread support (#3664).
- Aggregating onto a named event now updates its type, reason and action
along with the count, last timestamp and message, so a Warning repeated
under the name of a Normal event is no longer reported as the Normal one.
An occurrence without an action clears the earlier action, except on an
event that carries an eventTime, where the reason stands in for it, as the
API server requires an action for such events. The API server only makes
these fields immutable for events.k8s.io/v1, not for the core API the sink
writes to.
- Supplied event names longer than the Kubernetes limit are shortened with a
hash of the full name instead of being plainly truncated, so distinct names
sharing a long prefix no longer merge into one event. Trailing '-' and '.'
are stripped before the hash is appended, for supplied and generated names
alike, so a name is never cut into an invalid "...-.<hash>".
- Events about cluster scoped resources in the kube-system namespace carry an
eventTime and an action (defaulting to the reason), which is what the API
server requires to accept them there. Events in the default namespace are
unchanged. The API server rejects such events in any other namespace, so the
javadocs and docs no longer suggest the namespace the operator runs in.
Tests: regression and unit tests, a kube-api-test based
DefaultEventRecorderIntegrationTest recording events against a real API
server, and ITs for cluster scoped resources in default and kube-system.
Copy file name to clipboardExpand all lines: docs/content/en/docs/documentation/operations/configuration.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -379,7 +379,7 @@ All operator-level keys are prefixed with `josdk.`.
379
379
380
380
| Key | Type | Description |
381
381
|---|---|---|
382
-
|`josdk.events.cluster-scoped-namespace`|`String`| Namespace to record events about cluster scoped resources in (defaults to `default`) |
382
+
|`josdk.events.cluster-scoped-namespace`|`String`| Namespace to record events about cluster scoped resources in (defaults to `default`); the API server only accepts `default` and `kube-system`|
383
383
384
384
Recording events requires the operator's service account to be allowed `get`, `create` and `patch` on
385
385
`events` in the core (`""`) API group. All three are used: an event that does not exist yet is
@@ -395,6 +395,11 @@ therefore has to grant the permission in every namespace events are recorded in
395
395
`default`, or whatever `josdk.events.cluster-scoped-namespace` is set to, if the operator reconciles
396
396
cluster scoped resources. A `ClusterRole` covers all of them at once.
397
397
398
+
The API server only accepts events about cluster scoped objects in the `default` and `kube-system`
399
+
namespaces, so those are the only values `josdk.events.cluster-scoped-namespace` can usefully be set
400
+
to. In particular, the namespace the operator itself runs in is rejected, and the event dropped with
401
+
a warning in the operator log.
402
+
398
403
#### Leader Election
399
404
400
405
Leader election is activated when at least one `josdk.leader-election.*` key is present.
Copy file name to clipboardExpand all lines: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -201,8 +201,8 @@ public ConfigurationServiceOverrider withLeaderElectionConfiguration(
201
201
202
202
/**
203
203
* Sets the namespace in which Kubernetes events about cluster scoped resources are recorded. Use
204
-
* this when the operator is not allowed to create events in the {@code default} namespace,
205
-
* passing for example the namespace the operator itself runs in.
204
+
* this when the operator is not allowed to create events in the {@code default} namespace. The
205
+
* API server only accepts {@code default} and {@code kube-system} for such events.
206
206
*
207
207
* @param namespace the namespace to record events about cluster scoped resources in
208
208
* @return this {@link ConfigurationServiceOverrider} for chained customization
0 commit comments