Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor error info #409

Open
zhengxiexie opened this issue Nov 27, 2023 · 1 comment
Open

refactor error info #409

zhengxiexie opened this issue Nov 27, 2023 · 1 comment

Comments

@zhengxiexie
Copy link
Contributor

zhengxiexie commented Nov 27, 2023

Now, log.Error is everywhere, both inside(service and utils module etc) and outside layer(controller module).
Suggest only putting err = fmt.Errorf("context info: %v", err) in inside layer, and not putting log.Error(err).
Put log.Error(err) in outside layer. In this way it could avoid much redundancy error info.

@zhengxiexie
Copy link
Contributor Author

2023-11-27 04:31:47.522 ERROR securitypolicy/builder.go:78 failed to build rule and groups {"rule": {"action":"allow","direction":"in","ports":[{"protocol":"TCP","port":"web-port"}]}, "ruleIndex": 0, "error": "no pod has the corresponding named port"} github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/securitypolicy.(*SecurityPolicyService).buildSecurityPolicy /root/nsx-operator/pkg/nsx/services/securitypolicy/builder.go:78 github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/securitypolicy.(*SecurityPolicyService).DeleteSecurityPolicy /root/nsx-operator/pkg/nsx/services/securitypolicy/firewall.go:247 github.com/vmware-tanzu/nsx-operator/pkg/controllers/securitypolicy.(*SecurityPolicyReconciler).Reconcile /root/nsx-operator/pkg/controllers/securitypolicy/securitypolicy_controller.go:139 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:122 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:323 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:274 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2 /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:235 2023-11-27 04:31:47.522 ERROR securitypolicy/firewall.go:250 failed to build nsx SecurityPolicy in deleting {"error": "no pod has the corresponding named port"} github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/securitypolicy.(*SecurityPolicyService).DeleteSecurityPolicy /root/nsx-operator/pkg/nsx/services/securitypolicy/firewall.go:250 github.com/vmware-tanzu/nsx-operator/pkg/controllers/securitypolicy.(*SecurityPolicyReconciler).Reconcile /root/nsx-operator/pkg/controllers/securitypolicy/securitypolicy_controller.go:139 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:122 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:323 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:274 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2 /root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant