Skip to content

Commit

Permalink
Merge pull request #64 from form3tech-oss/mike-logging-set-debug
Browse files Browse the repository at this point in the history
chore: Change noisy log messages to debug level
  • Loading branch information
miketonks-form3 authored Dec 11, 2023
2 parents 2eb86b6 + 1643e63 commit 161f9ef
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 92 deletions.
6 changes: 3 additions & 3 deletions api/v1alpha1/schedule_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ webhook.Defaulter = &Schedule{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (in *Schedule) Default() {
schedulelog.Info("default", "name", in.Name)
schedulelog.V(1).Info("default", "name", in.Name)
in.Spec.ConcurrencyPolicy.Default()
}

Expand All @@ -47,13 +47,13 @@ var _ webhook.Validator = &Schedule{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (in *Schedule) ValidateCreate() (admission.Warnings, error) {
schedulelog.Info("validate create", "name", in.Name)
schedulelog.V(1).Info("validate create", "name", in.Name)
return in.Validate()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *Schedule) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
schedulelog.Info("validate update", "name", in.Name)
schedulelog.V(1).Info("validate update", "name", in.Name)
return in.Validate()
}

Expand Down
156 changes: 78 additions & 78 deletions api/v1alpha1/zz_generated.chaosmesh.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cmd/chaos-builder/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ func (in *{{.Type}}) IsOneShot() bool {
var {{.Type}}WebhookLog = logf.Log.WithName("{{.Type}}-resource")
func (in *{{.Type}}) ValidateCreate() (admission.Warnings, error) {
{{.Type}}WebhookLog.Info("validate create", "name", in.Name)
{{.Type}}WebhookLog.V(1).Info("validate create", "name", in.Name)
return in.Validate()
}
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (in *{{.Type}}) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
{{.Type}}WebhookLog.Info("validate update", "name", in.Name)
{{.Type}}WebhookLog.V(1).Info("validate update", "name", in.Name)
{{- if not .EnableUpdate}}
if !reflect.DeepEqual(in.Spec, old.(*{{.Type}}).Spec) {
return nil, ErrCanNotUpdateChaos
Expand All @@ -170,7 +170,7 @@ func (in *{{.Type}}) ValidateUpdate(old runtime.Object) (admission.Warnings, err
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (in *{{.Type}}) ValidateDelete() (admission.Warnings, error) {
{{.Type}}WebhookLog.Info("validate delete", "name", in.Name)
{{.Type}}WebhookLog.V(1).Info("validate delete", "name", in.Name)
// Nothing to do?
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion controllers/common/condition/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
})
}

r.Log.Info("updating conditions", "conditions", conditions)
r.Log.V(1).Info("updating conditions", "conditions", conditions)
obj := r.Object.DeepCopyObject().(v1alpha1.InnerObject)

if err := r.Client.Get(ctx, req.NamespacedName, obj); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions controllers/common/desiredphase/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (info *reconcileInfo) CalcDesiredPhase() (v1alpha1.DesiredPhase, []recorder
func (info *reconcileInfo) Reconcile(req ctrl.Request) (ctrl.Result, error) {
desiredPhase, events := info.CalcDesiredPhase()

info.Log.Info("modify desiredPhase", "desiredPhase", desiredPhase)
info.Log.V(1).Info("modify desiredPhase", "desiredPhase", desiredPhase)
if info.obj.GetStatus().Experiment.DesiredPhase != desiredPhase {
for _, ev := range events {
info.Recorder.Event(info.obj, ev)
Expand All @@ -142,7 +142,7 @@ func (info *reconcileInfo) Reconcile(req ctrl.Request) (ctrl.Result, error) {

if obj.GetStatus().Experiment.DesiredPhase != desiredPhase {
obj.GetStatus().Experiment.DesiredPhase = desiredPhase
info.Log.Info("update object", "namespace", obj.GetNamespace(), "name", obj.GetName())
info.Log.V(1).Info("update object", "namespace", obj.GetNamespace(), "name", obj.GetName())
return info.Client.Update(context.TODO(), obj)
}

Expand Down
3 changes: 3 additions & 0 deletions controllers/common/finalizers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type InitReconciler struct {
func (r *InitReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
obj := r.Object.DeepCopyObject().(v1alpha1.InnerObject)

r.Log.Info("init reconciler -> Reconcile")
if err := r.Client.Get(context.TODO(), req.NamespacedName, obj); err != nil {
if apierrors.IsNotFound(err) {
r.Log.Info("chaos not found")
Expand Down Expand Up @@ -90,6 +91,8 @@ type CleanReconciler struct {
func (r *CleanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
obj := r.Object.DeepCopyObject().(v1alpha1.InnerObject)

r.Log.Info("clean reconciler -> Reconcile")

if err := r.Client.Get(context.TODO(), req.NamespacedName, obj); err != nil {
if apierrors.IsNotFound(err) {
r.Log.Info("chaos not found")
Expand Down
2 changes: 1 addition & 1 deletion controllers/common/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (p *Pipeline) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result
return ctrl.Result{}, err
}

p.ctx.Logger.WithName("pipeline").Info("reconcile result", "result", ret)
p.ctx.Logger.WithName("pipeline").V(1).Info("reconcile result", "result", ret)

if ret.Requeue || deadline != nil && deadline.Before(time.Now()) {
ret.Requeue = true
Expand Down
5 changes: 3 additions & 2 deletions controllers/common/records/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
needRetry := false
for index, record := range records {
var err error

idLogger := logger.WithValues("id", records[index].Id)
idLogger.Info("iterating record", "record", record, "desiredPhase", desiredPhase)
idLogger.V(1).Info("iterating record", "record", record, "desiredPhase", desiredPhase)

// The whole running logic is a cycle:
// Not Injected -> Not Injected/* -> Injected -> Injected/* -> Not Injected
Expand Down Expand Up @@ -217,7 +218,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}
if shouldUpdate {
updateError := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
logger.Info("updating records", "records", records)
logger.V(1).Info("updating records", "records", records)
obj := r.Object.DeepCopyObject().(v1alpha1.InnerObjectWithSelector)

if err := r.Client.Get(context.TODO(), req.NamespacedName, obj); err != nil {
Expand Down
2 changes: 0 additions & 2 deletions controllers/multicluster/remotechaos/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ var remotePredicates = predicate.Funcs{
}

if obj.GetRemoteCluster() == "" {
fmt.Println("remote cluster is empty")
return false
}

Expand All @@ -121,7 +120,6 @@ var remotePredicates = predicate.Funcs{
}

if obj.GetRemoteCluster() == "" {
fmt.Println("remote cluster is empty")
return false
}

Expand Down

0 comments on commit 161f9ef

Please sign in to comment.