Skip to content

Commit c0694c4

Browse files
committed
handle the missing mlmd service-ca cert gracefully
When mlmd is being reconciled, it expects a secret with certs that is created by the service-ca (when podtopodtls is enabled). This is an expected outcome, so we should not be reporting stacktraces for this. This change instead catches this scenario via a custom error for such lagging dependencies, and logs it at info level without a stack trace. Signed-off-by: Humair Khan <[email protected]>
1 parent 24f564b commit c0694c4

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

controllers/dspipeline_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223

2324
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/dspastatus"
@@ -313,7 +314,14 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
313314
err = r.ReconcileMLMD(ctx, dspa, params)
314315
if err != nil {
315316
r.setStatusAsNotReady(config.MLMDProxyReady, err, dspaStatus.SetMLMDProxyStatus)
316-
return ctrl.Result{}, err
317+
// TODO: this (and other components) should handle these scenarios via states or statuses instead of error
318+
var depErr *util.LaggingDependencyCreationError
319+
if errors.As(err, &depErr) {
320+
log.Info(depErr.Message)
321+
return ctrl.Result{}, nil
322+
} else {
323+
return ctrl.Result{}, err
324+
}
317325
} else {
318326
r.setStatus(ctx, params.MlmdProxyDefaultResourceName, config.MLMDProxyReady, dspa,
319327
dspaStatus.SetMLMDProxyStatus, log)

controllers/mlmd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package controllers
1717

1818
import (
1919
"context"
20-
"errors"
2120
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
21+
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/util"
2222
)
2323

2424
const (
@@ -72,9 +72,8 @@ func (r *DSPAReconciler) ReconcileMLMD(ctx context.Context, dsp *dspav1alpha1.Da
7272
if err != nil {
7373
return err
7474
}
75-
7675
if !certificatesExist {
77-
return errors.New("secret containing the certificate for MLMD gRPC Server was not created yet")
76+
return &util.LaggingDependencyCreationError{Message: "mlmd gRPC Server cert secret not found, this is likely because it has not been created yet"}
7877
}
7978
}
8079

controllers/util/err.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package util
18+
19+
import (
20+
"fmt"
21+
)
22+
23+
// LaggingDependencyCreationError should be used if a dependency that is
24+
// created by a third party is not found (e.g. service-ca secrets).
25+
type LaggingDependencyCreationError struct {
26+
Message string
27+
}
28+
29+
func (e *LaggingDependencyCreationError) Error() string {
30+
return fmt.Sprintf("Missing dependency error: %s", e.Message)
31+
}

0 commit comments

Comments
 (0)