Skip to content

Commit

Permalink
datapath/connector: move CheckLink to daemon/cmd
Browse files Browse the repository at this point in the history
This function is only used in daemon/cmd in a single place, so move it
there and unexport it.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser authored and christarazi committed Oct 1, 2020
1 parent 96648d0 commit 175c7da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 8 additions & 2 deletions daemon/cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"sync"

"github.com/cilium/cilium/pkg/controller"
"github.com/cilium/cilium/pkg/datapath/connector"
"github.com/cilium/cilium/pkg/endpoint"
"github.com/cilium/cilium/pkg/k8s"
"github.com/cilium/cilium/pkg/k8s/watchers"
Expand All @@ -34,6 +33,7 @@ import (
"github.com/cilium/cilium/pkg/option"

"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
)

Expand All @@ -43,6 +43,12 @@ type endpointRestoreState struct {
toClean []*endpoint.Endpoint
}

// checkLink returns an error if a link with linkName does not exist.
func checkLink(linkName string) error {
_, err := netlink.LinkByName(linkName)
return err
}

// validateEndpoint attempts to determine that the restored endpoint is valid, ie it
// still exists in k8s, its datapath devices are present, and Cilium is
// responsible for its workload, etc.
Expand Down Expand Up @@ -78,7 +84,7 @@ func (d *Daemon) validateEndpoint(ep *endpoint.Endpoint) (valid bool, err error)
ep.RunMetadataResolver(d.fetchK8sLabelsAndAnnotations)
}

if err := ep.ValidateConnectorPlumbing(connector.CheckLink); err != nil {
if err := ep.ValidateConnectorPlumbing(checkLink); err != nil {
return false, err
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/datapath/connector/veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,3 @@ func SetupVethWithNames(lxcIfName, tmpIfName string, mtu int, ep *models.Endpoin

return veth, &peer, nil
}

// CheckLink returns an error if a link with linkName does not exist.
func CheckLink(linkName string) error {
_, err := netlink.LinkByName(linkName)
return err
}

0 comments on commit 175c7da

Please sign in to comment.