diff --git a/agent.go b/agent.go new file mode 100644 index 0000000000..c88c3e299f --- /dev/null +++ b/agent.go @@ -0,0 +1,324 @@ +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package vppagent + +import ( + "context" + "fmt" + "log" + + "github.com/google/wire" + cninfra "go.ligato.io/cn-infra/v2" + "go.ligato.io/cn-infra/v2/config" + "go.ligato.io/cn-infra/v2/datasync" + "go.ligato.io/cn-infra/v2/datasync/kvdbsync/local" + "go.ligato.io/cn-infra/v2/health/probe" + "go.ligato.io/cn-infra/v2/logging" + "go.ligato.io/cn-infra/v2/logging/logmanager" + "go.ligato.io/cn-infra/v2/rpc/prometheus" + + "go.ligato.io/vpp-agent/v3/plugins/configurator" + "go.ligato.io/vpp-agent/v3/plugins/govppmux" + "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" + linux_ifplugin "go.ligato.io/vpp-agent/v3/plugins/linux/ifplugin" + linux_iptablesplugin "go.ligato.io/vpp-agent/v3/plugins/linux/iptablesplugin" + linux_l3plugin "go.ligato.io/vpp-agent/v3/plugins/linux/l3plugin" + linux_nsplugin "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" + "go.ligato.io/vpp-agent/v3/plugins/netalloc" + "go.ligato.io/vpp-agent/v3/plugins/orchestrator" + "go.ligato.io/vpp-agent/v3/plugins/restapi" + "go.ligato.io/vpp-agent/v3/plugins/telemetry" + "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin" +) + +type Agent struct { + cninfra.Base + cninfra.Server + + LogManager *logmanager.Plugin + + Probe *probe.Plugin + Prometheus *prometheus.Plugin + + KVScheduler *kvscheduler.Scheduler + Orchestrator *orchestrator.Plugin + + // Dataplane drivers + Netalloc *netalloc.Plugin + VPP + VPPClient *govppmux.Plugin + Linux + + Configurator *configurator.Plugin + RestAPI *restapi.Plugin + Telemetry *telemetry.Plugin + + ctx context.Context `wire:"-"` + cancel func() `wire:"-"` +} + +func New(conf config.Config) Agent { + ctx := context.Background() + + core, cancelCore, err := cninfra.InjectDefaultBase(ctx, conf) + if err != nil { + log.Fatal(err) + } + + server, cancelServer, err := cninfra.InjectDefaultServer(ctx, conf) + if err != nil { + log.Fatal(err) + } + + agent, cancelAgent, err := InjectAgent(ctx, conf, core, server) + if err != nil { + log.Fatal(err) + } + + agent.cancel = func() { + cancelAgent() + cancelServer() + cancelCore() + } + agent.ctx = ctx + + return agent +} + +func (agent Agent) Start() error { + if err := agent.Base.Start(agent.ctx); err != nil { + return err + } + if err := agent.Server.Start(agent.ctx); err != nil { + return err + } + + logging.Debugf("Agent Run()") + + // TODO: replace runAfterInit hack that calls AfterInit() with a call to + // a properly named method that describes the actual action. + + // for example: this call should be replaced with call to a method(s) + // that represent what the AfterInit does, e.g. + // agent.VPPClient.StartConnectionHandler() + runAfterInit(agent.VPPClient) + + // TODO: replace these hack calls with more generic approach of starting + // dataplane components in a way that new ones can be added and + // any existing ones can be removed or replaced with custom ones. + runAfterInit(agent.Netalloc) + forEachField(agent.Linux, runAfterInit) + forEachField(agent.VPP, runAfterInit) + + if err := agent.Orchestrator.StartWatching(); err != nil { + return err + } + + agent.Prometheus.RegisterHandlers() + agent.Telemetry.StartPeriodicUpdates() + if err := agent.Probe.RegisterProbes(); err != nil { + return err + } + + logging.Info("--- Agent is RUNNING! ---") + + return nil +} + +// Wait for a signal or cancellation +func (agent Agent) Wait() { + select { + case s := <-waitForSignal(): + logging.Info("received signal:", s) + case <-agent.ctx.Done(): + logging.Info("agent context canceled") + } +} + +func (agent Agent) Stop() error { + if agent.cancel == nil { + return fmt.Errorf("agent not started") + } + + agent.cancel() + agent.cancel = nil + + return nil +} + +// Run helper method to starts the agent, waits and stops the agent. +func (agent Agent) Run() { + + if err := agent.Start(); err != nil { + logging.Fatal("agent failed to start:", err) + } + + agent.Wait() + + if err := agent.Stop(); err != nil { + logging.Fatal("agent failed to stop:", err) + } +} + +type VPP struct { + ABF *abfplugin.ABFPlugin + ACL *aclplugin.ACLPlugin + Interface *ifplugin.IfPlugin + IPSec *ipsecplugin.IPSecPlugin + L2 *l2plugin.L2Plugin + L3 *l3plugin.L3Plugin + NAT *natplugin.NATPlugin + Punt *puntplugin.PuntPlugin + STN *stnplugin.STNPlugin + SR *srplugin.SRPlugin +} + +type Linux struct { + Interface *linux_ifplugin.IfPlugin + L3 *linux_l3plugin.L3Plugin + NS *linux_nsplugin.NsPlugin + IPTables *linux_iptablesplugin.IPTablesPlugin +} + +var WireDefaultNetAlloc = wire.NewSet( + netalloc.Wire, +) + +var WireDefaultVPP = wire.NewSet( + abfplugin.Wire, + aclplugin.Wire, + ifplugin.Wire, + l2plugin.Wire, + l3plugin.Wire, + ipsecplugin.Wire, + natplugin.Wire, + puntplugin.Wire, + srplugin.Wire, + stnplugin.Wire, + wire.NewSet(wire.Struct(new(VPP), "*")), +) + +var WireDefaultLinux = wire.NewSet( + linux_ifplugin.Wire, + linux_nsplugin.Wire, + linux_l3plugin.Wire, + linux_iptablesplugin.Wire, + wire.NewSet(wire.Struct(new(Linux), "*")), +) + +func TelemetryProvider(deps telemetry.Deps) (*telemetry.Plugin, func(), error) { + p := &telemetry.Plugin{Deps: deps} + p.SetName("telemetry") + p.Log = logging.ForPlugin("telemetry") + p.Cfg = config.ForPlugin("telemetry") + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + +var WireTelemetry = wire.NewSet( + TelemetryProvider, + wire.Struct(new(telemetry.Deps), "*"), +) + +func RestapiProvider(deps restapi.Deps) (*restapi.Plugin, error) { + p := &restapi.Plugin{Deps: deps} + p.SetName("restapi") + p.Log = logging.ForPlugin("restapi") + return p, p.Init() +} + +var WireRestAPI = wire.NewSet( + RestapiProvider, + wire.Struct(new(restapi.Deps), "*"), +) + +func ConfiguratorProvider(deps configurator.Deps) (*configurator.Plugin, error) { + p := &configurator.Plugin{Deps: deps} + p.SetName("configurator") + p.Log = logging.ForPlugin("configurator") + return p, p.Init() +} + +var WireConfigurator = wire.NewSet( + ConfiguratorProvider, + wire.Struct(new(configurator.Deps), "*"), +) + +func OrchestratorProvider(deps orchestrator.Deps) (*orchestrator.Plugin, error) { + p := &orchestrator.Plugin{Deps: deps} + p.SetName("orchestrator") + p.Log = logging.ForPlugin("orchestrator") + return p, p.Init() +} + +var WireOrchestrator = wire.NewSet( + OrchestratorProvider, + wire.Struct(new(orchestrator.Deps), "GRPC", "KVScheduler", "Watcher", "StatusPublisher"), + wire.Bind(new(orchestrator.Dispatcher), new(*orchestrator.Plugin)), + wire.InterfaceValue(new(datasync.KeyValProtoWatcher), local.DefaultRegistry), + wire.InterfaceValue(new(datasync.KeyProtoValWriter), (datasync.KeyProtoValWriter)(nil)), +) + +func KVSchedulerProvider(deps kvscheduler.Deps) (*kvscheduler.Scheduler, func(), error) { + p := &kvscheduler.Scheduler{Deps: deps} + p.SetName("kvscheduler") + p.Log = logging.ForPlugin("kvscheduler") + p.Cfg = config.ForPlugin("kvscheduler") + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + +var WireKVScheduler = wire.NewSet( + KVSchedulerProvider, + wire.Bind(new(api.KVScheduler), new(*kvscheduler.Scheduler)), + wire.Struct(new(kvscheduler.Deps), "HTTPHandlers"), +) + +func GovppProvider(deps govppmux.Deps) (*govppmux.Plugin, func(), error) { + p := &govppmux.Plugin{Deps: deps} + p.SetName("govpp") + p.Log = logging.ForPlugin("govpp") + p.Cfg = config.ForPlugin("govpp") + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + +var WireGoVppMux = wire.NewSet( + GovppProvider, + wire.Bind(new(govppmux.API), new(*govppmux.Plugin)), + wire.NewSet(wire.Struct(new(govppmux.Deps), "HTTPHandlers", "StatusCheck", "Resync")), +) diff --git a/cmd/agentctl/cli/flags.go b/cmd/agentctl/cli/flags.go index 7bcb8265d7..7ed60dab0a 100644 --- a/cmd/agentctl/cli/flags.go +++ b/cmd/agentctl/cli/flags.go @@ -92,5 +92,5 @@ func SetLogLevel(logLevel string) { } logrus.SetLevel(lvl) - logging.DefaultLogger.SetLevel(logging.ParseLogLevel(logLevel)) + logging.DefaultLogger.SetLevel(logging.LogLevel(lvl)) } diff --git a/cmd/vpp-agent/app/vpp_agent.go b/cmd/vpp-agent/app/vpp_agent.go index 98c4356240..294eba334d 100644 --- a/cmd/vpp-agent/app/vpp_agent.go +++ b/cmd/vpp-agent/app/vpp_agent.go @@ -15,6 +15,7 @@ package app import ( + "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/datasync" "go.ligato.io/cn-infra/v2/datasync/kvdbsync" "go.ligato.io/cn-infra/v2/datasync/kvdbsync/local" @@ -26,8 +27,10 @@ import ( "go.ligato.io/cn-infra/v2/health/probe" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/infra" + "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/cn-infra/v2/logging/logmanager" "go.ligato.io/cn-infra/v2/messaging/kafka" + "go.ligato.io/cn-infra/v2/rpc/prometheus" "go.ligato.io/vpp-agent/v3/plugins/configurator" linux_ifplugin "go.ligato.io/vpp-agent/v3/plugins/linux/ifplugin" @@ -36,6 +39,7 @@ import ( linux_nsplugin "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" "go.ligato.io/vpp-agent/v3/plugins/netalloc" "go.ligato.io/vpp-agent/v3/plugins/orchestrator" + "go.ligato.io/vpp-agent/v3/plugins/orchestrator/watcher" "go.ligato.io/vpp-agent/v3/plugins/restapi" "go.ligato.io/vpp-agent/v3/plugins/telemetry" "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin" @@ -73,9 +77,9 @@ type VPPAgent struct { Configurator *configurator.Plugin RESTAPI *restapi.Plugin - Probe *probe.Plugin StatusCheck *statuscheck.Plugin Telemetry *telemetry.Plugin + Probe *probe.Plugin } // New creates new VPPAgent instance. @@ -98,6 +102,9 @@ func New() *VPPAgent { }), ) + aggregator := watcher.NewPlugin(watcher.UseWatchers(etcdDataSync, consulDataSync, redisDataSync)) + orchestrator.DefaultPlugin.Watcher = aggregator + // Set watcher for KVScheduler. watchers := datasync.KVProtoWatchers{ local.DefaultRegistry, @@ -129,6 +136,8 @@ func New() *VPPAgent { vpp := DefaultVPP() linux := DefaultLinux() + probe.DefaultPlugin.Prometheus = &prometheus.DefaultPlugin + return &VPPAgent{ PluginName: "VPPAgent", LogManager: &logmanager.DefaultPlugin, @@ -160,6 +169,11 @@ func (a *VPPAgent) AfterInit() error { resync.DefaultPlugin.DoResync() //orchestrator.DefaultPlugin.InitialSync() a.StatusCheck.ReportStateChange(a.PluginName, statuscheck.OK, nil) + + if err := config.WriteAs("config-out.yml"); err != nil { + logging.Warn(err) + } + return nil } diff --git a/cmd/vpp-agent/main.go b/cmd/vpp-agent/main.go index 86463ec168..b05cc0853c 100644 --- a/cmd/vpp-agent/main.go +++ b/cmd/vpp-agent/main.go @@ -17,19 +17,14 @@ package main import ( - "flag" "fmt" - "io/ioutil" "log" "os" - "time" - "go.ligato.io/cn-infra/v2/agent" - "go.ligato.io/cn-infra/v2/datasync/kvdbsync" - "go.ligato.io/cn-infra/v2/datasync/resync" + "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/logging" - "go.ligato.io/vpp-agent/v3/cmd/vpp-agent/app" + vppagent "go.ligato.io/vpp-agent/v3" "go.ligato.io/vpp-agent/v3/pkg/debug" "go.ligato.io/vpp-agent/v3/pkg/version" ) @@ -42,32 +37,32 @@ const logo = ` __ ` +/* +func init() { + flag.BoolP("version", "V", false, "Print version info and exit.") +} + func parseVersion() { s := flag.NewFlagSet("version", flag.ContinueOnError) s.Usage = func() {} s.SetOutput(ioutil.Discard) var ( - v = s.Bool("V", false, "Print version and exit.") - vv = s.Bool("version", false, "Print version info and exit.") + v = s.BoolP("version", "V", false, "Print version info and exit.") ) + s.Lookup("version") if err := s.Parse(os.Args[1:]); err == nil { if *v { fmt.Fprintln(os.Stdout, version.Version()) os.Exit(0) } - if *vv { - fmt.Fprintln(os.Stdout, version.Info()) - os.Exit(0) - } } ver, rev, date := version.Data() agent.BuildVersion = ver agent.CommitHash = rev agent.BuildDate = date -} +}*/ func main() { - parseVersion() fmt.Fprintf(os.Stderr, logo, version.Short(), version.BuiltOn(), version.BuiltBy()) if debug.IsEnabled() { @@ -76,19 +71,29 @@ func main() { defer debug.Start().Stop() } - vppAgent := app.New() + if err := config.Read(); err != nil { + log.Fatal(err) + } + + /*vppAgent := app.New() a := agent.NewAgent( + agent.Name("vpp-agent"), + agent.Version(version.Version()), agent.AllPlugins(vppAgent), - agent.StartTimeout(startTimeout), - agent.StopTimeout(stopTimeout), + //agent.StartTimeout(startTimeout), + //agent.StopTimeout(stopTimeout), ) if err := a.Run(); err != nil { logging.DefaultLogger.Fatal(err) - } + }*/ + + agent := vppagent.New(config.DefaultConfig) + + agent.Run() } -var ( +/*var ( startTimeout = agent.DefaultStartTimeout stopTimeout = agent.DefaultStopTimeout resyncTimeout = time.Second * 10 @@ -127,4 +132,4 @@ func init() { } kvdbsync.ResyncDoneTimeout = resyncTimeout resync.SingleResyncAckTimeout = resyncTimeout -} +}*/ diff --git a/cmd/vpp-agent/vpp_agent_test.go b/cmd/vpp-agent/main_test.go similarity index 100% rename from cmd/vpp-agent/vpp_agent_test.go rename to cmd/vpp-agent/main_test.go diff --git a/go.mod b/go.mod index 81a0d8623f..701436091f 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-errors/errors v1.0.1 github.com/golang/protobuf v1.3.3 + github.com/google/wire v0.4.0 github.com/gorilla/mux v1.6.2 github.com/gorilla/websocket v1.4.1 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 @@ -44,14 +45,13 @@ require ( github.com/prometheus/client_golang v0.9.3 github.com/sirupsen/logrus v1.6.0 github.com/spf13/cobra v0.0.3 - github.com/spf13/pflag v1.0.3 - github.com/spf13/viper v1.4.0 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.6.3 github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d github.com/vishvananda/netlink v0.0.0-20180910184128-56b1bd27a9a3 github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 // indirect go.ligato.io/cn-infra/v2 v2.5.0-alpha.0.20200313154441-b0d4c1b11c73 - go.uber.org/multierr v1.2.0 // indirect golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 // indirect golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 @@ -59,3 +59,7 @@ require ( google.golang.org/grpc v1.27.1 gotest.tools v2.2.0+incompatible // indirect ) + +replace go.ligato.io/cn-infra/v2 => ../cn-infra + +//replace git.fd.io/govpp.git => github.com/FDio/govpp v0.3.4 diff --git a/go.sum b/go.sum index 8fbcd63ca9..aa18e406f7 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,7 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn github.com/alicebob/miniredis v2.4.5+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= github.com/alicebob/miniredis v2.5.0+incompatible h1:yBHoLpsyjupjz3NL3MhKMVkR41j82Yjf3KFv7ApYzUI= github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.0 h1:B7AQgHi8QSEi4uHu7Sbsga+IJDU+CENgjxoo81vDUqU= @@ -55,12 +56,9 @@ github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/containerd/continuity v0.0.0-20171215195539-b2b946a77f59 h1:PP8ffsrKAQ6u4Yq63J+g5HJTeka1tgsmaGMZuHzXm1g= github.com/containerd/continuity v0.0.0-20171215195539-b2b946a77f59/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/coreos/bbolt v1.3.1-etcd.8/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY= github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-iptables v0.4.0 h1:wh4UbVs8DhLUbpyq97GLJDKrQMjEDD63T1xE4CrsKzQ= @@ -68,10 +66,8 @@ github.com/coreos/go-iptables v0.4.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmeka github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= @@ -135,7 +131,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE= github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -155,6 +150,13 @@ github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/wire v0.4.0 h1:kXcsA/rIGzJImVqPdhfnr6q0xsS9gU0515q1EPpJ9fE= +github.com/google/wire v0.4.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= @@ -166,7 +168,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmo github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.5.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.11.3 h1:h8+NsYENhxNTuq+dobk3+ODoJtwY4Fu0WQXsxJfL8aM= github.com/grpc-ecosystem/grpc-gateway v1.11.3/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -210,13 +211,16 @@ github.com/jhump/protoreflect v1.5.0 h1:NgpVT+dX71c8hZnxHof2M7QDK7QtohIJ7DYycjnk github.com/jhump/protoreflect v1.5.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -227,10 +231,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42 h1:PzBD7QuxXSgSu61TKXxRwVGzWO5d9QZ0HxFFpndZMCg= github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= -github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/maraino/go-mock v0.0.0-20180321183845-4c74c434cd3a/go.mod h1:KpdDhCgE2rvPhsnLbGZ8Uf1QORj6v92FOgFKnCz5CXM= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= @@ -243,10 +247,13 @@ github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdI github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs= github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo= @@ -307,16 +314,19 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.0.0/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -330,20 +340,24 @@ github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= +github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tinylib/msgp v1.0.2 h1:DfdQrzQa7Yh2es9SuLkixqxuXS2SxsdYn0KbdrOGWD8= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= -github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d h1:ggUgChAeyge4NZ4QUw6lhHsVymzwSDJOZcE0s2X8S20= github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg= github.com/vishvananda/netlink v0.0.0-20180910184128-56b1bd27a9a3 h1:oQccJ/ewO6mMMoDST1l1QNv4wHgYJrjPgB02iO0QWHk= @@ -351,9 +365,9 @@ github.com/vishvananda/netlink v0.0.0-20180910184128-56b1bd27a9a3/go.mod h1:+SR5 github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4= github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/willfaught/gockle v0.0.0-20160623235217-4f254e1e0f0a/go.mod h1:NLcF+3nDpXVIZatjn5Z97gKzFFVU7TzgbAcs8G7/Jrs= -github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/gopher-lua v0.0.0-20181031023651-12c4817b42c5/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 h1:1b6PAtenNyhsmo/NKXVe34h7JEZKva1YB/ne7K7mqKM= @@ -361,30 +375,32 @@ github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBU go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.ligato.io/cn-infra/v2 v2.5.0-alpha.0.20200313154441-b0d4c1b11c73 h1:sJFlfW8T9HF+5FkVRvhXnMrcMWSw8PVwDURzi5YiZ9o= -go.ligato.io/cn-infra/v2 v2.5.0-alpha.0.20200313154441-b0d4c1b11c73/go.mod h1:mYLtG2Bq3C/SOUUafEe8JOwdqohd4NVYl6Bu/nh/O8Y= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.2.0 h1:6I+W7f5VwC5SV9dNrZ3qXrDB9mD0dyGOi/ZJmYw03T4= -go.uber.org/multierr v1.2.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= +go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3 h1:KYQXGkl6vs02hK7pK4eIbw0NpNPedieTSTEiJ//bwGs= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -394,7 +410,6 @@ golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108150841-be88a9aa50a1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -417,7 +432,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181031143558-9b800f95dbbc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 h1:YoY1wS6JYVRpIfFngRf2HHo9R9dAne3xbkGOQ5rJXjU= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -428,21 +442,29 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 h1:xQwXv67TxFo9nC1GJFyab5eq/5B590r6RlnL/G8Sz7w= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191114200427-caa0b0f7d508 h1:0FYNp0PF9kFm/ZUrvcJiQ12IUJJG7iAc6Cu01wbKrbU= +golang.org/x/tools v0.0.0-20191114200427-caa0b0f7d508/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= @@ -454,7 +476,6 @@ google.golang.org/genproto v0.0.0-20181101192439-c830210a61df/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -465,9 +486,12 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -476,8 +500,11 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/plugins/configurator/plugin.go b/plugins/configurator/plugin.go index f75a406b86..71ab52248b 100644 --- a/plugins/configurator/plugin.go +++ b/plugins/configurator/plugin.go @@ -54,18 +54,18 @@ type Plugin struct { // Deps - dependencies of Plugin type Deps struct { - infra.PluginDeps - GRPCServer grpc.Server - Dispatch orchestrator.Dispatcher - VPP govppmux.API - ServiceLabel servicelabel.ReaderAPI - AddrAlloc netalloc.AddressAllocator - VPPACLPlugin aclplugin.API - VPPIfPlugin ifplugin.API - VPPL2Plugin *l2plugin.L2Plugin - VPPL3Plugin l3plugin.API - LinuxIfPlugin iflinuxplugin.API - NsPlugin nsplugin.API + infra.PluginDeps `wire:"-"` + GRPCServer grpc.Server + Dispatch orchestrator.Dispatcher + VPP govppmux.API + ServiceLabel servicelabel.ReaderAPI + AddrAlloc netalloc.AddressAllocator + VPPACLPlugin aclplugin.API + VPPIfPlugin ifplugin.API + VPPL2Plugin *l2plugin.L2Plugin + VPPL3Plugin l3plugin.API + LinuxIfPlugin iflinuxplugin.API + NsPlugin nsplugin.API } // Init sets plugin child loggers diff --git a/plugins/govppmux/plugin_impl_govppmux.go b/plugins/govppmux/plugin_impl_govppmux.go index 714368599f..04aa6080a9 100644 --- a/plugins/govppmux/plugin_impl_govppmux.go +++ b/plugins/govppmux/plugin_impl_govppmux.go @@ -29,6 +29,7 @@ import ( govpp "git.fd.io/govpp.git/core" "git.fd.io/govpp.git/proxy" "github.com/pkg/errors" + "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/datasync/resync" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/infra" @@ -86,14 +87,16 @@ type Plugin struct { // Deps defines dependencies for the govppmux plugin. type Deps struct { - infra.PluginDeps - HTTPHandlers rest.HTTPHandlers - StatusCheck statuscheck.PluginStatusWriter - Resync *resync.Plugin + infra.PluginDeps `wire:"-"` + HTTPHandlers rest.HTTPHandlers + StatusCheck statuscheck.PluginStatusWriter + Resync *resync.Plugin } // Init is the entry point called by Agent Core. A single binary-API connection to VPP is established. func (p *Plugin) Init() (err error) { + p.Log.Debug("Init()") + if p.config, err = p.loadConfig(); err != nil { return err } @@ -116,7 +119,7 @@ func (p *Plugin) Init() (err error) { p.Log.Debugf("found %d registered VPP handlers", len(vpp.GetHandlers())) for name, handler := range vpp.GetHandlers() { versions := handler.Versions() - p.Log.Debugf("- handler: %-10s has %d versions: %v", name, len(versions), versions) + p.Log.Tracef("- handler: %-10s has %d versions: %v", name, len(versions), versions) } // TODO: Async connect & automatic reconnect support is not yet implemented in the agent, @@ -175,7 +178,7 @@ func (p *Plugin) Init() (err error) { if err != nil { return err } - p.Log.Infof("VPP proxy ready") + p.Log.Infof("VPP proxy ready %#v", config.Get("govpp.proxy-enabled")) } // register REST API handlers @@ -201,8 +204,10 @@ func (p *Plugin) AfterInit() error { // Close cleans up the resources allocated by the govppmux plugin. func (p *Plugin) Close() error { - p.cancel() - p.wg.Wait() + if p.cancel != nil { + p.cancel() + p.wg.Wait() + } defer func() { if p.vppConn != nil { @@ -295,14 +300,14 @@ func (p *Plugin) updateVPPInfo() (err error) { if err != nil { p.Log.Warnf("RunCli error: %v", err) } else { - p.Log.Debugf("vpp# show version verbose\n%s", version) + p.Log.Tracef("vpp# show version verbose\n%s", version) } cmdline, err := p.vpeHandler.RunCli(ctx, "show version cmdline") if err != nil { p.Log.Warnf("RunCli error: %v", err) } else { out := strings.Replace(cmdline, "\n", "", -1) - p.Log.Debugf("vpp# show version cmdline:\n%s", out) + p.Log.Tracef("vpp# show version cmdline:\n%s", out) } ver, err := p.vpeHandler.GetVersion(ctx) @@ -333,7 +338,7 @@ func (p *Plugin) updateVPPInfo() (err error) { p.Log.Debugf("VPP loaded %d plugins", len(plugins)) for _, plugin := range plugins { - p.Log.Debugf(" - plugin: %v", plugin) + p.Log.Tracef(" - plugin: %v", plugin) } p.infoMu.Lock() diff --git a/plugins/kvscheduler/config.go b/plugins/kvscheduler/config.go new file mode 100644 index 0000000000..c2c591fdaa --- /dev/null +++ b/plugins/kvscheduler/config.go @@ -0,0 +1,55 @@ +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kvscheduler + +const ( + // by default, a history of processed transaction is recorded + defaultRecordTransactionHistory = true + + // by default, only transaction processed in the last 24 hours are kept recorded + // (with the exception of permanently recorded init period) + defaultTransactionHistoryAgeLimit = 24 * 60 // in minutes + + // by default, transactions from the first hour of runtime stay permanently + // recorded + defaultPermanentlyRecordedInitPeriod = 60 // in minutes + + // by default, all NB transactions and SB notifications are run without + // simulation (Retries are always first simulated) + defaultEnableTxnSimulation = false + + // by default, a concise summary of every processed transactions is printed + // to stdout + defaultPrintTxnSummary = true +) + +func DefaultConfig() *Config { + return &Config{ + RecordTransactionHistory: defaultRecordTransactionHistory, + TransactionHistoryAgeLimit: defaultTransactionHistoryAgeLimit, + PermanentlyRecordedInitPeriod: defaultPermanentlyRecordedInitPeriod, + EnableTxnSimulation: defaultEnableTxnSimulation, + PrintTxnSummary: defaultPrintTxnSummary, + } +} + +// Config holds the KVScheduler configuration. +type Config struct { + RecordTransactionHistory bool `json:"record-transaction-history"` + TransactionHistoryAgeLimit uint32 `json:"transaction-history-age-limit"` // in minutes + PermanentlyRecordedInitPeriod uint32 `json:"permanently-recorded-init-period"` // in minutes + EnableTxnSimulation bool `json:"enable-txn-simulation"` + PrintTxnSummary bool `json:"print-txn-summary"` +} diff --git a/plugins/kvscheduler/node_utils.go b/plugins/kvscheduler/node_utils.go index 58aafdbb04..55c10a2700 100644 --- a/plugins/kvscheduler/node_utils.go +++ b/plugins/kvscheduler/node_utils.go @@ -16,12 +16,21 @@ package kvscheduler import ( "github.com/golang/protobuf/proto" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/internal/graph" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/internal/utils" "go.ligato.io/vpp-agent/v3/proto/ligato/kvscheduler" ) +const ( + // DependencyRelation identifies dependency relation for the graph. + DependencyRelation = "depends-on" + + // DerivesRelation identifies relation of value derivation for the graph. + DerivesRelation = "derives" +) + func nodeToKVPairWithMetadata(node graph.Node) kvs.KVWithMetadata { return kvs.KVWithMetadata{ Key: node.GetKey(), diff --git a/plugins/kvscheduler/plugin_scheduler.go b/plugins/kvscheduler/plugin_scheduler.go index 6b8ec8571b..cf25361a94 100644 --- a/plugins/kvscheduler/plugin_scheduler.go +++ b/plugins/kvscheduler/plugin_scheduler.go @@ -37,34 +37,6 @@ import ( ) const ( - // DependencyRelation identifies dependency relation for the graph. - DependencyRelation = "depends-on" - - // DerivesRelation identifies relation of value derivation for the graph. - DerivesRelation = "derives" - - // how often the transaction history gets trimmed to remove records too old to keep - txnHistoryTrimmingPeriod = 1 * time.Minute - - // by default, a history of processed transaction is recorded - defaultRecordTransactionHistory = true - - // by default, only transaction processed in the last 24 hours are kept recorded - // (with the exception of permanently recorded init period) - defaultTransactionHistoryAgeLimit = 24 * 60 // in minutes - - // by default, transactions from the first hour of runtime stay permanently - // recorded - defaultPermanentlyRecordedInitPeriod = 60 // in minutes - - // by default, all NB transactions and SB notifications are run without - // simulation (Retries are always first simulated) - defaultEnableTxnSimulation = false - - // by default, a concise summary of every processed transactions is printed - // to stdout - defaultPrintTxnSummary = true - // name of the environment variable used to enable verification after every transaction verifyModeEnv = "KVSCHED_VERIFY_MODE" @@ -125,15 +97,6 @@ type Deps struct { HTTPHandlers rest.HTTPHandlers } -// Config holds the KVScheduler configuration. -type Config struct { - RecordTransactionHistory bool `json:"record-transaction-history"` - TransactionHistoryAgeLimit uint32 `json:"transaction-history-age-limit"` // in minutes - PermanentlyRecordedInitPeriod uint32 `json:"permanently-recorded-init-period"` // in minutes - EnableTxnSimulation bool `json:"enable-txn-simulation"` - PrintTxnSummary bool `json:"print-txn-summary"` -} - // SchedulerTxn implements transaction for the KV scheduler. type SchedulerTxn struct { scheduler *Scheduler @@ -149,20 +112,15 @@ type valStateWatcher struct { // Init initializes the scheduler. Single go routine is started that will process // all the transactions synchronously. func (s *Scheduler) Init() error { - // default configuration - s.config = &Config{ - RecordTransactionHistory: defaultRecordTransactionHistory, - TransactionHistoryAgeLimit: defaultTransactionHistoryAgeLimit, - PermanentlyRecordedInitPeriod: defaultPermanentlyRecordedInitPeriod, - EnableTxnSimulation: defaultEnableTxnSimulation, - PrintTxnSummary: defaultPrintTxnSummary, - } + s.Log.Debug("Init()") - // load configuration - err := s.loadConfig(s.config) - if err != nil { - s.Log.Error(err) - return err + if s.config == nil { + s.config = DefaultConfig() + err := s.loadConfig(s.config) + if err != nil { + s.Log.Error(err) + return err + } } s.Log.Debugf("KVScheduler configuration: %+v", *s.config) @@ -206,6 +164,9 @@ func (s *Scheduler) Init() error { // loadConfig loads configuration file. func (s *Scheduler) loadConfig(config *Config) error { + if s.Cfg == nil { + return nil + } found, err := s.Cfg.LoadValue(config) if err != nil { return err diff --git a/plugins/kvscheduler/refresh.go b/plugins/kvscheduler/refresh.go index 9063f52fdd..85e1f56bee 100644 --- a/plugins/kvscheduler/refresh.go +++ b/plugins/kvscheduler/refresh.go @@ -131,7 +131,7 @@ func (s *Scheduler) refreshGraph(graphW graph.RWAccess, plural = "" } - var list strings.Builder + /*var list strings.Builder for i, d := range retrieved { num := fmt.Sprintf("%d.", i+1) list.WriteString(fmt.Sprintf("\n - %3s [%s]: %q (%s)\n %v", @@ -140,8 +140,10 @@ func (s *Scheduler) refreshGraph(graphW graph.RWAccess, list.WriteString(fmt.Sprintf("\n Metadata: %+v", d.Metadata)) } } + items := list.String()*/ + items := retrieved s.Log.Debugf("%s descriptor retrieved %d item%s: %v", - descriptor.Name, len(retrieved), plural, list.String()) + descriptor.Name, len(retrieved), plural, items) } diff --git a/plugins/kvscheduler/txn_record.go b/plugins/kvscheduler/txn_record.go index 82b323c87e..f57fdead2c 100644 --- a/plugins/kvscheduler/txn_record.go +++ b/plugins/kvscheduler/txn_record.go @@ -28,6 +28,11 @@ import ( "go.ligato.io/vpp-agent/v3/proto/ligato/kvscheduler" ) +const ( + // how often the transaction history gets trimmed to remove records too old to keep + txnHistoryTrimmingPeriod = 1 * time.Minute +) + // GetTransactionHistory returns history of transactions started within the specified // time window, or the full recorded history if the timestamps are zero values. func (s *Scheduler) GetTransactionHistory(since, until time.Time) (history kvs.RecordedTxns) { diff --git a/plugins/linux/ifplugin/options.go b/plugins/linux/ifplugin/options.go index a755ef7c9a..d748438f63 100644 --- a/plugins/linux/ifplugin/options.go +++ b/plugins/linux/ifplugin/options.go @@ -1,15 +1,53 @@ package ifplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/cn-infra/v2/servicelabel" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" "go.ligato.io/vpp-agent/v3/plugins/netalloc" + "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "ServiceLabel", "AddrAlloc", "VppIfPlugin", "NsPlugin", "KVScheduler"), + wire.Bind(new(API), new(*IfPlugin)), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + addrallocPlugin netalloc.AddressAllocator, + nsPlugin nsplugin.API, + ifPlugin ifplugin.API, + label servicelabel.ReaderAPI, +) Deps { + return Deps{ + ServiceLabel: label, + KVScheduler: scheduler, + AddrAlloc: addrallocPlugin, + NsPlugin: nsPlugin, + VppIfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*IfPlugin, func(), error) { + p := &IfPlugin{Deps: deps} + p.SetName("linux-if-plugin") + p.Setup() + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/linux/iptablesplugin/iptablesplugin.go b/plugins/linux/iptablesplugin/iptablesplugin.go index 197f6f2859..04ac87f3a0 100644 --- a/plugins/linux/iptablesplugin/iptablesplugin.go +++ b/plugins/linux/iptablesplugin/iptablesplugin.go @@ -20,6 +20,7 @@ import ( "math" "go.ligato.io/cn-infra/v2/infra" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/linux/iptablesplugin/descriptor" "go.ligato.io/vpp-agent/v3/plugins/linux/iptablesplugin/linuxcalls" @@ -39,13 +40,29 @@ const ( defaultMinRuleCountForPerfRuleAddition = math.MaxInt32 ) +// Config holds the plugin configuration. +type Config struct { + linuxcalls.HandlerConfig `json:"handler"` + + Disabled bool `json:"disabled"` + GoRoutinesCnt int `json:"go-routines-count"` +} + +func DefaultConfig() *Config { + return &Config{ + // default configuration + GoRoutinesCnt: defaultGoRoutinesCnt, + HandlerConfig: linuxcalls.HandlerConfig{ + MinRuleCountForPerfRuleAddition: defaultMinRuleCountForPerfRuleAddition, + }, + } +} + // IPTablesPlugin configures Linux iptables rules. type IPTablesPlugin struct { Deps - // From configuration file - disabled bool - configFound bool + conf *Config // system handlers iptHandler linuxcalls.IPTablesAPI @@ -61,32 +78,23 @@ type Deps struct { NsPlugin nsplugin.API } -// Config holds the plugin configuration. -type Config struct { - linuxcalls.HandlerConfig `json:"handler"` - - Disabled bool `json:"disabled"` - GoRoutinesCnt int `json:"go-routines-count"` -} - // Init initializes and registers descriptors and handlers for Linux iptables rules. -func (p *IPTablesPlugin) Init() error { +func (p *IPTablesPlugin) Init() (err error) { // parse configuration file - config, err := p.retrieveConfig() + p.conf, err = p.loadConfig() if err != nil { return err } - p.Log.Debugf("Linux iptables config: %+v", config) - if config.Disabled { - p.disabled = true + p.Log.Debugf("Linux iptables config: %+v", p.conf) + if p.conf.Disabled { p.Log.Infof("Disabling iptables plugin") return nil } // init iptables handler p.iptHandler = linuxcalls.NewIPTablesHandler() - err = p.iptHandler.Init(&config.HandlerConfig) - if err != nil && p.configFound { + err = p.iptHandler.Init(&p.conf.HandlerConfig) + if err != nil { // just warn here, iptables / ip6tables just may not be installed - will return // an error by attempt to configure it p.Log.Warnf("Error by initializing iptables handler: %v", err) @@ -94,7 +102,7 @@ func (p *IPTablesPlugin) Init() error { // init & register the descriptor ruleChainDescriptor := descriptor.NewRuleChainDescriptor( - p.KVScheduler, p.iptHandler, p.NsPlugin, p.Log, config.GoRoutinesCnt, config.MinRuleCountForPerfRuleAddition) + p.KVScheduler, p.iptHandler, p.NsPlugin, p.Log, p.conf.GoRoutinesCnt, p.conf.MinRuleCountForPerfRuleAddition) err = p.Deps.KVScheduler.RegisterKVDescriptor(ruleChainDescriptor) if err != nil { @@ -109,23 +117,18 @@ func (p *IPTablesPlugin) Close() error { return nil } -// retrieveConfig loads plugin configuration file. -func (p *IPTablesPlugin) retrieveConfig() (*Config, error) { - config := &Config{ - // default configuration - GoRoutinesCnt: defaultGoRoutinesCnt, - HandlerConfig: linuxcalls.HandlerConfig{ - MinRuleCountForPerfRuleAddition: defaultMinRuleCountForPerfRuleAddition, - }, - } - found, err := p.Cfg.LoadValue(config) - if !found { - p.Log.Debug("Linux IPTablesPlugin config not found") - return config, nil - } - if err != nil { - return nil, err +// loadConfig loads plugin configuration file. +func (p *IPTablesPlugin) loadConfig() (*Config, error) { + config := DefaultConfig() + if p.Cfg != nil { + found, err := p.Cfg.LoadValue(config) + if !found { + p.Log.Debug("Linux IPTablesPlugin config not found") + return config, nil + } + if err != nil { + return nil, err + } } - p.configFound = true - return config, err + return config, nil } diff --git a/plugins/linux/iptablesplugin/options.go b/plugins/linux/iptablesplugin/options.go index c77543c87b..551a265f76 100644 --- a/plugins/linux/iptablesplugin/options.go +++ b/plugins/linux/iptablesplugin/options.go @@ -15,13 +15,44 @@ package iptablesplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" ) +var Wire = wire.NewSet( + Provider, + ConfigProvider, + DepsProvider, +) + +func DepsProvider(scheduler kvs.KVScheduler, nsplugin nsplugin.API) Deps { + return Deps{ + KVScheduler: scheduler, + NsPlugin: nsplugin, + } +} + +func ConfigProvider(conf config.Config) *Config { + var cfg = DefaultConfig() + if err := conf.UnmarshalKey("linux-iptablesplugin", &cfg); err != nil { + logging.Errorf("unmarshal key failed: %v", err) + } + return cfg +} + +func Provider(deps Deps, conf *Config) (*IPTablesPlugin, error) { + p := &IPTablesPlugin{Deps: deps} + p.conf = conf + p.SetName("linux-iptablesplugin") + p.Log = logging.ForPlugin("linux-iptablesplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of IPTablesPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/linux/l3plugin/l3plugin.go b/plugins/linux/l3plugin/l3plugin.go index b8123729bf..208647604a 100644 --- a/plugins/linux/l3plugin/l3plugin.go +++ b/plugins/linux/l3plugin/l3plugin.go @@ -35,12 +35,23 @@ const ( defaultGoRoutinesCnt = 10 ) +// Config holds the l3plugin configuration. +type Config struct { + Disabled bool `json:"disabled"` + GoRoutinesCnt int `json:"go-routines-count"` +} + +func DefaultConfig() *Config { + return &Config{ + GoRoutinesCnt: defaultGoRoutinesCnt, + } +} + // L3Plugin configures Linux routes and ARP entries using Netlink API. type L3Plugin struct { Deps - // From configuration file - disabled bool + conf *Config // system handlers l3Handler linuxcalls.NetlinkAPI @@ -59,22 +70,15 @@ type Deps struct { AddrAlloc netalloc.AddressAllocator } -// Config holds the l3plugin configuration. -type Config struct { - Disabled bool `json:"disabled"` - GoRoutinesCnt int `json:"go-routines-count"` -} - // Init initializes and registers descriptors for Linux ARPs and Routes. -func (p *L3Plugin) Init() error { +func (p *L3Plugin) Init() (err error) { // parse configuration file - config, err := p.retrieveConfig() + p.conf, err = p.loadConfig() if err != nil { return err } - p.Log.Debugf("Linux L3 plugin config: %+v", config) - if config.Disabled { - p.disabled = true + p.Log.Debugf("Linux L3 plugin config: %+v", p.conf) + if p.conf.Disabled { p.Log.Infof("Disabling Linux L3 plugin") return nil } @@ -84,10 +88,10 @@ func (p *L3Plugin) Init() error { // init & register descriptors arpDescriptor := descriptor.NewARPDescriptor( - p.KVScheduler, p.IfPlugin, p.NsPlugin, p.AddrAlloc, p.l3Handler, p.Log, config.GoRoutinesCnt) + p.KVScheduler, p.IfPlugin, p.NsPlugin, p.AddrAlloc, p.l3Handler, p.Log, p.conf.GoRoutinesCnt) routeDescriptor := descriptor.NewRouteDescriptor( - p.KVScheduler, p.IfPlugin, p.NsPlugin, p.AddrAlloc, p.l3Handler, p.Log, config.GoRoutinesCnt) + p.KVScheduler, p.IfPlugin, p.NsPlugin, p.AddrAlloc, p.l3Handler, p.Log, p.conf.GoRoutinesCnt) err = p.Deps.KVScheduler.RegisterKVDescriptor(arpDescriptor) if err != nil { @@ -106,19 +110,18 @@ func (p *L3Plugin) Close() error { return nil } -// retrieveConfig loads L3Plugin configuration file. -func (p *L3Plugin) retrieveConfig() (*Config, error) { - config := &Config{ - // default configuration - GoRoutinesCnt: defaultGoRoutinesCnt, - } - found, err := p.Cfg.LoadValue(config) - if !found { - p.Log.Debug("Linux L3Plugin config not found") - return config, nil - } - if err != nil { - return nil, err +// loadConfig loads L3Plugin configuration file. +func (p *L3Plugin) loadConfig() (*Config, error) { + config := DefaultConfig() + if p.Cfg != nil { + found, err := p.Cfg.LoadValue(config) + if !found { + p.Log.Debug("Linux L3Plugin config not found") + return config, nil + } + if err != nil { + return nil, err + } } - return config, err + return config, nil } diff --git a/plugins/linux/l3plugin/options.go b/plugins/linux/l3plugin/options.go index 7005becc3c..8dfd7584ca 100644 --- a/plugins/linux/l3plugin/options.go +++ b/plugins/linux/l3plugin/options.go @@ -1,15 +1,53 @@ package l3plugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/linux/ifplugin" "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" "go.ligato.io/vpp-agent/v3/plugins/netalloc" ) +var Wire = wire.NewSet( + Provider, + ConfigProvider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + addrallocPlugin netalloc.AddressAllocator, + nsPlugin nsplugin.API, + ifPlugin ifplugin.API, +) Deps { + return Deps{ + KVScheduler: scheduler, + NsPlugin: nsPlugin, + IfPlugin: ifPlugin, + AddrAlloc: addrallocPlugin, + } +} + +func ConfigProvider(conf config.Config) *Config { + var cfg = DefaultConfig() + if err := conf.UnmarshalKey("linux-l3plugin", &cfg); err != nil { + logging.Errorf("unmarshal key failed: %v", err) + } + return cfg +} + +func Provider(deps Deps, conf *Config) (*L3Plugin, error) { + p := &L3Plugin{Deps: deps} + p.conf = conf + p.SetName("linux-l3plugin") + p.Log = logging.ForPlugin("linux-l3plugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/linux/nsplugin/ns_plugin.go b/plugins/linux/nsplugin/ns_plugin.go index 4c89b86700..82f72d7c11 100644 --- a/plugins/linux/nsplugin/ns_plugin.go +++ b/plugins/linux/nsplugin/ns_plugin.go @@ -15,7 +15,6 @@ package nsplugin import ( - "fmt" "strconv" "github.com/pkg/errors" @@ -38,8 +37,7 @@ import ( type NsPlugin struct { Deps - // From configuration file - disabled bool + conf *Config // Default namespace defaultNs netns.NsHandle @@ -63,28 +61,21 @@ type Config struct { Disabled bool `json:"disabled"` } -// UnavailableMicroserviceErr is error implementation used when a given microservice is not deployed. -type UnavailableMicroserviceErr struct { - label string -} - -func (e *UnavailableMicroserviceErr) Error() string { - return fmt.Sprintf("Microservice '%s' is not available", e.label) +// DefaultConfig returns default configuration. +func DefaultConfig() *Config { + return &Config{} } // Init namespace handler caches and create config namespace -func (p *NsPlugin) Init() error { +func (p *NsPlugin) Init() (err error) { // Parse configuration file - config, err := p.retrieveConfig() + p.conf, err = p.loadConfig() if err != nil { return err } - if config != nil { - if config.Disabled { - p.disabled = true - p.Log.Infof("Disabling Linux Namespace plugin") - return nil - } + if p.conf.Disabled { + p.Log.Infof("Disabling Linux Namespace plugin") + return nil } // Handlers @@ -108,14 +99,12 @@ func (p *NsPlugin) Init() error { } p.msDescriptor.StartTracker() - p.Log.Infof("Namespace plugin initialized") - return nil } // Close stops microservice tracker func (p *NsPlugin) Close() error { - if p.disabled { + if p.conf.Disabled { return nil } p.msDescriptor.StopTracker() @@ -127,7 +116,7 @@ func (p *NsPlugin) Close() error { // to be used with Netlink API. Do not forget to eventually close the handle using // the netns.NsHandle.Close() method. func (p *NsPlugin) GetNamespaceHandle(ctx nsLinuxcalls.NamespaceMgmtCtx, namespace *nsmodel.NetNamespace) (handle netns.NsHandle, err error) { - if p.disabled { + if p.conf.Disabled { return 0, errors.New("NsPlugin is disabled") } // Convert microservice namespace @@ -153,7 +142,7 @@ func (p *NsPlugin) GetNamespaceHandle(ctx nsLinuxcalls.NamespaceMgmtCtx, namespa // Caller should eventually call the returned "revert" function in order to get back to the original // network namespace (for example using "defer revert()"). func (p *NsPlugin) SwitchToNamespace(ctx nsLinuxcalls.NamespaceMgmtCtx, ns *nsmodel.NetNamespace) (revert func(), err error) { - if p.disabled { + if p.conf.Disabled { return func() {}, errors.New("NsPlugin is disabled") } @@ -208,19 +197,21 @@ func (p *NsPlugin) SwitchToNamespace(ctx nsLinuxcalls.NamespaceMgmtCtx, ns *nsmo }, nil } -// retrieveConfig loads NsPlugin configuration file. -func (p *NsPlugin) retrieveConfig() (*Config, error) { - config := &Config{} - found, err := p.Cfg.LoadValue(config) - if !found { - p.Log.Debug("Linux NsPlugin config not found") - return nil, nil - } - if err != nil { - return nil, err +// loadConfig loads NsPlugin configuration file. +func (p *NsPlugin) loadConfig() (*Config, error) { + config := DefaultConfig() + if p.Cfg != nil { + found, err := p.Cfg.LoadValue(config) + if !found { + p.Log.Debug("Linux NsPlugin config not found") + return config, nil + } + if err != nil { + return nil, err + } + p.Log.Debug("Linux NsPlugin config found") } - p.Log.Debug("Linux NsPlugin config found") - return config, err + return config, nil } // getOrCreateNs returns an existing Linux network namespace or creates a new one if it doesn't exist yet. diff --git a/plugins/linux/nsplugin/ns_plugin_api.go b/plugins/linux/nsplugin/ns_plugin_api.go index 26cda8881a..9bcc9d1eca 100644 --- a/plugins/linux/nsplugin/ns_plugin_api.go +++ b/plugins/linux/nsplugin/ns_plugin_api.go @@ -15,6 +15,8 @@ package nsplugin import ( + "fmt" + "github.com/vishvananda/netns" "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin/linuxcalls" @@ -33,3 +35,12 @@ type API interface { // the netns.NsHandle.Close() method. GetNamespaceHandle(ctx linuxcalls.NamespaceMgmtCtx, ns *linux_namespace.NetNamespace) (handle netns.NsHandle, err error) } + +// UnavailableMicroserviceErr is error implementation used when a given microservice is not deployed. +type UnavailableMicroserviceErr struct { + label string +} + +func (e *UnavailableMicroserviceErr) Error() string { + return fmt.Sprintf("Microservice '%s' is not available", e.label) +} diff --git a/plugins/linux/nsplugin/options.go b/plugins/linux/nsplugin/options.go index ca71396c69..7c722b8e48 100644 --- a/plugins/linux/nsplugin/options.go +++ b/plugins/linux/nsplugin/options.go @@ -1,12 +1,48 @@ package nsplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" ) +var Wire = wire.NewSet( + Provider, + ConfigProvider, + DepsProvider, + wire.Bind(new(API), new(*NsPlugin)), +) + +func DepsProvider(scheduler kvs.KVScheduler) Deps { + return Deps{ + KVScheduler: scheduler, + } +} + +func ConfigProvider(conf config.Config) *Config { + var cfg = DefaultConfig() + if err := conf.UnmarshalKey("http", &cfg); err != nil { + logging.Errorf("unmarshal key failed: %v", err) + } + return cfg +} + +func Provider(deps Deps, conf *Config) (*NsPlugin, func(), error) { + p := &NsPlugin{Deps: deps} + p.conf = conf + p.SetName("linux-nsplugin") + p.Log = logging.ForPlugin("linux-nsplugin") + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/netalloc/options.go b/plugins/netalloc/options.go index 632739303d..021f012edb 100644 --- a/plugins/netalloc/options.go +++ b/plugins/netalloc/options.go @@ -1,11 +1,34 @@ package netalloc import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "KVScheduler"), + wire.Bind(new(AddressAllocator), new(*Plugin)), +) + +func DepsProvider( + scheduler kvs.KVScheduler, +) Deps { + return Deps{ + KVScheduler: scheduler, + } +} +func Provider(deps Deps) (*Plugin, error) { + p := &Plugin{Deps: deps} + p.SetName("netalloc-plugin") + p.Setup() + return p, p.Init() +} + // DefaultPlugin is a default instance of netalloc plugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/orchestrator/orchestrator.go b/plugins/orchestrator/orchestrator.go index d868ed348f..2893d25fc2 100644 --- a/plugins/orchestrator/orchestrator.go +++ b/plugins/orchestrator/orchestrator.go @@ -15,13 +15,13 @@ package orchestrator import ( + "fmt" "os" "strings" "github.com/golang/protobuf/proto" "go.ligato.io/cn-infra/v2/datasync" "go.ligato.io/cn-infra/v2/infra" - "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/cn-infra/v2/rpc/grpc" "golang.org/x/net/context" "google.golang.org/grpc/reflection" @@ -67,8 +67,10 @@ type Deps struct { // Init registers the service to GRPC server. func (p *Plugin) Init() (err error) { + p.Log.Debug("Init()") + p.dispatcher = &dispatcher{ - log: logging.DefaultRegistry.NewLogger("dispatcher"), + log: p.Log.NewLogger("dispatcher"), db: newMemStore(), kvs: p.KVScheduler, } @@ -91,16 +93,23 @@ func (p *Plugin) Init() (err error) { p.log.Infof("grpc server not available") } + //_ = p.StartWatching() + + return nil +} + +func (p *Plugin) StartWatching() (err error) { nbPrefixes := p.kvs.GetRegisteredNBKeyPrefixes() if len(nbPrefixes) > 0 { p.log.Infof("Watch starting for %d registered NB prefixes", len(nbPrefixes)) } else { p.log.Warnf("No registered NB prefixes found in KVScheduler (ensure that all KVDescriptors are registered before this)") + return fmt.Errorf("no NB prefixes registered to KVScheduler") } var prefixes []string for _, prefix := range nbPrefixes { - p.log.Debugf("- watching NB prefix: %s", prefix) + p.log.Tracef("- watching NB prefix: %s", prefix) prefixes = append(prefixes, prefix) } @@ -114,11 +123,17 @@ func (p *Plugin) Init() (err error) { return err } + go p.watchEvents() + + statusChan := make(chan *kvscheduler.BaseValueStatus, 100) + p.kvs.WatchValueStatus(statusChan, nil) + go p.watchStatus(statusChan) + return nil } // AfterInit subscribes to known NB prefixes. -func (p *Plugin) AfterInit() (err error) { +/*func (p *Plugin) AfterInit() (err error) { go p.watchEvents() statusChan := make(chan *kvscheduler.BaseValueStatus, 100) @@ -126,7 +141,7 @@ func (p *Plugin) AfterInit() (err error) { go p.watchStatus(statusChan) return nil -} +}*/ // InitialSync will start initial synchronization with downstream. func (p *Plugin) InitialSync() { diff --git a/plugins/orchestrator/watcher/aggregator.go b/plugins/orchestrator/watcher/aggregator.go index 0c10860bfa..836f349b47 100644 --- a/plugins/orchestrator/watcher/aggregator.go +++ b/plugins/orchestrator/watcher/aggregator.go @@ -63,7 +63,7 @@ func NewPlugin(opts ...Option) *Aggregator { for _, o := range opts { o(p) } - p.PluginDeps.SetupLog() + p.PluginDeps.Setup() return p } diff --git a/plugins/restapi/plugin_restapi.go b/plugins/restapi/plugin_restapi.go index 6cebfe4117..cfd8e8af43 100644 --- a/plugins/restapi/plugin_restapi.go +++ b/plugins/restapi/plugin_restapi.go @@ -84,17 +84,17 @@ type Plugin struct { // Deps represents dependencies of Rest Plugin type Deps struct { - infra.PluginDeps - HTTPHandlers rest.HTTPHandlers - VPP govppmux.API - ServiceLabel servicelabel.ReaderAPI - AddrAlloc netalloc.AddressAllocator - VPPACLPlugin aclplugin.API - VPPIfPlugin ifplugin.API - VPPL2Plugin *l2plugin.L2Plugin - VPPL3Plugin *l3plugin.L3Plugin - LinuxIfPlugin linuxifplugin.API - NsPlugin nsplugin.API + infra.PluginDeps `wire:"-"` + HTTPHandlers rest.HTTPHandlers + VPP govppmux.API + ServiceLabel servicelabel.ReaderAPI + AddrAlloc netalloc.AddressAllocator + VPPACLPlugin aclplugin.API + VPPIfPlugin ifplugin.API + VPPL2Plugin *l2plugin.L2Plugin + VPPL3Plugin *l3plugin.L3Plugin + LinuxIfPlugin linuxifplugin.API + NsPlugin nsplugin.API } // index defines map of main index page entries @@ -180,11 +180,25 @@ func (p *Plugin) Init() (err error) { // Register permission groups, used if REST security is enabled p.HTTPHandlers.RegisterPermissionGroup(getPermissionsGroups()...) + p.RegisterHandlers() + return nil } // AfterInit is used to register HTTP handlers -func (p *Plugin) AfterInit() (err error) { +/*func (p *Plugin) AfterInit() (err error) { + + p.RegisterHandlers() + + return nil +}*/ + +// Close is used to clean up resources used by Plugin +func (p *Plugin) Close() error { + return nil +} + +func (p *Plugin) RegisterHandlers() { // VPP handlers p.registerTelemetryHandlers() // core @@ -203,12 +217,6 @@ func (p *Plugin) AfterInit() (err error) { // Index and stats handlers p.registerIndexHandlers() p.registerStatsHandler() - return nil -} - -// Close is used to clean up resources used by Plugin -func (p *Plugin) Close() error { - return nil } // Fill index item lists diff --git a/plugins/telemetry/config.go b/plugins/telemetry/config.go index 0d98cac146..f5390323fc 100644 --- a/plugins/telemetry/config.go +++ b/plugins/telemetry/config.go @@ -36,7 +36,7 @@ type Config struct { Skipped []string `json:"skipped"` } -func defaultConfig() *Config { +func DefaultConfig() *Config { return &Config{ PollingInterval: defaultUpdatePeriod, } @@ -44,7 +44,7 @@ func defaultConfig() *Config { // loadConfig returns telemetry plugin file configuration if exists func (p *Plugin) loadConfig() (*Config, error) { - cfg := defaultConfig() + cfg := DefaultConfig() found, err := p.Cfg.LoadValue(cfg) if err != nil { diff --git a/plugins/telemetry/telemetry.go b/plugins/telemetry/telemetry.go index afd7e24978..22ee398595 100644 --- a/plugins/telemetry/telemetry.go +++ b/plugins/telemetry/telemetry.go @@ -36,6 +36,7 @@ import ( "go.ligato.io/vpp-agent/v3/pkg/models" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls" + vpp_ifplugin "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" "go.ligato.io/vpp-agent/v3/proto/ligato/configurator" @@ -74,13 +75,13 @@ type InterfaceIndexProvider interface { // Deps represents dependencies of Telemetry Plugin type Deps struct { - infra.PluginDeps - ServiceLabel servicelabel.ReaderAPI - VPP govppmux.API - Prometheus prom.API - GRPC grpc.Server - HTTPHandlers rest.HTTPHandlers - IfPlugin InterfaceIndexProvider + infra.PluginDeps `wire:"-"` + ServiceLabel servicelabel.ReaderAPI + VPP govppmux.API + Prometheus prom.API + GRPC grpc.Server + HTTPHandlers rest.HTTPHandlers + IfPlugin vpp_ifplugin.API //InterfaceIndexProvider } // Init initializes Telemetry Plugin @@ -146,12 +147,8 @@ func (p *Plugin) Init() error { // AfterInit executes after initializion of Telemetry Plugin func (p *Plugin) AfterInit() error { - // Do not start polling if telemetry is disabled - if p.disabled || p.prometheusDisabled { - return nil - } - p.startPeriodicUpdates() + p.StartPeriodicUpdates() return nil } @@ -178,7 +175,11 @@ func (p *Plugin) Close() error { return nil } -func (p *Plugin) startPeriodicUpdates() { +func (p *Plugin) StartPeriodicUpdates() { // Do not start polling if telemetry is disabled + if p.disabled || p.prometheusDisabled { + return + } + p.handler = vppcalls.CompatibleTelemetryHandler(p.VPP) if p.handler == nil { p.Log.Warnf("VPP telemetry handler unavailable, skipping periodic updates") diff --git a/plugins/vpp/abfplugin/abfplugin.go b/plugins/vpp/abfplugin/abfplugin.go index 8003a7eee3..d2e669c60f 100644 --- a/plugins/vpp/abfplugin/abfplugin.go +++ b/plugins/vpp/abfplugin/abfplugin.go @@ -49,12 +49,12 @@ type ABFPlugin struct { // Deps represents dependencies for the plugin. type Deps struct { - infra.PluginDeps - Scheduler kvs.KVScheduler - VPP govppmux.API - ACLPlugin aclplugin.API - IfPlugin ifplugin.API - StatusCheck statuscheck.PluginStatusWriter // optional + infra.PluginDeps `wire:"-"` + Scheduler kvs.KVScheduler + VPP govppmux.API + ACLPlugin aclplugin.API + IfPlugin ifplugin.API + StatusCheck statuscheck.PluginStatusWriter // optional } // Init initializes ABF plugin. diff --git a/plugins/vpp/abfplugin/options.go b/plugins/vpp/abfplugin/options.go index a261e0732f..3b0796b9f0 100644 --- a/plugins/vpp/abfplugin/options.go +++ b/plugins/vpp/abfplugin/options.go @@ -15,14 +15,46 @@ package abfplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" + "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "StatusCheck", "Scheduler", "VPP", "ACLPlugin", "IfPlugin"), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + aclPlugin aclplugin.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + Scheduler: scheduler, + VPP: govppmuxPlugin, + ACLPlugin: aclPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*ABFPlugin, error) { + p := &ABFPlugin{Deps: deps} + p.SetName("vpp-abfplugin") + p.Log = logging.ForPlugin("vpp-abf-plugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of ABFPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/aclplugin/aclplugin.go b/plugins/vpp/aclplugin/aclplugin.go index 3b3023d226..0f2ba4726c 100644 --- a/plugins/vpp/aclplugin/aclplugin.go +++ b/plugins/vpp/aclplugin/aclplugin.go @@ -49,11 +49,11 @@ type ACLPlugin struct { // Deps represents dependencies for the plugin. type Deps struct { - infra.PluginDeps - Scheduler kvs.KVScheduler - VPP govppmux.API - IfPlugin ifplugin.API - StatusCheck statuscheck.PluginStatusWriter // optional + infra.PluginDeps `wire:"-"` + Scheduler kvs.KVScheduler + VPP govppmux.API + IfPlugin ifplugin.API + StatusCheck statuscheck.PluginStatusWriter // optional } // Init initializes ACL plugin. diff --git a/plugins/vpp/aclplugin/options.go b/plugins/vpp/aclplugin/options.go index 42a1ec2a86..fbed79d112 100644 --- a/plugins/vpp/aclplugin/options.go +++ b/plugins/vpp/aclplugin/options.go @@ -15,15 +15,46 @@ package aclplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "*"), + //wire.InterfaceValue(new(API), &ACLPlugin{}), + wire.Bind(new(API), new(*ACLPlugin)), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + Scheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*ACLPlugin, error) { + p := &ACLPlugin{Deps: deps} + p.SetName("vpp-aclplugin") + p.Log = logging.ForPlugin("vpp-aclplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/binapi/binapi.go b/plugins/vpp/binapi/binapi.go index 9ac3cc7c78..04d180526c 100644 --- a/plugins/vpp/binapi/binapi.go +++ b/plugins/vpp/binapi/binapi.go @@ -44,7 +44,7 @@ func CompatibleVersion(ch CompatibilityChecker) (Version, error) { // check core compatibility coreMsgs := check.Core.AllMessages() if err := ch.CheckCompatiblity(coreMsgs...); errors.As(err, &compErr) { - logging.Debugf("binapi version %v core incompatible (%d/%d messages)", version, len(compErr.IncompatibleMessages), len(coreMsgs)) + logging.Tracef("binapi version %v core incompatible (%d/%d messages)", version, len(compErr.IncompatibleMessages), len(coreMsgs)) continue } else if err != nil { logging.Warnf("binapi version %v check failed: %v", version, err) @@ -55,7 +55,7 @@ func CompatibleVersion(ch CompatibilityChecker) (Version, error) { pluginMsgs := check.Plugins.AllMessages() if err := ch.CheckCompatiblity(pluginMsgs...); errors.As(err, &compErr) { // some plugins might be disabled - logging.Debugf("binapi version %v partly incompatible: (%d/%d messages)", version, len(compErr.IncompatibleMessages), len(pluginMsgs)) + logging.Tracef("binapi version %v partly incompatible: (%d/%d messages)", version, len(compErr.IncompatibleMessages), len(pluginMsgs)) if picked.version == "" || picked.incompatible > len(compErr.IncompatibleMessages) { picked.version = version picked.incompatible = len(compErr.IncompatibleMessages) diff --git a/plugins/vpp/handlers.go b/plugins/vpp/handlers.go index 613f79158a..9e30e87e44 100644 --- a/plugins/vpp/handlers.go +++ b/plugins/vpp/handlers.go @@ -82,7 +82,7 @@ func (h *Handler) GetCompatibleVersion(c Client) (*HandlerVersion, error) { // try preferred binapi version first if ver := c.BinapiVersion(); ver != "" { if v, ok := h.versions[ver]; ok { - logging.Debugf("VPP handler %s COMPATIBLE with preferred version: %s", h.desc.Name, v.Version) + logging.Tracef("VPP handler %s COMPATIBLE with preferred version: %s", h.desc.Name, v.Version) return v, nil } } diff --git a/plugins/vpp/ifplugin/config.go b/plugins/vpp/ifplugin/config.go index 54f1abd655..3a2e0901d7 100644 --- a/plugins/vpp/ifplugin/config.go +++ b/plugins/vpp/ifplugin/config.go @@ -51,8 +51,8 @@ func (p *IfPlugin) loadConfig() (*Config, error) { if err != nil { return nil, err } else if !found { - p.Log.Debugf("config %s not found", p.Cfg.GetConfigName()) - return nil, nil + //p.Log.Debugf("config %s not found", p.Cfg.GetConfigName()) + return &cfg, nil } p.Log.Debugf("config %s found: %+v", p.Cfg.GetConfigName(), cfg) diff --git a/plugins/vpp/ifplugin/ifplugin.go b/plugins/vpp/ifplugin/ifplugin.go index 55a1d17387..7ef0e3243b 100644 --- a/plugins/vpp/ifplugin/ifplugin.go +++ b/plugins/vpp/ifplugin/ifplugin.go @@ -98,11 +98,11 @@ type IfPlugin struct { // Deps lists dependencies of the interface plugin. type Deps struct { - infra.PluginDeps - KVScheduler kvs.KVScheduler - VPP govppmux.API - ServiceLabel servicelabel.ReaderAPI - AddrAlloc netalloc.AddressAllocator + infra.PluginDeps `wire:"-"` + KVScheduler kvs.KVScheduler + VPP govppmux.API + ServiceLabel servicelabel.ReaderAPI + AddrAlloc netalloc.AddressAllocator /* LinuxIfPlugin and NsPlugin deps are optional, but they are required if AFPacket or TAP+TAP_TO_VPP interfaces are used. */ LinuxIfPlugin descriptor.LinuxPluginAPI @@ -330,22 +330,20 @@ func (p *IfPlugin) fromConfigFile() error { p.Log.Errorf("Error reading %v config file: %v", p.PluginName, err) return err } - if config != nil { - publishers := datasync.KVProtoWriters{} - for _, pub := range config.StatusPublishers { - db, found := p.Deps.DataSyncs[pub] - if !found { - p.Log.Warnf("Unknown status publisher %q from config", pub) - continue - } - publishers = append(publishers, db) - p.Log.Infof("Added status publisher %q from config", pub) - } - p.Deps.PublishStatistics = publishers - if config.MTU != 0 { - p.defaultMtu = config.MTU - p.Log.Infof("Default MTU set to %v", p.defaultMtu) + publishers := datasync.KVProtoWriters{} + for _, pub := range config.StatusPublishers { + db, found := p.Deps.DataSyncs[pub] + if !found { + p.Log.Debugf("Unknown status publisher %q from config", pub) + continue } + publishers = append(publishers, db) + p.Log.Infof("Added status publisher %q from config", pub) + } + p.Deps.PublishStatistics = publishers + if config.MTU != 0 { + p.defaultMtu = config.MTU + p.Log.Infof("Default MTU set to %v", p.defaultMtu) } return nil } @@ -364,18 +362,18 @@ var ( func (p *IfPlugin) fixNilPointers() { if p.Deps.PublishErrors == nil { p.Deps.PublishErrors = noopWriter - p.Log.Debug("setting default noop writer for PublishErrors dependency") + //p.Log.Debug("setting default noop writer for PublishErrors dependency") } if p.Deps.PublishStatistics == nil { p.Deps.PublishStatistics = noopWriter - p.Log.Debug("setting default noop writer for PublishStatistics dependency") + //p.Log.Debug("setting default noop writer for PublishStatistics dependency") } if p.Deps.NotifyStates == nil { p.Deps.NotifyStates = noopWriter - p.Log.Debug("setting default noop writer for NotifyStatistics dependency") + //p.Log.Debug("setting default noop writer for NotifyStatistics dependency") } if p.Deps.Watcher == nil { p.Deps.Watcher = noopWatcher - p.Log.Debug("setting default noop watcher for Watcher dependency") + //p.Log.Debug("setting default noop watcher for Watcher dependency") } } diff --git a/plugins/vpp/ifplugin/options.go b/plugins/vpp/ifplugin/options.go index 0986caff7a..9c79870121 100644 --- a/plugins/vpp/ifplugin/options.go +++ b/plugins/vpp/ifplugin/options.go @@ -15,6 +15,7 @@ package ifplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/config" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" @@ -22,9 +23,47 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" + "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" "go.ligato.io/vpp-agent/v3/plugins/netalloc" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "NsPlugin", "StatusCheck", "ServiceLabel", "KVScheduler", "VPP", "AddrAlloc" /*"LinuxIfPlugin"*/), + //wire.InterfaceValue(new(API), &IfPlugin{}), + wire.Bind(new(API), new(*IfPlugin)), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + addrallocPlugin netalloc.AddressAllocator, + nsPlugin nsplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + AddrAlloc: addrallocPlugin, + NsPlugin: nsPlugin, + } +} + +func Provider(deps Deps) (*IfPlugin, func(), error) { + p := &IfPlugin{Deps: deps} + p.SetName("vpp-ifplugin") + p.Setup() + cancel := func() { + if err := p.Close(); err != nil { + p.Log.Error(err) + } + } + return p, cancel, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1904/watch_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp1904/watch_vppcalls.go index 7e793d739f..ff5ca65ff2 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1904/watch_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1904/watch_vppcalls.go @@ -126,7 +126,7 @@ func (h *InterfaceVppHandler) WatchDHCPLeases(ctx context.Context, leasesCh chan go func() { h.log.Debugf("start watching DHCP leases") - defer h.log.Debugf("done watching DHCP lease", ctx.Err()) + defer h.log.Debug("done watching DHCP lease", ctx.Err()) for { select { diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1908/watch_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp1908/watch_vppcalls.go index 93e6a6a347..afcdbb02a8 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1908/watch_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1908/watch_vppcalls.go @@ -126,7 +126,7 @@ func (h *InterfaceVppHandler) WatchDHCPLeases(ctx context.Context, leasesCh chan go func() { h.log.Debugf("start watching DHCP leases") - defer h.log.Debugf("done watching DHCP lease", ctx.Err()) + defer h.log.Debug("done watching DHCP lease", ctx.Err()) for { select { diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go index 9fd98ee599..3487dbd231 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go @@ -126,7 +126,7 @@ func (h *InterfaceVppHandler) WatchDHCPLeases(ctx context.Context, leasesCh chan go func() { h.log.Debugf("start watching DHCP leases") - defer h.log.Debugf("done watching DHCP lease", ctx.Err()) + defer h.log.Debug("done watching DHCP lease", ctx.Err()) for { select { diff --git a/plugins/vpp/import_test.go b/plugins/vpp/import_test.go deleted file mode 100644 index 1106928329..0000000000 --- a/plugins/vpp/import_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp_test - -import ( - "fmt" - "log" - "reflect" - "testing" - - "git.fd.io/govpp.git/api" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - - // force import of all vpp plugins - _ "go.ligato.io/vpp-agent/v3/cmd/vpp-agent/app" -) - -func TestVppHandlers(t *testing.T) { - handlers := vpp.GetHandlers() - log.Printf("%d handlers:", len(handlers)) - - for h, handler := range handlers { - log.Printf("- handler: %-10s (%v)", h, handler.Versions()) - } -} - -func TestBinapiMessage(t *testing.T) { - msgTypes := api.GetRegisteredMessageTypes() - log.Printf("%d binapi messages:", len(msgTypes)) - - for msgType := range msgTypes { - typ := msgType.Elem() - msg := reflect.New(typ).Interface().(api.Message) - id := fmt.Sprintf("%s_%s", msg.GetMessageName(), msg.GetCrcString()) - log.Printf("- msg: %s - %s (%v)", typ.String(), typ.PkgPath(), id) - } -} diff --git a/plugins/vpp/ipsecplugin/options.go b/plugins/vpp/ipsecplugin/options.go index a8bd2ada30..e4fde1b196 100644 --- a/plugins/vpp/ipsecplugin/options.go +++ b/plugins/vpp/ipsecplugin/options.go @@ -15,14 +15,42 @@ package ipsecplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*IPSecPlugin, error) { + p := &IPSecPlugin{Deps: deps} + p.SetName("vpp-ipsecplugin") + p.Log = logging.ForPlugin("vpp-ipsecplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of IPSec plugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/l2plugin/options.go b/plugins/vpp/l2plugin/options.go index d52c228da6..dc77e27ed5 100644 --- a/plugins/vpp/l2plugin/options.go +++ b/plugins/vpp/l2plugin/options.go @@ -15,14 +15,43 @@ package l2plugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "StatusCheck", "IfPlugin", "KVScheduler", "VPP"), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*L2Plugin, error) { + p := &L2Plugin{Deps: deps} + p.SetName("vpp-l2plugin") + p.Log = logging.ForPlugin("vpp-l2plugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of L2Plugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/l3plugin/options.go b/plugins/vpp/l3plugin/options.go index 7511e09b26..d93dfdd924 100644 --- a/plugins/vpp/l3plugin/options.go +++ b/plugins/vpp/l3plugin/options.go @@ -15,15 +15,47 @@ package l3plugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/netalloc" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, + //wire.Struct(new(Deps), "StatusCheck", "AddrAlloc", "IfPlugin", "KVScheduler", "VPP"), + wire.Bind(new(API), new(*L3Plugin)), +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + addrallocPlugin netalloc.AddressAllocator, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + AddrAlloc: addrallocPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*L3Plugin, error) { + p := &L3Plugin{Deps: deps} + p.SetName("vpp-l3-plugin") + p.Setup() + return p, p.Init() +} + // DefaultPlugin is a default instance of IfPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/natplugin/options.go b/plugins/vpp/natplugin/options.go index 0af4c93a34..50d478e91f 100644 --- a/plugins/vpp/natplugin/options.go +++ b/plugins/vpp/natplugin/options.go @@ -15,14 +15,42 @@ package natplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*NATPlugin, error) { + p := &NATPlugin{Deps: deps} + p.SetName("vpp-natplugin") + p.Log = logging.ForPlugin("vpp-natplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of NATPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/puntplugin/options.go b/plugins/vpp/puntplugin/options.go index 97c347ebad..486f838896 100644 --- a/plugins/vpp/puntplugin/options.go +++ b/plugins/vpp/puntplugin/options.go @@ -15,13 +15,43 @@ package puntplugin import ( + "github.com/google/wire" + "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + //PublishState: TODO + } +} + +func Provider(deps Deps) (*PuntPlugin, error) { + p := &PuntPlugin{Deps: deps} + p.SetName("vpp-puntplugin") + p.Log = logging.ForPlugin("vpp-puntplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of punt plugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/srplugin/options.go b/plugins/vpp/srplugin/options.go index e0b42605bf..aad8774ed0 100644 --- a/plugins/vpp/srplugin/options.go +++ b/plugins/vpp/srplugin/options.go @@ -15,14 +15,42 @@ package srplugin import ( + "github.com/google/wire" "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + Scheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*SRPlugin, error) { + p := &SRPlugin{Deps: deps} + p.SetName("vpp-srplugin") + p.Log = logging.ForPlugin("vpp-srplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of SRPlugin. var DefaultPlugin = *NewPlugin() diff --git a/plugins/vpp/stnplugin/options.go b/plugins/vpp/stnplugin/options.go index 3609093bf0..a6e43a2184 100644 --- a/plugins/vpp/stnplugin/options.go +++ b/plugins/vpp/stnplugin/options.go @@ -15,13 +15,42 @@ package stnplugin import ( + "github.com/google/wire" + "go.ligato.io/cn-infra/v2/health/statuscheck" "go.ligato.io/cn-infra/v2/logging" "go.ligato.io/vpp-agent/v3/plugins/govppmux" "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + kvs "go.ligato.io/vpp-agent/v3/plugins/kvscheduler/api" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" ) +var Wire = wire.NewSet( + Provider, + DepsProvider, +) + +func DepsProvider( + scheduler kvs.KVScheduler, + govppmuxPlugin govppmux.API, + ifPlugin ifplugin.API, + statuscheck statuscheck.PluginStatusWriter, +) Deps { + return Deps{ + StatusCheck: statuscheck, + KVScheduler: scheduler, + VPP: govppmuxPlugin, + IfPlugin: ifPlugin, + } +} + +func Provider(deps Deps) (*STNPlugin, error) { + p := &STNPlugin{Deps: deps} + p.SetName("vpp-stnplugin") + p.Log = logging.ForPlugin("vpp-stnplugin") + return p, p.Init() +} + // DefaultPlugin is a default instance of STN plugin. var DefaultPlugin = *NewPlugin() diff --git a/utils.go b/utils.go new file mode 100644 index 0000000000..78ef3f6fa8 --- /dev/null +++ b/utils.go @@ -0,0 +1,52 @@ +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package vppagent + +import ( + "os" + "os/signal" + "reflect" + + "go.ligato.io/cn-infra/v2/infra" + "go.ligato.io/cn-infra/v2/logging" +) + +func waitForSignal() chan os.Signal { + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + logging.Infof("waiting for signal..") + return c +} + +func runAfterInit(x interface{}) { + p, ok := x.(infra.PostInit) + if !ok { + return + } + if err := p.AfterInit(); err != nil { + panic(err) + } +} + +func forEachField(v interface{}, cb func(field interface{})) { + val := reflect.ValueOf(v) + for i := 0; i < val.NumField(); i++ { + field := val.Field(i) + if field.IsNil() { + continue + } + cb(field.Interface()) + } +} diff --git a/wire.go b/wire.go new file mode 100644 index 0000000000..19d9363ed9 --- /dev/null +++ b/wire.go @@ -0,0 +1,125 @@ +// Copyright (c) 2020 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//+build wireinject + +package vppagent + +import ( + "context" + + "github.com/google/wire" + cninfra "go.ligato.io/cn-infra/v2" + "go.ligato.io/cn-infra/v2/config" + "go.ligato.io/cn-infra/v2/datasync/resync" + "go.ligato.io/cn-infra/v2/health/probe" + "go.ligato.io/cn-infra/v2/health/statuscheck" + "go.ligato.io/cn-infra/v2/rpc/grpc" + "go.ligato.io/cn-infra/v2/rpc/prometheus" + "go.ligato.io/cn-infra/v2/servicelabel" +) + +//go:generate wire + +func InjectDefaultVPPAgent(ctx context.Context) (a Agent, c func(), e error) { + wire.Build( + cninfra.WireDefaultAll, + + cninfra.CoreProviders, + cninfra.ServerProviders, + + cninfra.WireDefaultConfig, + cninfra.WireLogManager, + cninfra.WirePrometheusProbe, + + resync.WireDefault, + + WireKVScheduler, + WireOrchestrator, + + // Dataplane components with plugins + WireDefaultNetAlloc, + WireDefaultLinux, + WireDefaultVPP, + + // Dataplane-related components + WireGoVppMux, + WireConfigurator, + WireRestAPI, + WireTelemetry, + + wire.Struct(new(Agent), "*"), + ) + return +} + +func InjectAgent(ctx context.Context, conf config.Config, + core cninfra.Base, server cninfra.Server) (a Agent, c func(), e error) { + wire.Build( + //cninfra.InjectDefaultCore, + //cninfra.InjectDefaultServer, + + /*cninfra.ProvideServiceLabelReaderAPI, + cninfra.ProvideStatusCheckStatusReader, + cninfra.ProvideStatusCheckPluginStatusWriter, + cninfra.ProvideRestHTTPHandlers, + cninfra.ProvideGrpcServer,*/ + + wire.FieldsOf(new(cninfra.Base), "ServiceLabel"), + wire.Bind(new(servicelabel.ReaderAPI), new(*servicelabel.Plugin)), + + wire.FieldsOf(new(cninfra.Base), "StatusCheck"), + wire.Bind(new(statuscheck.StatusReader), new(*statuscheck.Plugin)), + wire.Bind(new(statuscheck.PluginStatusWriter), new(*statuscheck.Plugin)), + + // Injecting HTTP & GRPC server as deps + + // 1. using helper function which returns proper API interface: + cninfra.ProvideRestHTTPHandlers, + //cninfra.GrpcServerProvider, + + // 2. or by manually extracting GRPC field and binding it to interface: + wire.FieldsOf(new(cninfra.Server), "GRPC"), + wire.Bind(new(grpc.Server), new(*grpc.Plugin)), + //wire.FieldsOf(new(cninfra.Server), "HTTP"), + //wire.Bind(new(rest.HTTPHandlers), new(*rest.Plugin)), + + //wire.FieldsOf(new(cninfra.Core), "LogRegistry"), + //logmanager.WireDefault, + cninfra.WireLogManager, + + resync.WireDefault, + probe.WireDefault, + prometheus.WireDefault, + //cninfra.WirePrometheusProbe, + + WireKVScheduler, + WireOrchestrator, + + // Dataplane components with plugins + WireDefaultNetAlloc, + WireDefaultLinux, + WireDefaultVPP, + + // Dataplane related components + WireGoVppMux, + WireConfigurator, + WireRestAPI, + WireTelemetry, + //wire.Bind(new(telemetry.InterfaceIndexProvider), new(*ifplugin.IfPlugin)), + + wire.Struct(new(Agent), "*"), + ) + return +} diff --git a/wire_gen.go b/wire_gen.go new file mode 100644 index 0000000000..f3e607606a --- /dev/null +++ b/wire_gen.go @@ -0,0 +1,762 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package vppagent + +import ( + "context" + "go.ligato.io/cn-infra/v2" + "go.ligato.io/cn-infra/v2/config" + "go.ligato.io/cn-infra/v2/datasync" + "go.ligato.io/cn-infra/v2/datasync/kvdbsync/local" + "go.ligato.io/cn-infra/v2/datasync/resync" + "go.ligato.io/cn-infra/v2/health/probe" + "go.ligato.io/cn-infra/v2/logging" + "go.ligato.io/cn-infra/v2/logging/logmanager" + "go.ligato.io/cn-infra/v2/rpc/prometheus" + "go.ligato.io/vpp-agent/v3/plugins/configurator" + "go.ligato.io/vpp-agent/v3/plugins/govppmux" + "go.ligato.io/vpp-agent/v3/plugins/kvscheduler" + ifplugin2 "go.ligato.io/vpp-agent/v3/plugins/linux/ifplugin" + "go.ligato.io/vpp-agent/v3/plugins/linux/iptablesplugin" + l3plugin2 "go.ligato.io/vpp-agent/v3/plugins/linux/l3plugin" + "go.ligato.io/vpp-agent/v3/plugins/linux/nsplugin" + "go.ligato.io/vpp-agent/v3/plugins/netalloc" + "go.ligato.io/vpp-agent/v3/plugins/orchestrator" + "go.ligato.io/vpp-agent/v3/plugins/restapi" + "go.ligato.io/vpp-agent/v3/plugins/telemetry" + "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin" + "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin" +) + +// Injectors from wire.go: + +func InjectDefaultVPPAgent(ctx context.Context) (Agent, func(), error) { + config := _wireConfigValue + base, cleanup, err := cninfra.InjectDefaultBase(ctx, config) + if err != nil { + return Agent{}, nil, err + } + server, cleanup2, err := cninfra.InjectDefaultServer(ctx, config) + if err != nil { + cleanup() + return Agent{}, nil, err + } + readerAPI := cninfra.ProvideServiceLabelReaderAPI(base) + registry := _wireRegistryValue + httpHandlers := cninfra.ProvideRestHTTPHandlers(server) + deps := logmanager.Deps{ + ServiceLabel: readerAPI, + LogRegistry: registry, + HTTP: httpHandlers, + } + logmanagerConfig := logmanager.ConfigProvider(config) + plugin, err := logmanager.Provider(deps, logmanagerConfig) + if err != nil { + cleanup2() + cleanup() + return Agent{}, nil, err + } + statusReader := cninfra.ProvideStatusCheckStatusReader(base) + prometheusDeps := prometheus.Deps{ + HTTP: httpHandlers, + } + prometheusPlugin, err := prometheus.Provider(prometheusDeps) + if err != nil { + cleanup2() + cleanup() + return Agent{}, nil, err + } + probeDeps := probe.Deps{ + ServiceLabel: readerAPI, + StatusCheck: statusReader, + HTTP: httpHandlers, + Prometheus: prometheusPlugin, + } + probePlugin, err := probe.Provider(probeDeps) + if err != nil { + cleanup2() + cleanup() + return Agent{}, nil, err + } + kvschedulerDeps := kvscheduler.Deps{ + HTTPHandlers: httpHandlers, + } + scheduler, cleanup3, err := KVSchedulerProvider(kvschedulerDeps) + if err != nil { + cleanup2() + cleanup() + return Agent{}, nil, err + } + grpcServer := cninfra.ProvideGrpcServer(server) + keyValProtoWatcher := _wireSyncbaseRegistryValue + keyProtoValWriter := _wireKeyProtoValWriterValue + orchestratorDeps := orchestrator.Deps{ + GRPC: grpcServer, + KVScheduler: scheduler, + Watcher: keyValProtoWatcher, + StatusPublisher: keyProtoValWriter, + } + orchestratorPlugin, err := OrchestratorProvider(orchestratorDeps) + if err != nil { + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + netallocDeps := netalloc.DepsProvider(scheduler) + netallocPlugin, err := netalloc.Provider(netallocDeps) + if err != nil { + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + pluginStatusWriter := cninfra.ProvideStatusCheckPluginStatusWriter(base) + resyncPlugin, cleanup4, err := resync.Provider() + if err != nil { + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + govppmuxDeps := govppmux.Deps{ + HTTPHandlers: httpHandlers, + StatusCheck: pluginStatusWriter, + Resync: resyncPlugin, + } + govppmuxPlugin, cleanup5, err := GovppProvider(govppmuxDeps) + if err != nil { + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + nspluginDeps := nsplugin.DepsProvider(scheduler) + nspluginConfig := nsplugin.ConfigProvider(config) + nsPlugin, cleanup6, err := nsplugin.Provider(nspluginDeps, nspluginConfig) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + ifpluginDeps := ifplugin.DepsProvider(scheduler, govppmuxPlugin, netallocPlugin, nsPlugin, pluginStatusWriter) + ifPlugin, cleanup7, err := ifplugin.Provider(ifpluginDeps) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + aclpluginDeps := aclplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + aclPlugin, err := aclplugin.Provider(aclpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + abfpluginDeps := abfplugin.DepsProvider(scheduler, govppmuxPlugin, aclPlugin, ifPlugin, pluginStatusWriter) + abfPlugin, err := abfplugin.Provider(abfpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + ipsecpluginDeps := ipsecplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + ipSecPlugin, err := ipsecplugin.Provider(ipsecpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + l2pluginDeps := l2plugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + l2Plugin, err := l2plugin.Provider(l2pluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + l3pluginDeps := l3plugin.DepsProvider(scheduler, govppmuxPlugin, netallocPlugin, ifPlugin, pluginStatusWriter) + l3Plugin, err := l3plugin.Provider(l3pluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + natpluginDeps := natplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + natPlugin, err := natplugin.Provider(natpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + puntpluginDeps := puntplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + puntPlugin, err := puntplugin.Provider(puntpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + stnpluginDeps := stnplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + stnPlugin, err := stnplugin.Provider(stnpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + srpluginDeps := srplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, pluginStatusWriter) + srPlugin, err := srplugin.Provider(srpluginDeps) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + vpp := VPP{ + ABF: abfPlugin, + ACL: aclPlugin, + Interface: ifPlugin, + IPSec: ipSecPlugin, + L2: l2Plugin, + L3: l3Plugin, + NAT: natPlugin, + Punt: puntPlugin, + STN: stnPlugin, + SR: srPlugin, + } + deps2 := ifplugin2.DepsProvider(scheduler, netallocPlugin, nsPlugin, ifPlugin, readerAPI) + ifpluginIfPlugin, cleanup8, err := ifplugin2.Provider(deps2) + if err != nil { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + deps3 := l3plugin2.DepsProvider(scheduler, netallocPlugin, nsPlugin, ifpluginIfPlugin) + l3pluginConfig := l3plugin2.ConfigProvider(config) + l3pluginL3Plugin, err := l3plugin2.Provider(deps3, l3pluginConfig) + if err != nil { + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + iptablespluginDeps := iptablesplugin.DepsProvider(scheduler, nsPlugin) + iptablespluginConfig := iptablesplugin.ConfigProvider(config) + ipTablesPlugin, err := iptablesplugin.Provider(iptablespluginDeps, iptablespluginConfig) + if err != nil { + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + linux := Linux{ + Interface: ifpluginIfPlugin, + L3: l3pluginL3Plugin, + NS: nsPlugin, + IPTables: ipTablesPlugin, + } + configuratorDeps := configurator.Deps{ + GRPCServer: grpcServer, + Dispatch: orchestratorPlugin, + VPP: govppmuxPlugin, + ServiceLabel: readerAPI, + AddrAlloc: netallocPlugin, + VPPACLPlugin: aclPlugin, + VPPIfPlugin: ifPlugin, + VPPL2Plugin: l2Plugin, + VPPL3Plugin: l3Plugin, + LinuxIfPlugin: ifpluginIfPlugin, + NsPlugin: nsPlugin, + } + configuratorPlugin, err := ConfiguratorProvider(configuratorDeps) + if err != nil { + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + restapiDeps := restapi.Deps{ + HTTPHandlers: httpHandlers, + VPP: govppmuxPlugin, + ServiceLabel: readerAPI, + AddrAlloc: netallocPlugin, + VPPACLPlugin: aclPlugin, + VPPIfPlugin: ifPlugin, + VPPL2Plugin: l2Plugin, + VPPL3Plugin: l3Plugin, + LinuxIfPlugin: ifpluginIfPlugin, + NsPlugin: nsPlugin, + } + restapiPlugin, err := RestapiProvider(restapiDeps) + if err != nil { + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + telemetryDeps := telemetry.Deps{ + ServiceLabel: readerAPI, + VPP: govppmuxPlugin, + Prometheus: prometheusPlugin, + GRPC: grpcServer, + HTTPHandlers: httpHandlers, + IfPlugin: ifPlugin, + } + telemetryPlugin, cleanup9, err := TelemetryProvider(telemetryDeps) + if err != nil { + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + agent := Agent{ + Base: base, + Server: server, + LogManager: plugin, + Probe: probePlugin, + Prometheus: prometheusPlugin, + KVScheduler: scheduler, + Orchestrator: orchestratorPlugin, + Netalloc: netallocPlugin, + VPP: vpp, + VPPClient: govppmuxPlugin, + Linux: linux, + Configurator: configuratorPlugin, + RestAPI: restapiPlugin, + Telemetry: telemetryPlugin, + } + return agent, func() { + cleanup9() + cleanup8() + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + }, nil +} + +var ( + _wireConfigValue = config.DefaultConfig + _wireRegistryValue = logging.DefaultRegistry + _wireSyncbaseRegistryValue = local.DefaultRegistry + _wireKeyProtoValWriterValue = (datasync.KeyProtoValWriter)(nil) +) + +func InjectAgent(ctx context.Context, conf config.Config, core cninfra.Base, server cninfra.Server) (Agent, func(), error) { + plugin := core.ServiceLabel + registry := _wireRegistryValue + httpHandlers := cninfra.ProvideRestHTTPHandlers(server) + deps := logmanager.Deps{ + ServiceLabel: plugin, + LogRegistry: registry, + HTTP: httpHandlers, + } + logmanagerConfig := logmanager.ConfigProvider(conf) + logmanagerPlugin, err := logmanager.Provider(deps, logmanagerConfig) + if err != nil { + return Agent{}, nil, err + } + statuscheckPlugin := core.StatusCheck + prometheusDeps := prometheus.Deps{ + HTTP: httpHandlers, + } + prometheusPlugin, err := prometheus.Provider(prometheusDeps) + if err != nil { + return Agent{}, nil, err + } + probeDeps := probe.Deps{ + ServiceLabel: plugin, + StatusCheck: statuscheckPlugin, + HTTP: httpHandlers, + Prometheus: prometheusPlugin, + } + probePlugin, err := probe.Provider(probeDeps) + if err != nil { + return Agent{}, nil, err + } + kvschedulerDeps := kvscheduler.Deps{ + HTTPHandlers: httpHandlers, + } + scheduler, cleanup, err := KVSchedulerProvider(kvschedulerDeps) + if err != nil { + return Agent{}, nil, err + } + grpcPlugin := server.GRPC + keyValProtoWatcher := _wireSyncbaseRegistryValue + keyProtoValWriter := _wireKeyProtoValWriterValue + orchestratorDeps := orchestrator.Deps{ + GRPC: grpcPlugin, + KVScheduler: scheduler, + Watcher: keyValProtoWatcher, + StatusPublisher: keyProtoValWriter, + } + orchestratorPlugin, err := OrchestratorProvider(orchestratorDeps) + if err != nil { + cleanup() + return Agent{}, nil, err + } + netallocDeps := netalloc.DepsProvider(scheduler) + netallocPlugin, err := netalloc.Provider(netallocDeps) + if err != nil { + cleanup() + return Agent{}, nil, err + } + resyncPlugin, cleanup2, err := resync.Provider() + if err != nil { + cleanup() + return Agent{}, nil, err + } + govppmuxDeps := govppmux.Deps{ + HTTPHandlers: httpHandlers, + StatusCheck: statuscheckPlugin, + Resync: resyncPlugin, + } + govppmuxPlugin, cleanup3, err := GovppProvider(govppmuxDeps) + if err != nil { + cleanup2() + cleanup() + return Agent{}, nil, err + } + nspluginDeps := nsplugin.DepsProvider(scheduler) + nspluginConfig := nsplugin.ConfigProvider(conf) + nsPlugin, cleanup4, err := nsplugin.Provider(nspluginDeps, nspluginConfig) + if err != nil { + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + ifpluginDeps := ifplugin.DepsProvider(scheduler, govppmuxPlugin, netallocPlugin, nsPlugin, statuscheckPlugin) + ifPlugin, cleanup5, err := ifplugin.Provider(ifpluginDeps) + if err != nil { + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + aclpluginDeps := aclplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + aclPlugin, err := aclplugin.Provider(aclpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + abfpluginDeps := abfplugin.DepsProvider(scheduler, govppmuxPlugin, aclPlugin, ifPlugin, statuscheckPlugin) + abfPlugin, err := abfplugin.Provider(abfpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + ipsecpluginDeps := ipsecplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + ipSecPlugin, err := ipsecplugin.Provider(ipsecpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + l2pluginDeps := l2plugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + l2Plugin, err := l2plugin.Provider(l2pluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + l3pluginDeps := l3plugin.DepsProvider(scheduler, govppmuxPlugin, netallocPlugin, ifPlugin, statuscheckPlugin) + l3Plugin, err := l3plugin.Provider(l3pluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + natpluginDeps := natplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + natPlugin, err := natplugin.Provider(natpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + puntpluginDeps := puntplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + puntPlugin, err := puntplugin.Provider(puntpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + stnpluginDeps := stnplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + stnPlugin, err := stnplugin.Provider(stnpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + srpluginDeps := srplugin.DepsProvider(scheduler, govppmuxPlugin, ifPlugin, statuscheckPlugin) + srPlugin, err := srplugin.Provider(srpluginDeps) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + vpp := VPP{ + ABF: abfPlugin, + ACL: aclPlugin, + Interface: ifPlugin, + IPSec: ipSecPlugin, + L2: l2Plugin, + L3: l3Plugin, + NAT: natPlugin, + Punt: puntPlugin, + STN: stnPlugin, + SR: srPlugin, + } + deps2 := ifplugin2.DepsProvider(scheduler, netallocPlugin, nsPlugin, ifPlugin, plugin) + ifpluginIfPlugin, cleanup6, err := ifplugin2.Provider(deps2) + if err != nil { + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + deps3 := l3plugin2.DepsProvider(scheduler, netallocPlugin, nsPlugin, ifpluginIfPlugin) + l3pluginConfig := l3plugin2.ConfigProvider(conf) + l3pluginL3Plugin, err := l3plugin2.Provider(deps3, l3pluginConfig) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + iptablespluginDeps := iptablesplugin.DepsProvider(scheduler, nsPlugin) + iptablespluginConfig := iptablesplugin.ConfigProvider(conf) + ipTablesPlugin, err := iptablesplugin.Provider(iptablespluginDeps, iptablespluginConfig) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + linux := Linux{ + Interface: ifpluginIfPlugin, + L3: l3pluginL3Plugin, + NS: nsPlugin, + IPTables: ipTablesPlugin, + } + configuratorDeps := configurator.Deps{ + GRPCServer: grpcPlugin, + Dispatch: orchestratorPlugin, + VPP: govppmuxPlugin, + ServiceLabel: plugin, + AddrAlloc: netallocPlugin, + VPPACLPlugin: aclPlugin, + VPPIfPlugin: ifPlugin, + VPPL2Plugin: l2Plugin, + VPPL3Plugin: l3Plugin, + LinuxIfPlugin: ifpluginIfPlugin, + NsPlugin: nsPlugin, + } + configuratorPlugin, err := ConfiguratorProvider(configuratorDeps) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + restapiDeps := restapi.Deps{ + HTTPHandlers: httpHandlers, + VPP: govppmuxPlugin, + ServiceLabel: plugin, + AddrAlloc: netallocPlugin, + VPPACLPlugin: aclPlugin, + VPPIfPlugin: ifPlugin, + VPPL2Plugin: l2Plugin, + VPPL3Plugin: l3Plugin, + LinuxIfPlugin: ifpluginIfPlugin, + NsPlugin: nsPlugin, + } + restapiPlugin, err := RestapiProvider(restapiDeps) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + telemetryDeps := telemetry.Deps{ + ServiceLabel: plugin, + VPP: govppmuxPlugin, + Prometheus: prometheusPlugin, + GRPC: grpcPlugin, + HTTPHandlers: httpHandlers, + IfPlugin: ifPlugin, + } + telemetryPlugin, cleanup7, err := TelemetryProvider(telemetryDeps) + if err != nil { + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + return Agent{}, nil, err + } + agent := Agent{ + Base: core, + Server: server, + LogManager: logmanagerPlugin, + Probe: probePlugin, + Prometheus: prometheusPlugin, + KVScheduler: scheduler, + Orchestrator: orchestratorPlugin, + Netalloc: netallocPlugin, + VPP: vpp, + VPPClient: govppmuxPlugin, + Linux: linux, + Configurator: configuratorPlugin, + RestAPI: restapiPlugin, + Telemetry: telemetryPlugin, + } + return agent, func() { + cleanup7() + cleanup6() + cleanup5() + cleanup4() + cleanup3() + cleanup2() + cleanup() + }, nil +}