Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Weave-npc: while logging differentiate between fatal and non-fatal er…
Browse files Browse the repository at this point in the history
…rors
  • Loading branch information
murali-reddy committed Apr 2, 2020
1 parent 14730f8 commit 48015aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func SetLogLevel(levelname string) {
Log.Level = level
}

func CheckError(e error) {
if e != nil {
Log.Error(e)
}
}

func CheckFatal(e error) {
if e != nil {
Log.Fatal(e)
Expand Down
18 changes: 10 additions & 8 deletions prog/weave-npc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ var (
bridgePortName string
)

func handleError(err error) { common.CheckFatal(err) }
func handleError(err error) { common.CheckError(err) }

func handleFatal(err error) { common.CheckFatal(err) }

func makeController(getter cache.Getter, resource string,
objType runtime.Object, handlers cache.ResourceEventHandlerFuncs) cache.Controller {
Expand Down Expand Up @@ -240,19 +242,19 @@ func root(cmd *cobra.Command, args []string) {
}

config, err := rest.InClusterConfig()
handleError(err)
handleFatal(err)

client, err := kubernetes.NewForConfig(config)
handleError(err)
handleFatal(err)

ipt, err := iptables.New()
handleError(err)
handleFatal(err)

ips := ipset.New(common.LogLogger(), maxList)

handleError(resetIPTables(ipt))
handleError(resetIPSets(ips))
handleError(createBaseRules(ipt, ips))
handleFatal(resetIPTables(ipt))
handleFatal(resetIPSets(ips))
handleFatal(createBaseRules(ipt, ips))

npc := npc.New(nodeName, ipt, ips, client)

Expand Down Expand Up @@ -339,5 +341,5 @@ func main() {
rootCmd.PersistentFlags().IntVar(&maxList, "max-list-size", 1024, "maximum size of ipset list (for namespaces)")
rootCmd.PersistentFlags().StringVar(&bridgePortName, "bridge-port-name", "vethwe-bridge", "name of the brige port on which packets are received and sent")

handleError(rootCmd.Execute())
handleFatal(rootCmd.Execute())
}

0 comments on commit 48015aa

Please sign in to comment.