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

fix zap logger rotation issues #2344

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions cni/ipam/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cni/ipam"
"github.com/Azure/azure-container-networking/common"
"github.com/Azure/azure-container-networking/log"
)

const name = "azure-vnet-ipam"
Expand All @@ -23,17 +22,6 @@ func main() {
var config common.PluginConfig
config.Version = version

logDirectory := "" // Sets the current location as log directory
Copy link
Member

Choose a reason for hiding this comment

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

did we validate ipam logs moved to zap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I did with this PR: #2299
Verified azure-ipam.log


log.SetName(name)
log.SetLevel(log.LevelInfo)
if err := log.SetTargetLogDirectory(log.TargetLogfile, logDirectory); err != nil {
fmt.Printf("Failed to setup cni logging: %v\n", err)
return
}

defer log.Close()

ipamPlugin, err := ipam.NewPlugin(name, &config)
if err != nil {
fmt.Printf("Failed to create IPAM plugin, err:%v.\n", err)
Expand Down
12 changes: 0 additions & 12 deletions cni/ipam/pluginv6/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cni/ipam"
"github.com/Azure/azure-container-networking/common"
"github.com/Azure/azure-container-networking/log"
)

const name = "azure-vnet-ipamv6"
Expand All @@ -23,17 +22,6 @@ func main() {
var config common.PluginConfig
config.Version = version

logDirectory := "" // Sets the current location as log directory

log.SetName(name)
log.SetLevel(log.LevelInfo)
if err := log.SetTargetLogDirectory(log.TargetLogfile, logDirectory); err != nil {
fmt.Printf("Failed to setup cni logging: %v\n", err)
return
}

defer log.Close()

ipamPlugin, err := ipam.NewPlugin(name, &config)
if err != nil {
fmt.Printf("Failed to create IPAM plugin, err:%v.\n", err)
Expand Down
2 changes: 1 addition & 1 deletion cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ func (plugin *NetPlugin) Get(args *cniSkel.CmdArgs) error {

// Query the endpoint.
if epInfo, err = plugin.nm.GetEndpointInfo(networkID, endpointID); err != nil {
plugin.Errorf("Failed to query endpoint: %v", err)
logger.Error("Failed to query endpoint", zap.Error(err))
return err
}

Expand Down
10 changes: 0 additions & 10 deletions cni/network/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
zaplog "github.com/Azure/azure-container-networking/cni/log"
"github.com/Azure/azure-container-networking/cni/network"
"github.com/Azure/azure-container-networking/common"
"github.com/Azure/azure-container-networking/log"
"github.com/Azure/azure-container-networking/nns"
"github.com/Azure/azure-container-networking/platform"
"github.com/Azure/azure-container-networking/store"
Expand Down Expand Up @@ -295,15 +294,6 @@ func main() {
os.Exit(0)
}

log.SetName(name)
log.SetLevel(log.LevelInfo)
if err := log.SetTargetLogDirectory(log.TargetLogfile, ""); err != nil {
fmt.Printf("Failed to setup cni logging: %v\n", err)
return
}

defer log.Close()

if rootExecute() != nil {
os.Exit(1)
}
Expand Down