tests: collect init container logs
Signed-off-by: travisn <tnielsen@redhat.com>
This commit is contained in:
2 files changed
+21
-6
No files matched your search
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package installer
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
@@ -26,18 +27,16 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis"
|
||||
|
||||
"flag"
|
||||
|
||||
cephv1beta1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1beta1"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
opspec "github.com/rook/rook/pkg/operator/ceph/spec"
|
||||
"github.com/rook/rook/tests/framework/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -435,6 +434,11 @@ func (h *CephInstaller) GatherAllRookLogs(namespace, systemNamespace string, tes
|
||||
h.k8shelper.GetRookLogs("rook-ceph-osd-prepare", Env.HostType, namespace, testName)
|
||||
h.k8shelper.GetRookLogs("rook-ceph-rgw", Env.HostType, namespace, testName)
|
||||
h.k8shelper.GetRookLogs("rook-ceph-mds", Env.HostType, namespace, testName)
|
||||
h.k8shelper.GetRookContainerLogs("rook-ceph-mgr", Env.HostType, namespace, testName, opspec.ConfigInitContainerName)
|
||||
h.k8shelper.GetRookContainerLogs("rook-ceph-mon", Env.HostType, namespace, testName, opspec.ConfigInitContainerName)
|
||||
h.k8shelper.GetRookContainerLogs("rook-ceph-osd", Env.HostType, namespace, testName, opspec.ConfigInitContainerName)
|
||||
h.k8shelper.GetRookContainerLogs("rook-ceph-rgw", Env.HostType, namespace, testName, opspec.ConfigInitContainerName)
|
||||
h.k8shelper.GetRookContainerLogs("rook-ceph-mds", Env.HostType, namespace, testName, opspec.ConfigInitContainerName)
|
||||
}
|
||||
|
||||
// NewCephInstaller creates new instance of CephInstaller
|
||||
|
||||
@@ -1403,7 +1403,14 @@ func (k8sh *K8sHelper) IsRookInstalled(namespace string) bool {
|
||||
|
||||
//GetRookLogs captures logs from specified rook pod and writes it to specified file
|
||||
func (k8sh *K8sHelper) GetRookLogs(podAppName string, hostType string, namespace string, testName string) {
|
||||
k8sh.GetRookContainerLogs(podAppName, hostType, namespace, testName, "")
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) GetRookContainerLogs(podAppName, hostType, namespace, testName, containerName string) {
|
||||
logOpts := &v1.PodLogOptions{}
|
||||
if containerName != "" {
|
||||
logOpts.Container = containerName
|
||||
}
|
||||
listOpts := metav1.ListOptions{LabelSelector: "app=" + podAppName}
|
||||
|
||||
podList, err := k8sh.Clientset.CoreV1().Pods(namespace).List(listOpts)
|
||||
@@ -1434,7 +1441,11 @@ func (k8sh *K8sHelper) GetRookLogs(podAppName string, hostType string, namespace
|
||||
continue
|
||||
}
|
||||
}
|
||||
fileName := fmt.Sprintf("%s_%s_%s_%s_%d.log", testName, hostType, podName, namespace, time.Now().Unix())
|
||||
logSuffix := ""
|
||||
if containerName != "" {
|
||||
logSuffix = "_" + containerName
|
||||
}
|
||||
fileName := fmt.Sprintf("%s_%s_%s_%s%s_%d.log", testName, hostType, podName, namespace, logSuffix, time.Now().Unix())
|
||||
fpath = path.Join(fpath, fileName)
|
||||
file, err := os.Create(fpath)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user