From 7c8567b5f45aac49d8ea2987dd5683962c701cfe Mon Sep 17 00:00:00 2001 From: marcushines <80116818+marcushines@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:16:07 -0700 Subject: [PATCH] Remove resetter interface from arista as this api doesn't (#449) * Remove resetter interface from arista as this api doesn't work in the default case with arista nodes currently * remove test and skip reset --- cloudbuild/vendors_test.sh | 1 - topo/node/arista/arista.go | 28 ----------- topo/node/arista/arista_test.go | 86 --------------------------------- 3 files changed, 115 deletions(-) diff --git a/cloudbuild/vendors_test.sh b/cloudbuild/vendors_test.sh index 87340690..ba792450 100644 --- a/cloudbuild/vendors_test.sh +++ b/cloudbuild/vendors_test.sh @@ -40,7 +40,6 @@ pushd "$HOME/kne/cloudbuild" go test -v vendors/vendors_test.go \ -testbed testbed.textproto \ -topology topology.textproto \ - -skip_reset \ -vendor_creds ARISTA/admin/admin \ -vendor_creds JUNIPER/root/Google123 \ -vendor_creds CISCO/cisco/cisco123 \ diff --git a/topo/node/arista/arista.go b/topo/node/arista/arista.go index dac0eb56..e9c1c2a7 100644 --- a/topo/node/arista/arista.go +++ b/topo/node/arista/arista.go @@ -22,7 +22,6 @@ import ( "path/filepath" "regexp" "strings" - "time" cpb "github.com/openconfig/kne/proto/ceos" tpb "github.com/openconfig/kne/proto/topo" @@ -65,7 +64,6 @@ type Node struct { var ( _ node.Certer = (*Node)(nil) _ node.ConfigPusher = (*Node)(nil) - _ node.Resetter = (*Node)(nil) ethIntfRe = regexp.MustCompile(`^Ethernet\d+(?:/\d+)?(?:/\d+)?$`) mgmtIntfRe = regexp.MustCompile(`^Management\d+(?:/\d+)?$`) @@ -303,32 +301,6 @@ func (n *Node) ConfigPush(ctx context.Context, r io.Reader) error { return resp.Failed } -func (n *Node) ResetCfg(ctx context.Context) error { - log.Infof("%s resetting config", n.Name()) - - err := n.SpawnCLIConn() - if err != nil { - return err - } - - defer n.cliConn.Close() - - // this takes a long time sometimes, so we crank timeouts up - resp, err := n.cliConn.SendCommand( - "configure replace clean-config", - scrapliopts.WithTimeoutOps(300*time.Second), - ) - if err != nil { - return err - } - - if resp.Failed == nil { - log.Infof("%s - finshed resetting config", n.Name()) - } - - return resp.Failed -} - func defaults(pb *tpb.Node) *tpb.Node { if pb == nil { pb = &tpb.Node{ diff --git a/topo/node/arista/arista_test.go b/topo/node/arista/arista_test.go index 315081f8..3e47747d 100644 --- a/topo/node/arista/arista_test.go +++ b/topo/node/arista/arista_test.go @@ -17,7 +17,6 @@ import ( "context" "fmt" "testing" - "time" ceos "github.com/aristanetworks/arista-ceoslab-operator/v2/api/v1alpha1" ceosclient "github.com/aristanetworks/arista-ceoslab-operator/v2/api/v1alpha1/dynamic" @@ -27,9 +26,6 @@ import ( ceospb "github.com/openconfig/kne/proto/ceos" topopb "github.com/openconfig/kne/proto/topo" "github.com/openconfig/kne/topo/node" - scrapliopts "github.com/scrapli/scrapligo/driver/options" - scraplitransport "github.com/scrapli/scrapligo/transport" - scrapliutil "github.com/scrapli/scrapligo/util" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" @@ -438,85 +434,3 @@ func TestCRD(t *testing.T) { }) } } - -func TestResetCfg(t *testing.T) { - ki := fake.NewSimpleClientset(&corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod1", - }, - }) - - reaction := func(action ktest.Action) (handled bool, ret watch.Interface, err error) { - f := &fakeWatch{ - e: []watch.Event{{ - Object: &corev1.Pod{ - Status: corev1.PodStatus{ - Phase: corev1.PodRunning, - }, - }, - }}, - } - return true, f, nil - } - ki.PrependWatchReactor("*", reaction) - - ni := &node.Impl{ - KubeClient: ki, - Namespace: "test", - Proto: &topopb.Node{ - Name: "pod1", - Vendor: topopb.Vendor_ARISTA, - Config: &topopb.Config{}, - }, - } - - tests := []struct { - desc string - wantErr bool - ni *node.Impl - testFile string - }{ - { - // successfully configure certificate - desc: "success", - wantErr: false, - ni: ni, - testFile: "testdata/reset_config_success", - }, - { - // device returns "% Invalid input" -- we expect to fail - desc: "failure", - wantErr: true, - ni: ni, - testFile: "testdata/reset_config_failure", - }, - } - - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - nImpl, err := New(tt.ni) - - if err != nil { - t.Fatalf("failed creating kne arista node") - } - - n, _ := nImpl.(*Node) - - n.testOpts = []scrapliutil.Option{ - scrapliopts.WithTransportType(scraplitransport.FileTransport), - scrapliopts.WithFileTransportFile(tt.testFile), - scrapliopts.WithTimeoutOps(2 * time.Second), - scrapliopts.WithTransportReadSize(1), - scrapliopts.WithReadDelay(0), - scrapliopts.WithDefaultLogger(), - } - - ctx := context.Background() - - err = n.ResetCfg(ctx) - if err != nil && !tt.wantErr { - t.Fatalf("resetting config failed, error: %+v\n", err) - } - }) - } -}