This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bug-report ability to collect control plane logs (#4365)
Adds bug-report ability to collect control plane logs Signed-off-by: Thomas Stringer <[email protected]>
- Loading branch information
1 parent
e5b2754
commit 81b5265
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package bugreport | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path" | ||
"strings" | ||
|
||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/openservicemesh/osm/pkg/constants" | ||
) | ||
|
||
func (c *Config) collectControlPlaneLogs() error { | ||
pods, err := c.KubeClient.CoreV1().Pods(c.ControlPlaneNamepace). | ||
List(context.Background(), v1.ListOptions{ | ||
LabelSelector: fmt.Sprintf( | ||
"%s=%s", | ||
constants.OSMAppNameLabelKey, | ||
constants.OSMAppNameLabelValue, | ||
), | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("error getting control plane pods: %w", err) | ||
} | ||
|
||
for _, pod := range pods.Items { | ||
cmd := []string{"kubectl", "logs", "-n", pod.Namespace, pod.Name} | ||
outPath := path.Join(c.rootNamespaceDirPath(), pod.Namespace, rootPodDirName, pod.Name, commandsDirName, strings.Join(cmd, "_")) | ||
if err := runCmdAndWriteToFile(cmd, outPath); err != nil { | ||
return fmt.Errorf("error writing control pod logs: %w", err) | ||
} | ||
c.completionSuccess("Collected report for Pod %s/%s", pod.Namespace, pod.Name) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters