Skip to content

Commit

Permalink
Add OVS groups to support bundle (#6195)
Browse files Browse the repository at this point in the history
Fixes #6066

Signed-off-by: Shikhar Soni <shikharish05@gmail.com>
  • Loading branch information
shikharish authored Apr 9, 2024
1 parent 7bd05a9 commit d893e06
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func (c *SupportBundleController) generateSupportBundle(supportBundle *cpv1b2.Su
if err = agentDumper.DumpFlows(basedir); err != nil {
return err
}
if err = agentDumper.DumpGroups(basedir); err != nil {
return err
}
if err = agentDumper.DumpNetworkPolicyResources(basedir); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ func TestSupportBundleCollectionAdd(t *testing.T) {
agentDumper: &mockAgentDumper{dumpGoroutinePprofErr: fmt.Errorf("failed to dump goroutine Pprof")},
uploader: &testUploader{},
},
{
name: "SupportBundleCollection failed to dump groups",
supportBundleCollection: generateSupportbundleCollection("supportBundle13", "sftp://10.220.175.92:22/root/supportbundle"),
expectedCompleted: false,
agentDumper: &mockAgentDumper{dumpGroupsErr: fmt.Errorf("failed to dump groups")},
uploader: &testUploader{},
},
}

for _, tt := range testcases {
Expand Down Expand Up @@ -225,6 +232,7 @@ func generateSupportbundleCollection(name string, url string) *cpv1b2.SupportBun
type mockAgentDumper struct {
dumpLogErr error
dumpFlowsErr error
dumpGroupsErr error
dumpHostNetworkInfoErr error
dumpAgentInfoErr error
dumpNetworkPolicyResourcesErr error
Expand All @@ -242,6 +250,10 @@ func (d *mockAgentDumper) DumpFlows(basedir string) error {
return d.dumpFlowsErr
}

func (d *mockAgentDumper) DumpGroups(basedir string) error {
return d.dumpGroupsErr
}

func (d *mockAgentDumper) DumpHostNetworkInfo(basedir string) error {
return d.dumpHostNetworkInfoErr
}
Expand Down
1 change: 1 addition & 0 deletions pkg/apiserver/registry/system/supportbundle/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func (r *supportBundleREST) collectAgent(ctx context.Context, since string) (*sy
dumper.DumpLog,
dumper.DumpHostNetworkInfo,
dumper.DumpFlows,
dumper.DumpGroups,
dumper.DumpNetworkPolicyResources,
dumper.DumpAgentInfo,
dumper.DumpHeapPprof,
Expand Down
4 changes: 4 additions & 0 deletions pkg/apiserver/registry/system/supportbundle/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ func (f *fakeAgentDumper) DumpFlows(basedir string) error {
return f.returnErr
}

func (f *fakeAgentDumper) DumpGroups(basedir string) error {
return f.returnErr
}

func (f *fakeAgentDumper) DumpHostNetworkInfo(basedir string) error {
return f.returnErr
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/support/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import (
type AgentDumper interface {
// DumpFlows should create files that contains flows under the basedir.
DumpFlows(basedir string) error
// DumpGroups should create files that contains groups under the basedir
DumpGroups(basedir string) error
// DumpHostNetworkInfo should create files that contains host network
// information under the basedir. Host network information should include
// links, routes, addresses and etc.
Expand Down Expand Up @@ -330,6 +332,14 @@ func (d *agentDumper) DumpFlows(basedir string) error {
return writeFile(d.fs, filepath.Join(basedir, "flows"), "flows", []byte(strings.Join(flows, "\n")))
}

func (d *agentDumper) DumpGroups(basedir string) error {
groups, err := d.ovsCtlClient.DumpGroups()
if err != nil {
return fmt.Errorf("error when dumping groups: %w", err)
}
return writeFile(d.fs, filepath.Join(basedir, "groups"), "groups", []byte(strings.Join(groups, "\n")))
}

func (d *agentDumper) DumpHeapPprof(basedir string) error {
return DumpHeapPprof(d.fs, basedir)
}
Expand Down

0 comments on commit d893e06

Please sign in to comment.