Skip to content

Commit

Permalink
Patch for configcheck status (kube-logging#820)
Browse files Browse the repository at this point in the history
* Patch logging status in configcheck instead of updating

* Enable go in goland
  • Loading branch information
pepov authored Sep 9, 2021
1 parent bf3c548 commit a1db89a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .idea/logging-operator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pkg/resources/fluentd/fluentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func New(client client.Client, log logr.Logger,
// Reconcile reconciles the fluentd resource
func (r *Reconciler) Reconcile() (*reconcile.Result, error) {
ctx := context.Background()
patchBase := client.MergeFrom(r.Logging.DeepCopy())

for _, res := range []resources.Resource{
r.serviceAccount,
Expand Down Expand Up @@ -155,8 +156,8 @@ func (r *Reconciler) Reconcile() (*reconcile.Result, error) {
for _, removedHash := range removedHashes {
delete(r.Logging.Status.ConfigCheckResults, removedHash)
}
if err := r.Client.Status().Update(ctx, r.Logging); err != nil {
return nil, errors.WrapWithDetails(err, "failed to update status", "logging", r.Logging)
if err := r.Client.Status().Patch(ctx, r.Logging, patchBase); err != nil {
return nil, errors.WrapWithDetails(err, "failed to patch status", "logging", r.Logging)
} else {
// explicitly ask for a requeue to short circuit the controller loop after the status update
return &reconcile.Result{Requeue: true}, nil
Expand All @@ -173,8 +174,8 @@ func (r *Reconciler) Reconcile() (*reconcile.Result, error) {
}
if result.Ready {
r.Logging.Status.ConfigCheckResults[hash] = result.Valid
if err := r.Client.Status().Update(ctx, r.Logging); err != nil {
return nil, errors.WrapWithDetails(err, "failed to update status", "logging", r.Logging)
if err := r.Client.Status().Patch(ctx, r.Logging, patchBase); err != nil {
return nil, errors.WrapWithDetails(err, "failed to patch status", "logging", r.Logging)
} else {
// explicitly ask for a requeue to short circuit the controller loop after the status update
return &reconcile.Result{Requeue: true}, nil
Expand Down

0 comments on commit a1db89a

Please sign in to comment.