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 <[email protected]>
  • Loading branch information
manuelbuil committed Nov 20, 2024
1 parent 0e99f63 commit 122ad6d
Show file tree
Hide file tree
Showing 32 changed files with 52 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 122ad6d

Please sign in to comment.