A new controller to bootstrap ceph-crash pod on Ceph nodes running Ceph pods only. This implementation is unfortunately a mix of 'hacks' to make the daemon working correclty. The ceph-crash script faced different issues: * it's not a daemon * it does not have any key in cephx * it runs ceph commands under the hood which need an admin key and a ceph.conf On upstream Ceph, ceph-crash needs to grow better, once that happens we will improve our implementation. This also enhances osd provisionConfig struct with DataPathMap Pod volumes and volume mount needs DataPathMap to perform the right actions on log and crash dir. Exposing DataPathMap makes that possible. Obviously, this is exposing ceph crash reports on the host as well as pushing them into the mgr. Basically, if a daemon fails, it'll put its core dump into /var/lib/ceph/crash, bindmounting this dir on the host, ensures that the crashes don't get lost when the pod dies. Example: ``` [leseb@tarox~/go/src/github.com/rook/rook][rgw-liveprobe !] kubectl -n rook-ceph exec -ti rook-ceph-crashcollector-minikube-574858b99c-zvg4z bash bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# ceph crash ls [root@rook-ceph-osd-2-7644f99695-cljzh /]# pidof ceph-osd 13258 5415 5397 [root@rook-ceph-osd-2-7644f99695-cljzh /]# kill -SIGABRT 13258 [root@rook-ceph-osd-2-7644f99695-cljzh /]# ls /var/lib/ceph/crash/ 2019-11-12_12:56:51.404109Z_39f060e1-776d-4605-8f28-85c97e53de96 posted ... wait maximum 10 min (ceph-crash scraps every 10 minutes) ... the container will exit [root@rook-ceph-osd-2-7644f99695-cljzh /]# exit [leseb@tarox~/go/src/github.com/rook/rook][rgw-liveprobe !] [leseb@tarox~/go/src/github.com/rook/rook][rgw-liveprobe !] kubectl -n rook-ceph exec -ti rook-ceph-crashcollector-minikube-574858b99c-zvg4z bash bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# ceph crash ls 2019-11-12_12:56:51.404109Z_39f060e1-776d-4605-8f28-85c97e53de96 osd.1 [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# ls /var/lib/ceph/crash/ posted [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# ls /var/lib/ceph/crash/posted/ 2019-11-12_12:56:51.404109Z_39f060e1-776d-4605-8f28-85c97e53de96 [root@rook-ceph-crashcollector-minikube-574858b99c-zvg4z /]# tail /var/lib/ceph/crash/posted/2019-11-12_12\:56\:51.404109Z_39f060e1-776d-4605-8f28-85c97e53de96/log 1/ 5 mgr 1/ 5 mgrc 1/ 5 dpdk 1/ 5 eventtrace -2/-2 (syslog threshold) -1/-1 (stderr threshold) max_recent 10000 max_new 1000 log_file /var/lib/ceph/crash/2019-11-12_12:56:51.404109Z_39f060e1-776d-4605-8f28-85c97e53de96/log --- end dump of recent events --- ``` Signed-off-by: Sébastien Han <seb@redhat.com> Co-authored-by: Rohan CJ <rohantmp@gmail.com>
169 lines
6.1 KiB
Go
169 lines
6.1 KiB
Go
/*
|
|
Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
|
|
"testing"
|
|
|
|
"github.com/coreos/pkg/capnslog"
|
|
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
|
"github.com/rook/rook/tests/framework/clients"
|
|
"github.com/rook/rook/tests/framework/installer"
|
|
"github.com/rook/rook/tests/framework/utils"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
const (
|
|
defaultNamespace = "default"
|
|
// UPDATE these versions when the integration test matrix changes
|
|
// These versions are for running a minimal test suite for more efficient tests across different versions of K8s
|
|
// instead of running all suites on all versions
|
|
blockMinimalTestVersion = "1.12.0"
|
|
multiClusterMinimalTestVersion = "1.13.0"
|
|
helmMinimalTestVersion = "1.14.0"
|
|
upgradeMinimalTestVersion = "1.15.0"
|
|
smokeSuiteMinimalTestVersion = "1.16.0"
|
|
)
|
|
|
|
var (
|
|
logger = capnslog.NewPackageLogger("github.com/rook/rook", "integrationTest")
|
|
)
|
|
|
|
// Test to make sure all rook components are installed and Running
|
|
func checkIfRookClusterIsInstalled(s suite.Suite, k8sh *utils.K8sHelper, opNamespace, clusterNamespace string, mons int) {
|
|
logger.Infof("Make sure all Pods in Rook Cluster %s are running", clusterNamespace)
|
|
assert.True(s.T(), k8sh.CheckPodCountAndState("rook-ceph-operator", opNamespace, 1, "Running"),
|
|
"Make sure there is 1 rook-operator present in Running state")
|
|
assert.True(s.T(), k8sh.CheckPodCountAndState("rook-ceph-mgr", clusterNamespace, 1, "Running"),
|
|
"Make sure there is 1 rook-ceph-mgr present in Running state")
|
|
assert.True(s.T(), k8sh.CheckPodCountAndState("rook-ceph-osd", clusterNamespace, 1, "Running"),
|
|
"Make sure there is at lest 1 rook-ceph-osd present in Running state")
|
|
assert.True(s.T(), k8sh.CheckPodCountAndState("rook-ceph-mon", clusterNamespace, mons, "Running"),
|
|
fmt.Sprintf("Make sure there are %d rook-ceph-mon present in Running state", mons))
|
|
assert.True(s.T(), k8sh.CheckPodCountAndState("rook-ceph-crashcollector", clusterNamespace, 1, "Running"),
|
|
"Make sure there is at lest 1 rook-ceph-crash present in Running state")
|
|
}
|
|
|
|
func checkIfRookClusterIsHealthy(s suite.Suite, testClient *clients.TestClient, clusterNamespace string) {
|
|
logger.Infof("Testing cluster %s health", clusterNamespace)
|
|
var err error
|
|
|
|
retryCount := 0
|
|
for retryCount < utils.RetryLoop {
|
|
err = clients.IsClusterHealthy(testClient, clusterNamespace)
|
|
if err == nil {
|
|
logger.Infof("cluster %s is healthy", clusterNamespace)
|
|
return
|
|
}
|
|
|
|
retryCount++
|
|
logger.Infof("waiting for cluster %s to become healthy. err: %+v", clusterNamespace, err)
|
|
<-time.After(time.Duration(utils.RetryInterval) * time.Second)
|
|
}
|
|
|
|
require.Nil(s.T(), err)
|
|
}
|
|
|
|
func HandlePanics(r interface{}, op installer.TestSuite, t func() *testing.T) {
|
|
if r != nil {
|
|
logger.Infof("unexpected panic occurred during test %s, --> %v", t().Name(), r)
|
|
t().Fail()
|
|
op.Teardown()
|
|
t().FailNow()
|
|
}
|
|
}
|
|
|
|
// TestCluster struct for handling panic and test suite tear down
|
|
type TestCluster struct {
|
|
installer *installer.CephInstaller
|
|
kh *utils.K8sHelper
|
|
helper *clients.TestClient
|
|
T func() *testing.T
|
|
namespace string
|
|
storeType string
|
|
useDevices bool
|
|
mons int
|
|
rbdMirrorWorkers int
|
|
}
|
|
|
|
func checkIfShouldRunForMinimalTestMatrix(t func() *testing.T, k8sh *utils.K8sHelper, version string) {
|
|
testArgs := os.Getenv("TEST_ARGUMENTS")
|
|
if !strings.Contains(testArgs, "min-test-matrix") {
|
|
logger.Infof("running all tests")
|
|
return
|
|
}
|
|
if !k8sh.VersionMinorMatches(version) {
|
|
logger.Infof("Skipping test suite since kube version is not minor version %s", version)
|
|
t().Skip()
|
|
}
|
|
logger.Infof("Running test suite since kube version is minor version %s", version)
|
|
}
|
|
|
|
// StartTestCluster creates new instance of TestCluster struct
|
|
func StartTestCluster(t func() *testing.T, minimalMatrixK8sVersion, namespace, storeType string, useHelm, useDevices bool, mons,
|
|
rbdMirrorWorkers int, rookVersion string, cephVersion cephv1.CephVersionSpec) (*TestCluster, *utils.K8sHelper) {
|
|
|
|
kh, err := utils.CreateK8sHelper(t)
|
|
require.NoError(t(), err)
|
|
checkIfShouldRunForMinimalTestMatrix(t, kh, minimalMatrixK8sVersion)
|
|
|
|
i := installer.NewCephInstaller(t, kh.Clientset, useHelm, rookVersion, cephVersion)
|
|
|
|
op := &TestCluster{i, kh, nil, t, namespace, storeType, useDevices, mons, rbdMirrorWorkers}
|
|
|
|
if rookVersion != installer.VersionMaster {
|
|
// make sure we have the images from a previous release locally so the test doesn't hit a timeout
|
|
assert.NoError(t(), kh.GetDockerImage("rook/ceph:"+rookVersion))
|
|
}
|
|
|
|
assert.NoError(t(), kh.GetDockerImage(cephVersion.Image))
|
|
|
|
op.Setup()
|
|
return op, kh
|
|
}
|
|
|
|
// SetUpRook is a wrapper for setting up rook
|
|
func (op *TestCluster) Setup() {
|
|
isRookInstalled, err := op.installer.InstallRookOnK8sWithHostPathAndDevices(op.namespace, op.storeType,
|
|
op.useDevices, cephv1.MonSpec{Count: op.mons, AllowMultiplePerNode: true}, false /* startWithAllNodes */, op.rbdMirrorWorkers)
|
|
|
|
if !isRookInstalled || err != nil {
|
|
logger.Errorf("Rook was not installed successfully: %v", err)
|
|
if !op.installer.T().Failed() {
|
|
op.installer.GatherAllRookLogs(op.installer.T().Name(), op.namespace, installer.SystemNamespace(op.namespace))
|
|
}
|
|
op.T().Fail()
|
|
op.Teardown()
|
|
op.T().FailNow()
|
|
}
|
|
}
|
|
|
|
// SetInstallData updates the installer helper based on the version of Rook desired
|
|
func (op *TestCluster) SetInstallData(version string) {}
|
|
|
|
// TearDownRook is a wrapper for tearDown after Suite
|
|
func (op *TestCluster) Teardown() {
|
|
op.installer.UninstallRook(op.namespace, true)
|
|
}
|