Skip to content

Commit

Permalink
fix lint error: Update is not checked (errcheck)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamasato committed Aug 21, 2022
1 parent d7f2e0d commit 5ecec4a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions controllers/mysqluser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ func (r *MySQLUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
log.Error(err, "[FetchMySQL] Failed")
mysqlUser.Status.Phase = mysqlUserPhaseNotReady
mysqlUser.Status.Reason = mysqlUserReasonMySQLFetchFailed
r.Status().Update(ctx, mysqlUser)
if serr := r.Status().Update(ctx, mysqlUser); serr != nil {
log.Error(serr, "Failed to update mysqluser status", "mysqlUser", mysqlUser.Name)
}
return ctrl.Result{}, client.IgnoreNotFound(err)
}
log.Info("[FetchMySQL] Found")
Expand All @@ -122,7 +124,9 @@ func (r *MySQLUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
if err != nil {
mysqlUser.Status.Phase = mysqlUserPhaseNotReady
mysqlUser.Status.Reason = mysqlUserReasonMySQLConnectionFailed
r.Status().Update(ctx, mysqlUser)
if serr := r.Status().Update(ctx, mysqlUser); serr != nil {
log.Error(serr, "Failed to update mysqluser status", "mysqlUser", mysqlUser.Name)
}
log.Error(err, "[MySQLClient] Failed to create")
return ctrl.Result{}, err // requeue
}
Expand All @@ -132,7 +136,9 @@ func (r *MySQLUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
mysqlUser.Status.Phase = mysqlUserPhaseNotReady
mysqlUser.Status.Reason = mysqlUserReasonMySQLConnectionFailed
log.Error(err, "[MySQLClient] Failed to connect to MySQL", "mysqlName", mysqlName)
r.Status().Update(ctx, mysqlUser)
if serr := r.Status().Update(ctx, mysqlUser); serr != nil {
log.Error(serr, "Failed to update mysqluser status", "mysqlUser", mysqlUser.Name)
}
return ctrl.Result{}, err // requeue
}
log.Info("[MySQLClient] Successfully connected")
Expand Down

0 comments on commit 5ecec4a

Please sign in to comment.