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

Remove glog #527

Merged

Conversation

adrianchiris
Copy link
Collaborator

@adrianchiris adrianchiris commented Oct 22, 2023

Remove the use of glog package.
use controller-runtime logging & zap instead.

  • Remove glog from cmds
  • Remove glog from tests
  • Remove glog from pkgs (multiple packages, see below)
    • webhook
    • daemon
    • host
    • leaderelection
    • plugins
    • service
    • systemd
    • utils
  • remove glog flags from bindata/manifests

roughly 460 substitutions required.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

coveralls commented Oct 22, 2023

Pull Request Test Coverage Report for Build 6643614723

  • 58 of 544 (10.66%) changed or added relevant lines in 24 files are covered.
  • 20 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.05%) to 25.568%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/daemon/event_recorder.go 0 1 0.0%
pkg/service/utils.go 0 1 0.0%
pkg/webhook/client.go 0 1 0.0%
pkg/webhook/config.go 0 1 0.0%
pkg/webhook/validate.go 7 8 87.5%
pkg/plugins/intel/intel_plugin.go 0 2 0.0%
pkg/utils/cluster.go 0 3 0.0%
pkg/utils/store.go 0 3 0.0%
pkg/webhook/mutate.go 0 5 0.0%
pkg/daemon/plugin.go 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/daemon/daemon.go 1 39.45%
pkg/plugins/mellanox/mellanox_plugin.go 1 0.0%
pkg/utils/utils_mlx.go 1 0.0%
controllers/sriovnetwork_controller.go 4 70.68%
pkg/utils/utils.go 4 7.44%
pkg/utils/utils_virtual.go 4 13.64%
pkg/plugins/generic/generic_plugin.go 5 42.23%
Totals Coverage Status
Change from base Build 6639207535: -0.05%
Covered Lines: 2331
Relevant Lines: 9117

💛 - Coveralls

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

1 similar comment
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

2 similar comments
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

1 similar comment
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@adrianchiris adrianchiris changed the title [WIP] Remove glog Remove glog Oct 25, 2023
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

1 similar comment
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

- create new log pkg to handle log initialization and setup
- update operator, daemon and webhook log setup and init logic

Signed-off-by: adrianc <adrianc@nvidia.com>
Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime log

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime log

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime logs

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime logs

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime log

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime logs

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime logs

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime logs

Signed-off-by: adrianc <adrianc@nvidia.com>
remove glog flags from manifest

Signed-off-by: adrianc <adrianc@nvidia.com>
update logs to use controller-runtime  logs

Signed-off-by: adrianc <adrianc@nvidia.com>
Signed-off-by: adrianc <adrianc@nvidia.com>
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@adrianchiris
Copy link
Collaborator Author

/test-all

@adrianchiris
Copy link
Collaborator Author

@SchSeba @zeeke PTAL

I have tested the change locally, PR rebased against master.

@adrianchiris
Copy link
Collaborator Author

Sample log from sriov config daemon:

2023-10-30T12:54:10.942768056Z  INFO    sriov-network-config-daemon     cobra/command.go:916    starting node writer
2023-10-30T12:54:10.962508147Z  INFO    sriov-network-config-daemon     cobra/command.go:916    Running on      {"platform": "Baremetal"}
2023-10-30T12:54:10.985544359Z  INFO    sriov-network-config-daemon/start.go:199        RunOnce()
2023-10-30T12:54:10.985637169Z  INFO    sriov-network-config-daemon/start.go:199        RunOnce(): first poll for nic status
2023-10-30T12:54:11.138692558Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T12:54:11.138817271Z  INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.0 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T12:54:11.138928432Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T12:54:11.138948937Z  INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.1 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T12:54:11.161606628Z  ERROR   utils/utils.go:163      getNetDevLinkSpeed(): fail to read Link Speed file      {"path": "/sys/class/net/enp129s0np0/speed", "error": "read /sys/class/net/enp129s0np0/speed: invalid argument"}
2023-10-30T12:54:11.168304929Z  INFO    daemon/writer.go:155    setNodeStateStatus(): status    {"sync-status": "", "last-sync-error": ""}
2023-10-30T12:54:11.190098177Z  INFO    daemon/writer.go:91     writeCheckpointFile(): try to decode the checkpoint file
2023-10-30T12:54:11.190385942Z  INFO    sriov-network-config-daemon     cobra/command.go:916    Starting SriovNetworkConfigDaemon
2023-10-30T12:54:11.190521775Z  INFO    sriov-network-config-daemon/start.go:220        Run()   {"node": "cloud-dev-44"}
2023-10-30T12:54:11.190566418Z  INFO    sriov-network-config-daemon/start.go:220        Run(): start daemon.
2023-10-30T12:54:11.190546985Z  INFO    runtime/asm_amd64.s:1598        Run(): start writer
2023-10-30T12:54:11.220722316Z  INFO    host/host.go:160        IsRHELSystem(): checking for RHEL machine
2023-10-30T12:54:11.220819078Z  INFO    host/host.go:171        IsUbuntuSystem(): checking for Ubuntu machine
2023-10-30T12:54:11.224171987Z  INFO    host/host.go:181        GetOSPrettyName(): getting os name from os-release file
2023-10-30T12:54:11.229748973Z  ERROR   daemon/daemon.go:217    tryEnableRdma(): failed to check OS name        {"error": "failed to find pretty operating system name"}
2023-10-30T12:54:11.229797893Z  INFO    host/host.go:127        LoadKernelModule(): try to load kernel module   {"name": "tun", "args": []}
2023-10-30T12:54:11.229823325Z  INFO    host/host.go:85 IsKernelModuleLoaded(): check if kernel module is loaded        {"name": "tun"}
2023-10-30T12:54:11.248953099Z  INFO    host/host.go:133        LoadKernelModule(): try to load kernel module   {"name": "vhost_net", "args": []}
2023-10-30T12:54:11.248996837Z  INFO    host/host.go:85 IsKernelModuleLoaded(): check if kernel module is loaded        {"name": "vhost_net"}
2023-10-30T12:54:11.297030525Z  INFO    daemon/daemon.go:429    Set log verbose level   {"new-level": -2, "current-level": 0}
2023-10-30T12:54:11.303536825Z  LEVEL(-2)       daemon/daemon.go:384    nodeUpdateHandler(): node is now drainable
2023-10-30T12:54:16.395449829Z  INFO    sriov-network-config-daemon/start.go:220        Starting workers
2023-10-30T12:54:16.395539681Z  INFO    sriov-network-config-daemon/start.go:220        Started workers
2023-10-30T12:54:16.395595008Z  LEVEL(-2)       daemon/daemon.go:319    processNextWorkItem     {"worker-queue-size": 1}
2023-10-30T12:54:16.395714341Z  LEVEL(-2)       daemon/daemon.go:319    get item from queue     {"item": 6}
2023-10-30T12:54:16.402562076Z  INFO    daemon/daemon.go:358    nodeStateSyncHandler(): new generation  {"generation": 6}
2023-10-30T12:54:16.402647605Z  INFO    runtime/asm_amd64.s:1598        Run(): refresh trigger
2023-10-30T12:54:16.402671302Z  LEVEL(-2)       daemon/writer.go:107    pollNicStatus()
2023-10-30T12:54:16.402726435Z  LEVEL(-2)       daemon/writer.go:133    DiscoverSriovDevices
2023-10-30T12:54:16.578223444Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T12:54:16.57838351Z   INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.0 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T12:54:16.578532833Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T12:54:16.578565673Z  INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.1 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T12:54:16.578702022Z  LEVEL(-2)       utils/utils.go:157      getNetdevMTU(): get MTU {"device": "0000:03:00.0"}
2023-10-30T12:54:16.57915546Z   LEVEL(-2)       utils/utils.go:162      getNetDevMac(): get Mac {"device": "enp3s0f0np0"}
2023-10-30T12:54:16.579250137Z  LEVEL(-2)       utils/utils.go:163      getNetDevLinkSpeed(): get LinkSpeed     {"device": "enp3s0f0np0"}
2023-10-30T12:54:16.579972537Z  LEVEL(-2)       utils/utils.go:165      getLinkType()   {"device": "0000:03:00.0"}
2023-10-30T12:54:16.583858403Z  LEVEL(-2)       utils/utils.go:179      GetNicSriovMode()       {"device": "0000:03:00.0"}
2023-10-30T12:54:16.585500736Z  LEVEL(-2)       utils/utils.go:712      getNetdevMTU(): get MTU {"device": "0000:03:00.2"}
...skipping...
2023-10-30T13:03:46.331949017Z  INFO    daemon/daemon.go:358    nodeStateSyncHandler(): new generation  {"generation": 6}
2023-10-30T13:03:46.332037677Z  INFO    daemon/daemon.go:358    nodeStateSyncHandler(): Interface not changed
2023-10-30T13:03:46.332061748Z  INFO    daemon/daemon.go:374    Successfully synced
2023-10-30T13:03:53.920737008Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T13:03:53.920888959Z  INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.0 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T13:03:53.921027012Z  INFO    sriovnetwork    utils/utils.go:145      IsSupportedModel(): found unsupported model     {"vendorId:": "8086", "deviceId:": "1521"}
2023-10-30T13:03:53.921060772Z  INFO    daemon/writer.go:133    DiscoverSriovDevices(): unsupported device      {"device": "0000:01:00.1 -> driver: 'igb' class: 'Network controller' vendor: 'Intel Corporation' product: 'I350 Gigabit Network Connection'"}
2023-10-30T13:03:53.950043033Z  ERROR   utils/utils.go:163      getNetDevLinkSpeed(): fail to read Link Speed file      {"path": "/sys/class/net/enp129s0np0/speed", "error": "read /sys/class/net/enp129s0np0/speed: invalid argument"}
2023-10-30T13:03:53.957377258Z  INFO    daemon/writer.go:155    setNodeStateStatus(): status    {"sync-status": "Succeeded", "last-sync-error": ""}
2023-10-30T13:04:01.331030241Z  INFO    daemon/daemon.go:358    nodeStateSyncHandler(): new generation  {"generation": 6}
2023-10-30T13:04:01.331133148Z  INFO    daemon/daemon.go:358    nodeStateSyncHandler(): Interface not changed
2023-10-30T13:04:01.331158258Z  INFO    daemon/daemon.go:374    Successfully synced

Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great thanks for the effort!

/lgtm

@bn222
Copy link
Collaborator

bn222 commented Oct 31, 2023

LGTM

Question, why is the old log package still an indirect dependency?

@adrianchiris
Copy link
Collaborator Author

Question, why is the old log package still an indirect dependency?

maybe because of dependency on sriov device plugin ?

@adrianchiris adrianchiris merged commit f00830a into k8snetworkplumbingwg:master Oct 31, 2023
12 checks passed
@@ -48,7 +48,7 @@ var (
Use: "start",
Short: "Starts SR-IOV Network Config Daemon",
Long: "",
Run: runStartCmd,
RunE: runStartCmd,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RunE?

@@ -35,10 +33,12 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/connrotation"
"sigs.k8s.io/controller-runtime/pkg/log"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better if we import "sigs.k8s.io/controller-runtime/pkg/log" only in the new log package of the sriov operator. For instance, here I see that you use it to get a new logger instance with a name element. Therefore, you could mask this function in the log package. Something like

func WithName(name string) logr.Logger {
return log.Log.WithName(name)
}


// To help debugging, immediately log version
glog.V(2).Infof("Version: %+v", version.Version)
setupLog.V(2).Info("sriov-network-config-daemon", "version", version.Version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please remind me why we call the V function to get a new logger with different level? Just wondering if we could simplify this now that you making some changes for logging.

rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
}

func main() {
if err := rootCmd.Execute(); err != nil {
glog.Exitf("Error executing mcd: %v", err)
log.Log.Error(err, "error executing sriov-network-config-daemon")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get the logger from the new log package. You can have there. I believe all files should only import the new log package and not other log related imports.

import "sigs.k8s.io/controller-runtime/pkg/log"

var Log = log.Log


// handleLogLevelChange handles log level change
func (dn *Daemon) handleLogLevelChange(logLevel int) {
newLevel := int8(logLevel * -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps you can use log.Log.V(logLevel).Enabled() to verify whether the new level is the same or not. You won't need to have a reference to the zap package.

@mlguerrero12
Copy link
Contributor

Too late for comments. Already merged.

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

Successfully merging this pull request may close these issues.

5 participants