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

Use the standard context library #2114

Merged
merged 1 commit into from
Nov 25, 2024
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
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
2 changes: 1 addition & 1 deletion pkg/backend/alloc/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package alloc

import (
"context"
"fmt"
"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"
)

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
Loading