From 30276f3db175b4d78e9f271e2692f583b161c3a2 Mon Sep 17 00:00:00 2001 From: toby cabot Date: Wed, 13 Dec 2023 11:25:08 -0500 Subject: [PATCH] Use the new VERSION file to report the TrueIngress version This removes our dependency on the TrueIngress go module, which wasn't very useful as it just called the TrueIngress executables and we can do that ourselves. Signed-off-by: toby cabot --- cmd/adhoc-agent.go | 8 +++++--- cmd/node-agent.go | 13 +++---------- go.mod | 1 - go.sum | 2 -- internal/exec/run_script.go | 2 +- internal/pfc/setup.go | 11 +++++++++++ 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/cmd/adhoc-agent.go b/cmd/adhoc-agent.go index 94e4d6d..b272d35 100644 --- a/cmd/adhoc-agent.go +++ b/cmd/adhoc-agent.go @@ -7,7 +7,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "epic-gateway.org/resource-model/controllers" - "epic-gateway.org/resource-model/internal/exec" "epic-gateway.org/resource-model/internal/network" "epic-gateway.org/resource-model/internal/pfc" // +kubebuilder:scaffold:imports @@ -75,8 +74,11 @@ func runAdhocAgent(cmd *cobra.Command, args []string) error { setupLog.V(1).Info("Cleaning up TrueIngress") - // Empty the PFC tables. - if err := exec.RunScript(setupLog, "/opt/acnodal/bin/pfc_cli_go initialize"); err != nil { + // See if the PFC is installed + pfc.Check(setupLog) + + // Empty the PFC tables + if err := pfc.Initialize(setupLog); err != nil { return err } diff --git a/cmd/node-agent.go b/cmd/node-agent.go index 2fb42cd..9895333 100644 --- a/cmd/node-agent.go +++ b/cmd/node-agent.go @@ -10,8 +10,7 @@ import ( epicv1 "epic-gateway.org/resource-model/api/v1" "epic-gateway.org/resource-model/controllers" - "epic-gateway.org/resource-model/internal/exec" - "epic-gateway.org/true-ingress/pfc" + "epic-gateway.org/resource-model/internal/pfc" // +kubebuilder:scaffold:imports ) @@ -88,16 +87,10 @@ func runNodeAgent(cmd *cobra.Command, args []string) error { } // See if the PFC is installed - ok, message := pfc.Check() - if ok { - // print the version - setupLog.Info("PFC", "version", message) - } else { - setupLog.Info("PFC Error", "message", message) - } + pfc.Check(setupLog) // Empty the PFC tables - if err := exec.RunScript(setupLog, "/opt/acnodal/bin/pfc_cli_go initialize"); err != nil { + if err := pfc.Initialize(setupLog); err != nil { return err } diff --git a/go.mod b/go.mod index 2ea3760..370a0ca 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.19 replace github.com/3scale-ops/marin3r => epic-gateway.org/marin3r v0.9.1-epic7 require ( - epic-gateway.org/true-ingress v0.22.4 github.com/3scale-ops/marin3r v0.9.1 github.com/containernetworking/plugins v0.8.7 github.com/go-logr/logr v1.2.0 diff --git a/go.sum b/go.sum index 2daad0c..000a759 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= epic-gateway.org/marin3r v0.9.1-epic7 h1:YuEyZTZdJUs27qrkcW2o/xWe/f1SJpjSpJcQALmHFSE= epic-gateway.org/marin3r v0.9.1-epic7/go.mod h1:bVIvwvEFiAtfPZnjDUJBt4Ujb6jvfeqzemOBmaEw750= -epic-gateway.org/true-ingress v0.22.4 h1:6y3NOAK8XvRGEwvhO6LUzi1C+jMQbVkF0T3WNshSkgo= -epic-gateway.org/true-ingress v0.22.4/go.mod h1:V2xlNKPoJvztoDAyyWxHmPNuTqwfWQGOxlObDeRpGVI= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= diff --git a/internal/exec/run_script.go b/internal/exec/run_script.go index c324a84..7f6ee85 100644 --- a/internal/exec/run_script.go +++ b/internal/exec/run_script.go @@ -15,7 +15,7 @@ func RunScript(log logr.Logger, script string) error { if stdoutStderr, err := cmd.CombinedOutput(); err != nil { log.Error(err, "Script FAILED", "script", script, "combined-output", string(stdoutStderr)) } else { - log.V(1).Info("Script succeeded", "script", script) + log.V(1).Info("Script succeeded", "script", script, "combined-output", string(stdoutStderr)) } return err diff --git a/internal/pfc/setup.go b/internal/pfc/setup.go index 0093771..c985ab1 100644 --- a/internal/pfc/setup.go +++ b/internal/pfc/setup.go @@ -57,3 +57,14 @@ func configure(log logr.Logger, nic string, qid int, flags int) error { script := fmt.Sprintf("/opt/acnodal/bin/cli_cfg set %[1]s %[2]d %[3]d", nic, qid, flags) return epicexec.RunScript(log, script) } + +func Check(log logr.Logger) error { + return epicexec.RunScript(log, "cat /opt/acnodal/bin/VERSION") +} + +func Initialize(log logr.Logger) error { + if err := epicexec.RunScript(log, fmt.Sprintf("/opt/acnodal/bin/cli_service del all")); err != nil { + return err + } + return epicexec.RunScript(log, fmt.Sprintf("/opt/acnodal/bin/cli_tunnel del all")) +}