Skip to content

Commit

Permalink
Use the standard context library
Browse files Browse the repository at this point in the history
Signed-off-by: manuelbuil <mbuil@suse.com>
  • Loading branch information
manuelbuil committed Nov 20, 2024
1 parent 0e99f63 commit 60d7a7a
Show file tree
Hide file tree
Showing 32 changed files with 51 additions and 48 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"errors"
"flag"
"fmt"
Expand All @@ -40,10 +41,8 @@ import (
"github.com/flannel-io/flannel/pkg/trafficmngr/iptables"
"github.com/flannel-io/flannel/pkg/trafficmngr/nftables"
"github.com/flannel-io/flannel/pkg/version"
"golang.org/x/net/context"
log "k8s.io/klog/v2"

"github.com/joho/godotenv"
log "k8s.io/klog/v2"

// Backends need to be imported for their init() to get executed and them to register
"github.com/coreos/go-systemd/v22/daemon"
Expand Down Expand Up @@ -508,7 +507,8 @@ func mustRunHealthz(stopChan <-chan struct{}, wg *sync.WaitGroup) {
<-stopChan

// create new context with timeout for http server to shutdown gracefully
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
log.Errorf("Shutdown healthz server error. %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/backend/alloc/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import (
"fmt"
"sync"

"context"

"github.com/flannel-io/flannel/pkg/backend"
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package backend

import (
"context"
"net"
"sync"

"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
)

type ExternalInterface struct {
Expand Down
7 changes: 3 additions & 4 deletions pkg/backend/extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
package extension

import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"strings"

"encoding/json"
"os/exec"
"strings"
"sync"

"github.com/flannel-io/flannel/pkg/backend"
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
6 changes: 2 additions & 4 deletions pkg/backend/extension/extension_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
package extension

import (
"context"
"encoding/json"
"sync"

"golang.org/x/net/context"

"fmt"
"sync"

"github.com/flannel-io/flannel/pkg/backend"
"github.com/flannel-io/flannel/pkg/lease"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/hostgw/hostgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package hostgw

import (
"context"
"fmt"
"sync"

Expand All @@ -26,7 +27,6 @@ import (
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/hostgw/hostgw_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package hostgw

import (
"context"
"fmt"
"strings"
"sync"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/flannel-io/flannel/pkg/routing"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/pkg/errors"
"golang.org/x/net/context"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
log "k8s.io/klog/v2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/ipip/ipip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package ipip

import (
"context"
"encoding/json"
"fmt"
"sync"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/ipsec/handle_charon.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package ipsec

import (
"context"
"fmt"
"net"
"os"
Expand All @@ -28,7 +29,6 @@ import (

"github.com/bronze1man/goStrongswanVici"
"github.com/flannel-io/flannel/pkg/lease"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/backend/ipsec/ipsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
package ipsec

import (
"context"
"encoding/json"
"fmt"
"sync"

"golang.org/x/net/context"

"github.com/flannel-io/flannel/pkg/backend"
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/ipsec/ipsec_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package ipsec

import (
"context"
"fmt"
"net"
"strconv"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package backend

import (
"context"
"fmt"
"strings"
"sync"

"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
)

var constructors = make(map[string]BackendCtor)
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/route_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package backend

import (
"bytes"
"context"
"net"
"sync"
"time"

"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/route_network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package backend

import (
"context"
"strings"
"sync"
"time"

"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/routing"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/backend/simple_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package backend

import (
"context"

"github.com/flannel-io/flannel/pkg/lease"
"golang.org/x/net/context"
)

type SimpleNetwork struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/tencentvpc/tencentvpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package tencentvpc

import (
"context"
"encoding/json"
"fmt"
"io"
Expand All @@ -31,7 +32,6 @@ import (
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
vpc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc/v20170312"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/udp/udp_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package udp

import (
"context"
"encoding/json"
"fmt"
"sync"
Expand All @@ -25,7 +26,6 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/udp/udp_network_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package udp

import (
"context"
"fmt"
"net"
"os"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/vxlan/vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ package vxlan
// this is called "directRouting"

import (
"context"
"encoding/json"
"fmt"
"net"
Expand All @@ -63,7 +64,6 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/vxlan/vxlan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package vxlan

import (
"context"
"encoding/json"
"net"
"sync"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/flannel-io/flannel/pkg/retry"
"github.com/flannel-io/flannel/pkg/subnet"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/vxlan/vxlan_network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package vxlan

import (
"context"
"encoding/json"
"net"
"strings"
Expand All @@ -25,7 +26,6 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/backend/vxlan/vxlan_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ package vxlan
// In this scheme the scaling of table entries (per host) is:
// - 1 network entry for the overlay network
// - 1 endpoint per local container
// - N remote endpoints remote node (total endpoints =
// - N remote endpoints remote node (total endpoints = N * number of remote nodes)

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -35,7 +37,6 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
log "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/wireguard/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package wireguard

import (
"context"
"errors"
"fmt"
"net"
Expand All @@ -28,7 +29,6 @@ import (

"github.com/flannel-io/flannel/pkg/ip"
"github.com/vishvananda/netlink"
"golang.org/x/net/context"
"golang.zx2c4.com/wireguard/wgctrl"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
log "k8s.io/klog/v2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/wireguard/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package wireguard

import (
"context"
"encoding/json"
"fmt"
"net"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/flannel-io/flannel/pkg/ip"
"github.com/flannel-io/flannel/pkg/lease"
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
)

type Mode string
Expand Down
Loading

0 comments on commit 60d7a7a

Please sign in to comment.