Skip to content

Commit

Permalink
fix: handle arguments in the logs (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-yu authored Oct 26, 2023
1 parent 876c5bf commit 3d3acff
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/client/restconfig/restconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func UpdateQPS(config *rest.Config) {

flowControlEnabled, err := flowcontrol.IsEnabled(ctx, config)
if err != nil {
klog.Warning("Failed to query apiserver to check for flow control enablement: %v", err)
klog.Warningf("Failed to query apiserver to check for flow control enablement: %v", err)
// Default to the lower QPS limits.
}
if flowControlEnabled {
Expand Down
12 changes: 6 additions & 6 deletions pkg/parse/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func run(ctx context.Context, p Parser, trigger string, state *reconcilerState)
gs.lastUpdate = metav1.Now()
var setSourceStatusErr error
if state.needToSetSourceStatus(gs) {
klog.V(3).Info("Updating source status (before read): %#v", gs)
klog.V(3).Infof("Updating source status (before read): %#v", gs)
setSourceStatusErr = p.setSourceStatus(ctx, gs)
if setSourceStatusErr == nil {
state.sourceStatus = gs
Expand All @@ -219,7 +219,7 @@ func run(ctx context.Context, p Parser, trigger string, state *reconcilerState)
if os.IsNotExist(err) || (err == nil && hydrate.DoneCommit(doneFilePath) != gs.commit) {
rs.message = RenderingInProgress
rs.lastUpdate = metav1.Now()
klog.V(3).Info("Updating rendering status (before read): %#v", rs)
klog.V(3).Infof("Updating rendering status (before read): %#v", rs)
setRenderingStatusErr := p.setRenderingStatus(ctx, state.renderingStatus, rs)
if setRenderingStatusErr == nil {
state.reset()
Expand All @@ -235,7 +235,7 @@ func run(ctx context.Context, p Parser, trigger string, state *reconcilerState)
rs.message = RenderingFailed
rs.lastUpdate = metav1.Now()
rs.errs = status.InternalHydrationError(err, "unable to read the done file: %s", doneFilePath)
klog.V(3).Info("Updating rendering status (before read): %#v", rs)
klog.V(3).Infof("Updating rendering status (before read): %#v", rs)
setRenderingStatusErr := p.setRenderingStatus(ctx, state.renderingStatus, rs)
if setRenderingStatusErr == nil {
state.renderingStatus = rs
Expand Down Expand Up @@ -299,7 +299,7 @@ func read(ctx context.Context, p Parser, trigger string, state *reconcilerState,
hydrationStatus.lastUpdate = metav1.Now()
// update the rendering status before source status because the parser needs to
// read and parse the configs after rendering is done and there might have errors.
klog.V(3).Info("Updating rendering status (after read): %#v", hydrationStatus)
klog.V(3).Infof("Updating rendering status (after read): %#v", hydrationStatus)
setRenderingStatusErr := p.setRenderingStatus(ctx, state.renderingStatus, hydrationStatus)
if setRenderingStatusErr == nil {
state.renderingStatus = hydrationStatus
Expand All @@ -319,7 +319,7 @@ func read(ctx context.Context, p Parser, trigger string, state *reconcilerState,
sourceStatus.lastUpdate = metav1.Now()
var setSourceStatusErr error
if state.needToSetSourceStatus(sourceStatus) {
klog.V(3).Info("Updating source status (after read): %#v", sourceStatus)
klog.V(3).Infof("Updating source status (after read): %#v", sourceStatus)
setSourceStatusErr := p.setSourceStatus(ctx, sourceStatus)
if setSourceStatusErr == nil {
state.sourceStatus = sourceStatus
Expand Down Expand Up @@ -462,7 +462,7 @@ func parseAndUpdate(ctx context.Context, p Parser, trigger string, state *reconc
lastUpdate: metav1.Now(),
}
if state.needToSetSourceStatus(newSourceStatus) {
klog.V(3).Info("Updating source status (after parse): %#v", newSourceStatus)
klog.V(3).Infof("Updating source status (after parse): %#v", newSourceStatus)
if err := p.setSourceStatus(ctx, newSourceStatus); err != nil {
// If `p.setSourceStatus` fails, we terminate the reconciliation.
// If we call `update` in this case and `update` succeeds, `Status.Source.Commit` would end up be older
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconcilermanager/controllers/reposync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func (r *RepoSyncReconciler) mapConfigMapToRepoSyncs(obj client.Object) []reconc
ctx := context.Background()
repoSyncList := &v1beta1.RepoSyncList{}
if err := r.client.List(ctx, repoSyncList, &client.ListOptions{Namespace: objRef.Namespace}); err != nil {
klog.Error("failed to list RepoSyncs for %s (%s): %v",
klog.Errorf("failed to list RepoSyncs for %s (%s): %v",
obj.GetObjectKind().GroupVersionKind().Kind, objRef, err)
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconcilermanager/controllers/rootsync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (r *RootSyncReconciler) mapConfigMapsToRootSyncs(obj client.Object) []recon
ctx := context.Background()
rootSyncList := &v1beta1.RootSyncList{}
if err := r.client.List(ctx, rootSyncList, &client.ListOptions{Namespace: objRef.Namespace}); err != nil {
klog.Error("failed to list RootSyncs for %s: %v", kinds.ObjectSummary(obj), err)
klog.Errorf("failed to list RootSyncs for %s: %v", kinds.ObjectSummary(obj), err)
return nil
}
var requests []reconcile.Request
Expand Down Expand Up @@ -557,7 +557,7 @@ func (r *RootSyncReconciler) mapObjectToRootSync(obj client.Object) []reconcile.

allRootSyncs := &v1beta1.RootSyncList{}
if err := r.client.List(context.Background(), allRootSyncs); err != nil {
klog.Error("failed to list all RootSyncs for %s (%s): %v",
klog.Errorf("failed to list all RootSyncs for %s (%s): %v",
obj.GetObjectKind().GroupVersionKind().Kind, objRef, err)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/syncer/reconcile/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *clientApplier) Create(ctx context.Context, intendedState *unstructured.
}
logErr, err := c.fights.DetectFight(time.Now(), intendedState)
if logErr {
klog.Error("Fight detected on create of %s.", description(intendedState))
klog.Errorf("Fight detected on create of %s.", description(intendedState))
}
if err == nil {
klog.V(3).Infof("Created object %v", core.GKNN(intendedState))
Expand Down

0 comments on commit 3d3acff

Please sign in to comment.