Skip to content

Commit 87db68d

Browse files
Remove message from Runtime SDK FailureResponses
Signed-off-by: killianmuldoon <[email protected]>
1 parent 1ec0cd6 commit 87db68d

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

internal/runtime/client/client.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ func (c *client) Discover(ctx context.Context, extensionConfig *runtimev1.Extens
142142

143143
// Check to see if the response is a failure and handle the failure accordingly.
144144
if response.GetStatus() == runtimehooksv1.ResponseStatusFailure {
145-
return nil, errors.Errorf("failed to discover extension %q: got failure response with message %q", extensionConfig.Name, response.GetMessage())
145+
log.Info(fmt.Sprintf("failed to discover extension %q: got failure response with message %v", extensionConfig.Name, response.GetMessage()))
146+
// Don't add the message to the error as it is may be unique causing too many reconciliations. Ref: https://github.com/kubernetes-sigs/cluster-api/issues/6921
147+
return nil, errors.Errorf("failed to discover extension %q: got failure response", extensionConfig.Name)
146148
}
147149

148150
// Check to see if the response is valid.
@@ -364,8 +366,9 @@ func (c *client) CallExtension(ctx context.Context, hook runtimecatalog.Hook, fo
364366

365367
// If the received response is a failure then return an error.
366368
if response.GetStatus() == runtimehooksv1.ResponseStatusFailure {
367-
log.Error(err, "extension handler returned a failure response")
368-
return errors.Errorf("failed to call extension handler %q: got failure response with message %q", name, response.GetMessage())
369+
log.Info(fmt.Sprintf("failed to call extension handler %q: got failure response with message %v", name, response.GetMessage()))
370+
// Don't add the message to the error as it is may be unique causing too many reconciliations. Ref: https://github.com/kubernetes-sigs/cluster-api/issues/6921
371+
return errors.Errorf("failed to call extension handler %q: got failure response", name)
369372
}
370373

371374
if retryResponse, ok := response.(runtimehooksv1.RetryResponseObject); ok && retryResponse.GetRetryAfterSeconds() != 0 {

internal/runtime/utils/error.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package utils
2+
3+
import "github.com/pkg/errors"
4+
5+
type VariableNotFoundErr struct {
6+
err error
7+
}
8+
9+
func variableNotFoundError(err error) VariableNotFoundErr {
10+
return VariableNotFoundErr{
11+
err: err,
12+
}
13+
}
14+
15+
func (v VariableNotFoundErr) Error() string {
16+
return v.err.Error()
17+
}
18+
19+
func (VariableNotFoundErr) Cause() error {
20+
return errors.New("variable not found")
21+
}
22+
23+
func IsVariableNotFoundErr(e error) bool {
24+
(errors.As(e))
25+
}

0 commit comments

Comments
 (0)