e2e: Add envoy config collection
Adds collection of envoy configs on the test:
"config_dump", "clusters", "certs", "listeners", "ready" and "stats".
format:
```
/tmp/test-<id>/envoy_configs
| <namespace_podName>/
| "config_dump.txt"
| "certs.txt"
| "listeners.txt"
...
```
@@ -1386,5 +1386,61 @@ func (td *OsmTestData) GrabLogs() error {
}
}
+ // TODO: Eventually a CLI command should implement collection of configurations necessary for debugging
+ pods, err := td.Client.CoreV1().Pods("").List(context.Background(), metav1.ListOptions{
+ // Reliable way to select injected pods
+ LabelSelector: "osm-proxy-uuid",
+ })
+
+ if err != nil {
+ return err
+ }
+
+ envoyConfDir := td.GetTestFilePath("envoy_configs")
+ err = os.Mkdir(envoyConfDir, 0750)
+ if err != nil && !os.IsExist(err) {
+ td.T.Logf("Error on creating dir for %s: %v", envoyConfDir, err)
+ return err
+ }
+
+ for _, pod := range pods.Items {
+ podEnvoyConfigFilepath := strings.Join([]string{envoyConfDir, fmt.Sprintf("%s_%s", pod.Namespace, pod.Name)}, "/")
+ err := os.Mkdir(podEnvoyConfigFilepath, 0750)
+ if err != nil && !os.IsExist(err) {
+ td.T.Logf("Error on creating dir for %s: %v, skipping", podEnvoyConfigFilepath, err)
+ continue
+ }
+
+ envoyDebugPaths := []string{
+ "config_dump",
+ "clusters",
+ "certs",
+ "listeners",
+ "ready",
+ "stats",
+ }
+
+ for _, dbgEnvoyPath := range envoyDebugPaths {
+ cmd := "../../bin/osm"
+ args := []string{
+ "proxy",
+ "get",
+ dbgEnvoyPath,
+ pod.Name,
+ "--namespace",
+ pod.Namespace,
+ "-f",
+ strings.Join([]string{podEnvoyConfigFilepath, fmt.Sprintf("%s.txt", dbgEnvoyPath)}, "/"),
+ }
+
+ stdout, stderr, err := td.RunLocal(cmd, args)
+ if err != nil {
+ td.T.Logf("error running cmd: %s args: %v", cmd, args)
+ td.T.Logf("stdout:\n%s", stdout)
+ td.T.Logf("stderr:\n%s", stderr)
+ }
+ }
+ }
+
return nil
}
