Skip to content

Commit 2d2cbaf

Browse files
Remove 'terminal error:' prefix from status messages
When TerminalError is used, unwrap it before showing the error message in status conditions. This prevents the 'terminal error:' prefix from appearing in user-facing messages. Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 2a1536a commit 2d2cbaf

4 files changed

Lines changed: 17 additions & 83 deletions

File tree

internal/operator-controller/controllers/clusterextension_controller.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,17 @@ func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager, opts ...
455455
}
456456

457457
func wrapErrorWithResolutionInfo(resolved ocv1.BundleMetadata, err error) error {
458-
wrappedErr := fmt.Errorf("error for resolved bundle %q with version %q: %w", resolved.Name, resolved.Version, err)
459-
// Preserve TerminalError type if the original error was terminal
458+
// Preserve TerminalError type through wrapping by re-wrapping after adding context
460459
if errors.Is(err, reconcile.TerminalError(nil)) {
460+
// Unwrap to get the inner error, add context, then re-wrap as TerminalError
461+
innerErr := err
462+
if unwrapped := errors.Unwrap(err); unwrapped != nil {
463+
innerErr = unwrapped
464+
}
465+
wrappedErr := fmt.Errorf("error for resolved bundle %q with version %q: %w", resolved.Name, resolved.Version, innerErr)
461466
return reconcile.TerminalError(wrappedErr)
462467
}
463-
return wrappedErr
468+
return fmt.Errorf("error for resolved bundle %q with version %q: %w", resolved.Name, resolved.Version, err)
464469
}
465470

466471
// Generate reconcile requests for all cluster extensions affected by a catalog change

internal/operator-controller/controllers/common_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ func setStatusProgressing(ext *ocv1.ClusterExtension, err error) {
155155

156156
if err != nil {
157157
progressingCond.Reason = ocv1.ReasonRetrying
158-
progressingCond.Message = err.Error()
158+
// Unwrap TerminalError to avoid "terminal error:" prefix in message
159+
innerErr := err
160+
if errors.Is(err, reconcile.TerminalError(nil)) {
161+
if unwrapped := errors.Unwrap(err); unwrapped != nil {
162+
innerErr = unwrapped
163+
}
164+
}
165+
progressingCond.Message = innerErr.Error()
159166
}
160167

161168
if errors.Is(err, reconcile.TerminalError(nil)) {

internal/operator-controller/controllers/common_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestSetStatusProgressing(t *testing.T) {
5353
Type: ocv1.TypeProgressing,
5454
Status: metav1.ConditionFalse,
5555
Reason: ocv1.ReasonBlocked,
56-
Message: "terminal error: boom",
56+
Message: "boom",
5757
},
5858
},
5959
} {

test/e2e/features/install.feature

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -243,84 +243,6 @@ Feature: Install ClusterExtension
243243
And ClusterExtension is available
244244
And operator "own-namespace-operator" target namespace is "${TEST_NAMESPACE}"
245245

246-
@SingleOwnNamespaceInstallSupport
247-
Scenario: Reject invalid watchNamespace format (DNS-1123 violation)
248-
Given ServiceAccount "olm-admin" in test namespace is cluster admin
249-
And resource is applied
250-
"""
251-
apiVersion: v1
252-
kind: Namespace
253-
metadata:
254-
name: single-namespace-operator-target
255-
"""
256-
When ClusterExtension is applied
257-
"""
258-
apiVersion: olm.operatorframework.io/v1
259-
kind: ClusterExtension
260-
metadata:
261-
name: ${NAME}
262-
spec:
263-
namespace: ${TEST_NAMESPACE}
264-
serviceAccount:
265-
name: olm-admin
266-
config:
267-
configType: Inline
268-
inline:
269-
watchNamespace: ${TEST_NAMESPACE}- # trailing '-' violates DNS-1123
270-
source:
271-
sourceType: Catalog
272-
catalog:
273-
packageName: single-namespace-operator
274-
selector:
275-
matchLabels:
276-
"olm.operatorframework.io/metadata.name": test-catalog
277-
"""
278-
Then ClusterExtension reports Progressing as False with Reason Blocked and Message includes:
279-
"""
280-
invalid ClusterExtension configuration: invalid configuration: invalid namespace name
281-
"""
282-
And ClusterExtension reports Installed as False with Reason Failed and Message:
283-
"""
284-
No bundle installed
285-
"""
286-
287-
@SingleOwnNamespaceInstallSupport
288-
@WebhookProviderCertManager
289-
Scenario: Reject watchNamespace for operator that does not support Single/OwnNamespace install modes
290-
Given ServiceAccount "olm-admin" in test namespace is cluster admin
291-
When ClusterExtension is applied
292-
"""
293-
apiVersion: olm.operatorframework.io/v1
294-
kind: ClusterExtension
295-
metadata:
296-
name: ${NAME}
297-
spec:
298-
namespace: ${TEST_NAMESPACE}
299-
serviceAccount:
300-
name: olm-admin
301-
config:
302-
configType: Inline
303-
inline:
304-
watchNamespace: ${TEST_NAMESPACE}
305-
source:
306-
sourceType: Catalog
307-
catalog:
308-
packageName: webhook-operator
309-
selector:
310-
matchLabels:
311-
"olm.operatorframework.io/metadata.name": test-catalog
312-
"""
313-
Then ClusterExtension reports Progressing as False with Reason Blocked and Message includes:
314-
"""
315-
error for resolved bundle "webhook-operator.1.0.0" with version "1.0.0":
316-
invalid ClusterExtension configuration: invalid configuration:
317-
additionalProperties 'watchNamespace' not allowed
318-
"""
319-
And ClusterExtension reports Installed as False with Reason Failed and Message:
320-
"""
321-
No bundle installed
322-
"""
323-
324246
@WebhookProviderCertManager
325247
Scenario: Install operator having webhooks
326248
Given ServiceAccount "olm-admin" in test namespace is cluster admin

0 commit comments

Comments
 (0)