From df52117bfa24cfb8508cb1f451f7e8470fcd7122 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 11 Oct 2019 11:20:35 +0000 Subject: [PATCH] Remove unused code --- ipam/allocator.go | 15 --------------- ipam/allocator_test.go | 2 -- ipam/paxos/paxos_test.go | 10 ---------- ipam/testutils_test.go | 25 ------------------------- nameserver/dns_test.go | 2 -- net/ipsec/ipsec.go | 8 -------- npc/namespace.go | 7 ------- plugin/skel/listener.go | 18 ------------------ prog/kube-utils/peerlist_test.go | 2 -- proxy/common.go | 2 -- test/tls/generate_certs.go | 2 -- testing/util.go | 7 ------- 12 files changed, 100 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index 6dbd7f37..c4048de7 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -207,21 +207,6 @@ func (alloc *Allocator) doOperation(op operation, ops *[]operation) { } } -// Given an operation, remove it from the pending queue -// Note the op may not be on the queue; it may have -// already succeeded. If it is on the queue, we call -// cancel on it, allowing callers waiting for the resultChans -// to unblock. -func (alloc *Allocator) cancelOp(opToCancel operation, ops *[]operation) { - for i, op := range *ops { - if op == opToCancel { - *ops = append((*ops)[:i], (*ops)[i+1:]...) - op.Cancel() - break - } - } -} - // Cancel all operations in a queue func (alloc *Allocator) cancelOps(ops *[]operation) { for _, op := range *ops { diff --git a/ipam/allocator_test.go b/ipam/allocator_test.go index e73c61d2..a60c72d4 100644 --- a/ipam/allocator_test.go +++ b/ipam/allocator_test.go @@ -17,8 +17,6 @@ import ( const ( testStart1 = "10.0.1.0" - testStart2 = "10.0.2.0" - testStart3 = "10.0.3.0" ) func returnFalse() bool { return false } diff --git a/ipam/paxos/paxos_test.go b/ipam/paxos/paxos_test.go index a78e4203..014e7e7f 100644 --- a/ipam/paxos/paxos_test.go +++ b/ipam/paxos/paxos_test.go @@ -56,16 +56,6 @@ func (m *Model) addLink(a, b *TestNode) { m.readyLinks = append(m.readyLinks, &ab, &ba) } -func (m *Model) linkExists(a, b *TestNode) bool { - for _, l := range a.links { - if l.to == b { - return true - } - } - - return false -} - type TestParams struct { // Number of nodes nodeCount uint diff --git a/ipam/testutils_test.go b/ipam/testutils_test.go index 8761d793..3039dd50 100644 --- a/ipam/testutils_test.go +++ b/ipam/testutils_test.go @@ -24,14 +24,6 @@ func (m *mockMessage) String() string { return fmt.Sprintf("-> %s [%x]", m.dst, m.buf) } -func toStringArray(messages []mockMessage) []string { - out := make([]string, len(messages)) - for i := range out { - out[i] = messages[i].String() - } - return out -} - type mockGossipComms struct { sync.RWMutex *testing.T @@ -100,14 +92,6 @@ func (m *mockGossipComms) GossipUnicast(dstPeerName mesh.PeerName, buf []byte) e return nil } -func ExpectMessage(alloc *Allocator, dst string, msgType byte, buf []byte) { - m := alloc.gossip.(*mockGossipComms) - dstPeerName, _ := mesh.PeerNameFromString(dst) - m.Lock() - m.messages = append(m.messages, mockMessage{dstPeerName, msgType, buf}) - m.Unlock() -} - func ExpectBroadcastMessage(alloc *Allocator, buf []byte) { m := alloc.gossip.(*mockGossipComms) m.Lock() @@ -208,15 +192,6 @@ func AssertNothingSent(t *testing.T, ch <-chan bool) { } } -func AssertNothingSentErr(t *testing.T, ch <-chan error) { - select { - case val := <-ch: - require.FailNow(t, fmt.Sprintf("Unexpected value on channel: %v", val)) - default: - // no message received - } -} - func makeNetworkOfAllocators(size int, cidr string, preClaims ...[]PreClaim) ([]*Allocator, *gossip.TestRouter, address.CIDR) { gossipRouter := gossip.NewTestRouter(0.0) allocs := make([]*Allocator, size) diff --git a/nameserver/dns_test.go b/nameserver/dns_test.go index 43cb117d..aa9a2804 100644 --- a/nameserver/dns_test.go +++ b/nameserver/dns_test.go @@ -41,9 +41,7 @@ func TestTruncation(t *testing.T) { defer dnsserver.Stop() // Add 100 mappings to nameserver - addrs := []address.Address{} for i := address.Address(0); i < 100; i++ { - addrs = append(addrs, i) nameserver.AddEntry("foo.weave.local.", "", mesh.UnknownPeerName, i) } diff --git a/net/ipsec/ipsec.go b/net/ipsec/ipsec.go index 5e429251..9aacbac2 100644 --- a/net/ipsec/ipsec.go +++ b/net/ipsec/ipsec.go @@ -430,14 +430,6 @@ func (ipsec *IPSec) removeDropNonEncrypted(srcIP, dstIP net.IP, udpPort int, inS return ipsec.resetRules(rules, true) } -func (ipsec *IPSec) removeDropNonEncryptedInbound(srcIP, dstIP net.IP, inSPI SPI) error { - r := ruleMarkInboundESP(srcIP, dstIP, inSPI) - if err := ipsec.ipt.Delete(r.table, r.chain, r.rulespec...); err != nil { - return errors.Wrap(err, fmt.Sprintf("iptables delete unique (%s, %s, %s)", r.table, r.chain, r.rulespec)) - } - return nil -} - // xfrm func xfrmAllocSpiState(srcIP, dstIP net.IP) *netlink.XfrmState { diff --git a/npc/namespace.go b/npc/namespace.go index c9184cff..13e59651 100644 --- a/npc/namespace.go +++ b/npc/namespace.go @@ -158,13 +158,6 @@ func (ns *ns) addToDefaultAllowIfNoMatching(pod *coreapi.Pod, policyType policyT return nil } -func (ns *ns) checkLocalPod(obj *coreapi.Pod) bool { - if obj.Spec.NodeName != ns.nodeName { - return false - } - return true -} - func (ns *ns) addPod(obj *coreapi.Pod) error { ns.pods[uid(obj)] = obj diff --git a/plugin/skel/listener.go b/plugin/skel/listener.go index 24bd4705..929c1303 100644 --- a/plugin/skel/listener.go +++ b/plugin/skel/listener.go @@ -201,24 +201,6 @@ func (listener *listener) leaveEndpoint(w http.ResponseWriter, r *http.Request) emptyOrErrorResponse(w, listener.d.LeaveEndpoint(&l)) } -func (listener *listener) discoverNew(w http.ResponseWriter, r *http.Request) { - var disco api.DiscoveryNotification - if err := json.NewDecoder(r.Body).Decode(&disco); err != nil { - sendError(w, "Could not decode JSON encoded payload", http.StatusBadRequest) - return - } - emptyOrErrorResponse(w, listener.d.DiscoverNew(&disco)) -} - -func (listener *listener) discoverDelete(w http.ResponseWriter, r *http.Request) { - var disco api.DiscoveryNotification - if err := json.NewDecoder(r.Body).Decode(&disco); err != nil { - sendError(w, "Could not decode JSON encoded payload", http.StatusBadRequest) - return - } - emptyOrErrorResponse(w, listener.d.DiscoverDelete(&disco)) -} - // === func (listener *listener) getIpamCapabilities(w http.ResponseWriter, r *http.Request) { diff --git a/prog/kube-utils/peerlist_test.go b/prog/kube-utils/peerlist_test.go index c5e47fee..2228282f 100644 --- a/prog/kube-utils/peerlist_test.go +++ b/prog/kube-utils/peerlist_test.go @@ -16,8 +16,6 @@ const ( peerName3 = "03:00:00:00:00:00" nodeName1 = "fake-node-1" nodeName2 = "fake-node-2" - - testIters = 1000 ) func TestPeerListBasic(t *testing.T) { diff --git a/proxy/common.go b/proxy/common.go index b54816dc..88dd8354 100644 --- a/proxy/common.go +++ b/proxy/common.go @@ -17,8 +17,6 @@ import ( var ( containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*") weaveWaitEntrypoint = []string{"/w/w"} - weaveEntrypoint = "/home/weave/weaver" - weaveContainerName = "/weave" Log = common.Log ) diff --git a/test/tls/generate_certs.go b/test/tls/generate_certs.go index 319384ad..a6e3b274 100644 --- a/test/tls/generate_certs.go +++ b/test/tls/generate_certs.go @@ -15,8 +15,6 @@ const ( caCertPath = "ca.pem" clientKeyPath = "key.pem" clientCertPath = "cert.pem" - serverKeyPath = "server-key.pem" - serverCertPath = "server.pem" ) func main() { diff --git a/testing/util.go b/testing/util.go index f87dba65..dd18c3f1 100644 --- a/testing/util.go +++ b/testing/util.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "reflect" - "runtime" "testing" "github.com/stretchr/testify/require" @@ -29,12 +28,6 @@ func AssertErrorType(t *testing.T, expected interface{}, actual error, desc stri } } -func stackTrace(all bool) string { - buf := make([]byte, 1<<20) - stacklen := runtime.Stack(buf, all) - return string(buf[:stacklen]) -} - // TrimTestArgs finds the first -- in os.Args and trim all args before // that, returning true when a -- was in fact found. func TrimTestArgs() bool {