Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OVS groups to support bundle #6195

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading