Skip to content

Commit

Permalink
Fix createRuntimeClass() error path
Browse files Browse the repository at this point in the history
Errors from Client.Get() other than IsNotFound are silently ignored
instead of being propagated to the caller. Reorganize the code a bit
and add the missing error path.

Signed-off-by: Greg Kurz <groug@kaod.org>
  • Loading branch information
gkurz authored and pmores committed Jun 3, 2022
1 parent f30507b commit c2f5d5c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/openshift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ func (r *KataConfigOpenShiftReconciler) createRuntimeClass() error {

foundRc := &nodeapi.RuntimeClass{}
err := r.Client.Get(context.TODO(), types.NamespacedName{Name: rc.Name}, foundRc)
if err != nil && k8serrors.IsNotFound(err) {
if err != nil {
if !k8serrors.IsNotFound(err) {
return err
}

r.Log.Info("Creating a new RuntimeClass", "rc.Name", rc.Name)
err = r.Client.Create(context.TODO(), rc)
if err != nil {
Expand Down

0 comments on commit c2f5d5c

Please sign in to comment.