forked from rook/rook
ceph: handle golangci-lint linter gosimple
this commit handles all the errors check for golangci-lint linter gosimple. Signed-off-by: subhamkrai <subhamkumarrai03@gmail.com>
This commit is contained in:
@@ -29,7 +29,6 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/server"
|
||||
kubeinformers "k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/informers/internalinterfaces"
|
||||
)
|
||||
|
||||
const resyncPeriod = time.Second * 30
|
||||
@@ -58,8 +57,7 @@ func startOperator(cmd *cobra.Command, args []string) error {
|
||||
rookImage := rook.GetOperatorImage(kubeClient, "")
|
||||
|
||||
// Only watch kubernetes resources relevant to our app
|
||||
var tweakListOptionsFunc internalinterfaces.TweakListOptionsFunc
|
||||
tweakListOptionsFunc = func(options *metav1.ListOptions) {
|
||||
tweakListOptionsFunc := func(options *metav1.ListOptions) {
|
||||
|
||||
options.LabelSelector = fmt.Sprintf("%s=%s", "app", constants.AppName)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func GetModifiedRookImagePath(originRookImage, addon string) string {
|
||||
if len(addon) > 0 {
|
||||
modifiedImageName = fmt.Sprintf("%s-%s", imageVersionParts[0], addon)
|
||||
} else {
|
||||
modifiedImageName = fmt.Sprintf("%s", imageVersionParts[0])
|
||||
modifiedImageName = imageVersionParts[0]
|
||||
}
|
||||
|
||||
imageParts[latestImagePartIndex] = fmt.Sprintf("%s:%s", modifiedImageName, modifiedImageTag)
|
||||
|
||||
@@ -118,15 +118,12 @@ func (a *Agent) Run() error {
|
||||
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, syscall.SIGTERM)
|
||||
for {
|
||||
select {
|
||||
case <-sigc:
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
flexvolumeServer.StopAll()
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
<-sigc
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
flexvolumeServer.StopAll()
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
|
||||
// In 1.11 and newer there is a timing issue loading flex drivers.
|
||||
|
||||
@@ -74,7 +74,7 @@ func (vm *VolumeManager) Init() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if in == true {
|
||||
if in {
|
||||
logger.Noticef("volume manager is a builtin kernel module, don't load it manually")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ func cleanMonDirs(dataDirHostPath, monSecret string) {
|
||||
logger.Infof("skipped clean up of the mon directory %q as the secret key did not match", monDir)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func secretKeyMatch(monDir, monSecret string) (bool, error) {
|
||||
|
||||
@@ -164,7 +164,7 @@ func mergeDefaultConfigWithRookConfigOverride(context *clusterd.Context, cluster
|
||||
|
||||
// prepends "client." if a user namespace is not already specified
|
||||
func getQualifiedUser(user string) string {
|
||||
if strings.Index(user, ".") == -1 {
|
||||
if !strings.Contains(user, ".") {
|
||||
return fmt.Sprintf("client.%s", user)
|
||||
}
|
||||
|
||||
|
||||
@@ -170,10 +170,7 @@ func CreateFilesystem(context *clusterd.Context, clusterInfo *ClusterInfo, name,
|
||||
// Rook to create multiple Ceph filesystems. False if Rook is not allowed to do so.
|
||||
func IsMultiFSEnabled() bool {
|
||||
t := os.Getenv(MultiFsEnv)
|
||||
if t == "true" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return t == "true"
|
||||
}
|
||||
|
||||
// SetNumMDSRanks sets the number of mds ranks (max_mds) for a Ceph filesystem.
|
||||
|
||||
@@ -107,17 +107,14 @@ func StartOSD(context *clusterd.Context, osdType, osdID, osdUUID, lvPath string,
|
||||
func handleTerminate(context *clusterd.Context, lvPath, volumeGroupName string) error {
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, syscall.SIGTERM)
|
||||
for {
|
||||
select {
|
||||
case <-sigc:
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
err := killCephOSDProcess(context, lvPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to kill ceph-osd process")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
<-sigc
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
err := killCephOSDProcess(context, lvPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to kill ceph-osd process")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func killCephOSDProcess(context *clusterd.Context, lvPath string) error {
|
||||
|
||||
@@ -179,53 +179,53 @@ func TestAvailableDevices(t *testing.T) {
|
||||
logger.Infof("OUTPUT for %s %v", command, args)
|
||||
|
||||
if command == "lsblk" {
|
||||
if strings.Index(args[3], "sdb") != -1 {
|
||||
if strings.Contains(args[3], "sdb") {
|
||||
// /dev/sdb has a partition
|
||||
return `NAME="sdb" SIZE="65" TYPE="disk" PKNAME=""
|
||||
NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
} else if strings.Index(args[0], "vg1-lv") != -1 {
|
||||
} else if strings.Contains(args[0], "vg1-lv") {
|
||||
// /dev/mapper/vg1-lv* are LVs
|
||||
return `TYPE="lvm"`, nil
|
||||
} else if strings.Index(args[0], "sdt1") != -1 {
|
||||
} else if strings.Contains(args[0], "sdt1") {
|
||||
return `TYPE="part"`, nil
|
||||
} else if strings.HasPrefix(args[0], "/dev") {
|
||||
return `TYPE="disk"`, nil
|
||||
}
|
||||
return "", nil
|
||||
} else if command == "blkid" {
|
||||
if strings.Index(args[3], "sdb1") != -1 {
|
||||
if strings.Contains(args[3], "sdb1") {
|
||||
// partition sdb1 has a label MY-PART
|
||||
return "MY-PART", nil
|
||||
}
|
||||
} else if command == "udevadm" {
|
||||
if strings.Index(args[2], "sdc") != -1 {
|
||||
if strings.Contains(args[2], "sdc") {
|
||||
// /dev/sdc has a file system
|
||||
return udevFSOutput, nil
|
||||
} else if strings.Index(args[2], "sdt1") != -1 {
|
||||
} else if strings.Contains(args[2], "sdt1") {
|
||||
return udevPartOutput, nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
} else if command == "dmsetup" && args[0] == "info" {
|
||||
if strings.Index(args[5], "vg1-lv1") != -1 {
|
||||
if strings.Contains(args[5], "vg1-lv1") {
|
||||
return "vg1-lv1", nil
|
||||
} else if strings.Index(args[5], "vg1-lv2") != -1 {
|
||||
} else if strings.Contains(args[5], "vg1-lv2") {
|
||||
return "vg1-lv2", nil
|
||||
}
|
||||
} else if command == "dmsetup" && args[0] == "splitname" {
|
||||
if strings.Index(args[2], "vg1-lv1") != -1 {
|
||||
if strings.Contains(args[2], "vg1-lv1") {
|
||||
return "vg1:lv1:", nil
|
||||
} else if strings.Index(args[2], "vg1-lv2") != -1 {
|
||||
} else if strings.Contains(args[2], "vg1-lv2") {
|
||||
return "vg1:lv2:", nil
|
||||
}
|
||||
} else if command == "ceph-volume" {
|
||||
if args[0] == "inventory" {
|
||||
if strings.Index(args[3], "/mnt/set1-0-data-qfhfk") != -1 {
|
||||
if strings.Contains(args[3], "/mnt/set1-0-data-qfhfk") {
|
||||
return cvInventoryOutputNotAvailableBluestoreLabel, nil
|
||||
} else if strings.Index(args[3], "sdb") != -1 {
|
||||
} else if strings.Contains(args[3], "sdb") {
|
||||
// sdb is locked
|
||||
return cvInventoryOutputNotAvailableLocked, nil
|
||||
} else if strings.Index(args[3], "sdc") != -1 {
|
||||
} else if strings.Contains(args[3], "sdc") {
|
||||
// sdc is too small
|
||||
return cvInventoryOutputNotAvailableSmall, nil
|
||||
}
|
||||
|
||||
@@ -57,8 +57,5 @@ func (a *OsdAgent) driveGroupsAreSupported(context *clusterd.Context) bool {
|
||||
// Call `ceph-volume drive-group` command with no args:
|
||||
// if supported, will return 0 (and help message which we ingore), else returns nonzero (error)
|
||||
_, err := callCephVolume(context, true, cvDriveGroupsCommand)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ func (r *CmdReporter) runCommand() (stdout, stderr string, retcode int, err erro
|
||||
retcode = 0
|
||||
}
|
||||
|
||||
return string(capturedStdout.Bytes()), string(capturedStderr.Bytes()), retcode, nil
|
||||
return capturedStdout.String(), capturedStderr.String(), retcode, nil
|
||||
}
|
||||
|
||||
func (r *CmdReporter) saveToConfigMap(stdout, stderr string, retcode int) error {
|
||||
|
||||
@@ -96,7 +96,7 @@ func (c *cluster) createInstance(rookImage string, cephVersion cephver.CephVersi
|
||||
// execute an orchestration until
|
||||
// there are no more unapplied changes to the cluster definition and
|
||||
// while no other goroutine is already running a cluster update
|
||||
for c.checkSetOrchestrationStatus() == true {
|
||||
for c.checkSetOrchestrationStatus() {
|
||||
if err != nil {
|
||||
logger.Errorf("there was an orchestration error, but there is another orchestration pending; proceeding with next orchestration run (which may succeed). %v", err)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (c *Cluster) genMonSharedKeyring() string {
|
||||
// return mon data dir path relative to the dataDirHostPath given a mon's name
|
||||
func dataDirRelativeHostPath(monName string) string {
|
||||
monHostDir := monName // support legacy case where the mon name is "mon#" and not a lettered ID
|
||||
if strings.Index(monName, "mon") == -1 {
|
||||
if !strings.Contains(monName, "mon") {
|
||||
// if the mon name doesn't have "mon" in it, mon dir is "mon-<ID>"
|
||||
monHostDir = "mon-" + monName
|
||||
}
|
||||
|
||||
@@ -398,10 +398,8 @@ func (c *Cluster) removeMon(daemonName string) error {
|
||||
logger.Errorf("failed to remove mon %q from quorum. %v", daemonName, err)
|
||||
}
|
||||
delete(c.ClusterInfo.Monitors, daemonName)
|
||||
// check if a mapping exists for the mon
|
||||
if _, ok := c.mapping.Node[daemonName]; ok {
|
||||
delete(c.mapping.Node, daemonName)
|
||||
}
|
||||
|
||||
delete(c.mapping.Node, daemonName)
|
||||
|
||||
// Remove the service endpoint
|
||||
if err := c.context.Clientset.CoreV1().Services(c.Namespace).Delete(resourceName, options); err != nil {
|
||||
|
||||
@@ -674,7 +674,7 @@ func (c *Cluster) startDeployments(mons []*monConfig, requireAllInQuorum bool) e
|
||||
|
||||
// Ensure each of the mons have been created. If already created, it will be a no-op.
|
||||
for i := 0; i < len(mons); i++ {
|
||||
node, _ := c.mapping.Node[mons[i].DaemonName]
|
||||
node := c.mapping.Node[mons[i].DaemonName]
|
||||
err := c.startMon(mons[i], node)
|
||||
if err != nil {
|
||||
if c.isUpgrade {
|
||||
|
||||
@@ -41,14 +41,9 @@ func monInQuorum(monitor client.MonMapEntry, quorum []int) bool {
|
||||
// convert the mon name to the numeric mon ID
|
||||
func fullNameToIndex(name string) (int, error) {
|
||||
// remove the "rook-ceph-mon" prefix
|
||||
if strings.HasPrefix(name, AppName) {
|
||||
name = name[len(AppName):]
|
||||
}
|
||||
name = strings.TrimPrefix(name, AppName)
|
||||
// remove the "-" prefix
|
||||
if strings.HasPrefix(name, "-") {
|
||||
name = name[1:]
|
||||
}
|
||||
|
||||
name = strings.TrimPrefix(name, "-")
|
||||
return k8sutil.NameToIndex(name)
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func (c *ClusterController) configureCephMonitoring(cluster *cluster, clusterInf
|
||||
}
|
||||
|
||||
// Start watchers
|
||||
if cluster.watchersActivated == true {
|
||||
if cluster.watchersActivated {
|
||||
logger.Debugf("cluster is already being watched by bucket and client provisioner for cluster %q", cluster.Namespace)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ func (c *ClusterController) StartOperatorSettingsWatch(namespace string, stopCh
|
||||
return
|
||||
}
|
||||
c.operatorConfigChange(newObj)
|
||||
return
|
||||
}, nil, stopCh)
|
||||
}
|
||||
|
||||
@@ -66,5 +65,4 @@ func (c *ClusterController) operatorConfigChange(obj interface{}) {
|
||||
logger.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -977,6 +977,4 @@ func (c *Cluster) applyUpgradeOSDFunctionality() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (c *cluster) checkSetOrchestrationStatus() bool {
|
||||
defer c.orchMux.Unlock()
|
||||
|
||||
// check if there is an orchestration needed currently
|
||||
if c.orchestrationNeeded == true && c.orchestrationRunning == false {
|
||||
if c.orchestrationNeeded && !c.orchestrationRunning {
|
||||
// there is an orchestration needed
|
||||
// allow to enter the orchestration-loop
|
||||
c.orchestrationNeeded = false
|
||||
|
||||
@@ -57,17 +57,17 @@ func (c *clientCluster) onK8sNode(object runtime.Object) bool {
|
||||
// Get CephCluster
|
||||
cluster := c.getCephCluster()
|
||||
|
||||
if k8sutil.GetNodeSchedulable(*node) == false {
|
||||
if !k8sutil.GetNodeSchedulable(*node) {
|
||||
logger.Debugf("node watcher: skipping cluster update. added node %q is unschedulable", node.Labels[v1.LabelHostname])
|
||||
return false
|
||||
}
|
||||
|
||||
if k8sutil.NodeIsTolerable(*node, cephv1.GetOSDPlacement(cluster.Spec.Placement).Tolerations, false) == false {
|
||||
if !k8sutil.NodeIsTolerable(*node, cephv1.GetOSDPlacement(cluster.Spec.Placement).Tolerations, false) {
|
||||
logger.Debugf("node watcher: node since it is not tolerable for cluster %q, skipping", cluster.Namespace)
|
||||
return false
|
||||
}
|
||||
|
||||
if cluster.Spec.Storage.UseAllNodes == false {
|
||||
if !cluster.Spec.Storage.UseAllNodes {
|
||||
logger.Debugf("node watcher: do not use all Nodes in cluster %q, skipping", cluster.Namespace)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -521,11 +521,7 @@ func isCMTConfigOverride(obj runtime.Object) bool {
|
||||
}
|
||||
|
||||
objectName := cm.GetName()
|
||||
if objectName == k8sutil.ConfigOverrideName {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return objectName == k8sutil.ConfigOverrideName
|
||||
}
|
||||
|
||||
func isCMToIgnoreOnDelete(obj runtime.Object) bool {
|
||||
|
||||
@@ -51,7 +51,7 @@ func (v *CephCSIVersion) String() string {
|
||||
|
||||
// Supported checks if the detected version is part of the known supported CSI versions
|
||||
func (v *CephCSIVersion) Supported() bool {
|
||||
if v.isAtLeast(&minimum) == false {
|
||||
if !v.isAtLeast(&minimum) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ func getOSDsForNodes(osdDataList []OsdData, nodeList []*corev1.Node, failureDoma
|
||||
}
|
||||
|
||||
func getFailureDomainMapForOsds(osdDataList []OsdData, failureDomainType string) (map[string][]OsdData, error) {
|
||||
failureDomainMap := make(map[string][]OsdData, 0)
|
||||
failureDomainMap := make(map[string][]OsdData)
|
||||
unfoundOSDs := make([]string, 0)
|
||||
var err error
|
||||
for _, osdData := range osdDataList {
|
||||
|
||||
@@ -184,7 +184,7 @@ func isCephCommand(command []string) bool {
|
||||
func argEnvReferences(c *v1.Container) []string {
|
||||
argRefSet := map[string]bool{}
|
||||
for _, a := range c.Args {
|
||||
argRefRegex, e := regexp.Compile("\\$\\(([a-zA-Z][a-zA-Z0-9_]*)\\)")
|
||||
argRefRegex, e := regexp.Compile(`\$\(([a-zA-Z][a-zA-Z0-9_]*)\)`)
|
||||
if e != nil {
|
||||
panic("could not compile argument reference regexp")
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@ import (
|
||||
)
|
||||
|
||||
func TestToString(t *testing.T) {
|
||||
assert.Equal(t, "14.0.0-0 nautilus", fmt.Sprintf("%s", &Nautilus))
|
||||
assert.Equal(t, "15.0.0-0 octopus", fmt.Sprintf("%s", &Octopus))
|
||||
assert.Equal(t, "14.0.0-0 nautilus", Nautilus.String())
|
||||
assert.Equal(t, "15.0.0-0 octopus", Octopus.String())
|
||||
receieved := CephVersion{-1, 0, 0, 0}
|
||||
|
||||
expected := fmt.Sprintf("-1.0.0-0 %s", unknownVersionString)
|
||||
assert.Equal(t, expected, fmt.Sprintf("%s", &CephVersion{-1, 0, 0, 0}))
|
||||
assert.Equal(t, expected, receieved.String())
|
||||
}
|
||||
|
||||
func TestCephVersionFormatted(t *testing.T) {
|
||||
|
||||
@@ -60,12 +60,8 @@ func (o *Operator) Run() error {
|
||||
// watch for changes to the cockroachdb clusters
|
||||
o.clusterController.StartWatch(v1.NamespaceAll, stopChan)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-signalChan:
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
<-signalChan
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/edgefs/cluster/prepare"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/cluster/target"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -181,7 +181,7 @@ func (c *cluster) createInstance(rookImage string, isClusterUpdate bool) (bool,
|
||||
// Skip preparation job in case of resurrect option is on
|
||||
//
|
||||
|
||||
if c.Spec.SkipHostPrepare == false && dro.NeedToResurrect == false {
|
||||
if !c.Spec.SkipHostPrepare && !dro.NeedToResurrect {
|
||||
err = c.prepareHostNodes(rookImage, clusterReconfiguration.DeploymentConfig)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to create [%s] cluster preparation jobs. %+v", c.Namespace, err)
|
||||
|
||||
@@ -49,7 +49,7 @@ func (c *cluster) createClusterReconfigurationSpec(existingConfig edgefsv1.Clust
|
||||
DeploymentConfig: edgefsv1.ClusterDeploymentConfig{
|
||||
DeploymentType: deploymentType,
|
||||
TransportKey: transportKey,
|
||||
DevConfig: make(map[string]edgefsv1.DevicesConfig, 0),
|
||||
DevConfig: make(map[string]edgefsv1.DevicesConfig),
|
||||
NeedPrivileges: c.needPrivelege(deploymentType),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ func (c *ClusterController) removeFinalizer(obj interface{}) {
|
||||
okCheck = true
|
||||
}
|
||||
|
||||
if okCheck != true || err != nil {
|
||||
if !okCheck || err != nil {
|
||||
logger.Errorf("failed to remove finalizer %s from cluster %s. %+v", fname, objectMeta.Name, err)
|
||||
time.Sleep(retrySeconds)
|
||||
continue
|
||||
|
||||
@@ -173,33 +173,31 @@ func (c *Cluster) waitJob(job *batch.Job) error {
|
||||
|
||||
events := watch.ResultChan()
|
||||
for {
|
||||
select {
|
||||
case event := <-events:
|
||||
if event.Object == nil {
|
||||
return fmt.Errorf("Result channel closed for Job %s", job.ObjectMeta.Name)
|
||||
}
|
||||
k8sJob, ok := event.Object.(*batch.Job)
|
||||
if !ok {
|
||||
return fmt.Errorf("Invalid Job event object: %T", event.Object)
|
||||
}
|
||||
conditions := k8sJob.Status.Conditions
|
||||
for _, condition := range conditions {
|
||||
if condition.Type == batch.JobComplete {
|
||||
logger.Infof("Job %s reported complete", job.ObjectMeta.Name)
|
||||
return nil
|
||||
} else if condition.Type == batch.JobFailed {
|
||||
return fmt.Errorf("Job %s failed", job.ObjectMeta.Name)
|
||||
}
|
||||
event := <-events
|
||||
if event.Object == nil {
|
||||
return fmt.Errorf("Result channel closed for Job %s", job.ObjectMeta.Name)
|
||||
}
|
||||
k8sJob, ok := event.Object.(*batch.Job)
|
||||
if !ok {
|
||||
return fmt.Errorf("Invalid Job event object: %T", event.Object)
|
||||
}
|
||||
conditions := k8sJob.Status.Conditions
|
||||
for _, condition := range conditions {
|
||||
if condition.Type == batch.JobComplete {
|
||||
logger.Infof("Job %s reported complete", job.ObjectMeta.Name)
|
||||
return nil
|
||||
} else if condition.Type == batch.JobFailed {
|
||||
return fmt.Errorf("Job %s failed", job.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) deleteJob(job *batch.Job) error {
|
||||
batchClient := c.context.Clientset.BatchV1()
|
||||
jobsClient := batchClient.Jobs(job.ObjectMeta.Namespace)
|
||||
var deletePropagation metav1.DeletionPropagation
|
||||
deletePropagation = metav1.DeletePropagationForeground
|
||||
deletePropagation := metav1.DeletePropagationForeground
|
||||
err := jobsClient.Delete(job.ObjectMeta.Name, &metav1.DeleteOptions{PropagationPolicy: &deletePropagation})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to delete job %s", job.ObjectMeta.Name)
|
||||
|
||||
@@ -59,16 +59,13 @@ func ParseDevicesResurrectMode(resurrectMode string) edgefsv1.DevicesResurrectOp
|
||||
switch resurrectModeToLower {
|
||||
case "restore":
|
||||
drm.NeedToResurrect = true
|
||||
break
|
||||
case "restorezap":
|
||||
drm.NeedToResurrect = true
|
||||
drm.NeedToZap = true
|
||||
break
|
||||
case "restorezapwait":
|
||||
drm.NeedToResurrect = true
|
||||
drm.NeedToZap = true
|
||||
drm.NeedToWait = true
|
||||
break
|
||||
}
|
||||
|
||||
return drm
|
||||
@@ -111,7 +108,7 @@ func (c *cluster) getClusterNodes() ([]rookv1.Node, error) {
|
||||
func (c *cluster) retrieveDeploymentConfig() (edgefsv1.ClusterDeploymentConfig, error) {
|
||||
|
||||
deploymentConfig := edgefsv1.ClusterDeploymentConfig{
|
||||
DevConfig: make(map[string]edgefsv1.DevicesConfig, 0),
|
||||
DevConfig: make(map[string]edgefsv1.DevicesConfig),
|
||||
}
|
||||
|
||||
cm, err := c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(configName, metav1.GetOptions{})
|
||||
|
||||
@@ -75,12 +75,8 @@ func (o *Operator) Run() error {
|
||||
// watch for changes to the edgefs clusters
|
||||
o.clusterController.StartWatch(v1.NamespaceAll, stopChan)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-signalChan:
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
<-signalChan
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -146,10 +146,7 @@ func GetNodeHostNames(clientset kubernetes.Interface) (map[string]string, error)
|
||||
func GetNodeSchedulable(node v1.Node) bool {
|
||||
// some unit tests set this to quickly emulate an unschedulable node; if this is set to true,
|
||||
// we can shortcut deeper inspection for schedulability.
|
||||
if node.Spec.Unschedulable {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return !node.Spec.Unschedulable
|
||||
}
|
||||
|
||||
// NodeMeetsPlacementTerms returns true if the Rook placement allows the node to have resources scheduled
|
||||
|
||||
@@ -75,9 +75,7 @@ func TestValidNode(t *testing.T) {
|
||||
|
||||
func testNode(taints []v1.Taint) v1.Node {
|
||||
n := v1.Node{}
|
||||
for _, t := range taints {
|
||||
n.Spec.Taints = append(n.Spec.Taints, t)
|
||||
}
|
||||
n.Spec.Taints = append(n.Spec.Taints, taints...)
|
||||
return n
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ func (ct *ContainersTester) RunFullSuite(resourceExpectations ResourceLimitExpec
|
||||
func argEnvReferences(c *v1.Container) []string {
|
||||
argRefSet := map[string]bool{}
|
||||
for _, a := range c.Args {
|
||||
argRefRegex, e := regexp.Compile("\\$\\(([a-zA-Z][a-zA-Z0-9_]*)\\)")
|
||||
argRefRegex, e := regexp.Compile(`\$\(([a-zA-Z][a-zA-Z0-9_]*)\)`)
|
||||
if e != nil {
|
||||
panic("could not compile argument reference regexp")
|
||||
}
|
||||
|
||||
@@ -60,12 +60,8 @@ func (o *Operator) Run() error {
|
||||
// watch for changes to the yugabytedb clusters
|
||||
o.clusterController.StartWatch(v1.NamespaceAll, stopChan)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-signalChan:
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
<-signalChan
|
||||
logger.Infof("shutdown signal received, exiting...")
|
||||
close(stopChan)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func SetFlagsFromEnv(flags *pflag.FlagSet, prefix string) {
|
||||
}
|
||||
}
|
||||
})
|
||||
if errorFlag != false {
|
||||
if errorFlag {
|
||||
logger.Error("failed to set flag ", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func (h *EdgefsInstaller) UninstallEdgefs(systemNamespace, namespace string) {
|
||||
h.k8shelper.Clientset.RbacV1().ClusterRoleBindings().Delete("rook-edgefs-system-psp", nil)
|
||||
|
||||
err = h.k8shelper.DeleteResourceAndWait(false, "podsecuritypolicy", "privileged")
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot delete podsecuritypolicy `privileged`"))
|
||||
checkError(h.T(), err, "cannot delete podsecuritypolicy `privileged`")
|
||||
|
||||
err = h.k8shelper.DeleteResourceAndWait(false, "namespace", namespace)
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot delete namespace %s", namespace))
|
||||
|
||||
@@ -147,16 +147,16 @@ func (h *NFSInstaller) UninstallNFSServer(systemNamespace, namespace string) {
|
||||
logger.Infof("uninstalling nfsserver from namespace %s", namespace)
|
||||
|
||||
err := h.k8shelper.DeleteResource("pvc", "nfs-pv-claim")
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot remove nfs pvc : nfs-pv-claim"))
|
||||
checkError(h.T(), err, "cannot remove nfs pvc : nfs-pv-claim")
|
||||
|
||||
err = h.k8shelper.DeleteResource("pvc", "nfs-pv-claim-bigger")
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot remove nfs pvc : nfs-pv-claim-bigger"))
|
||||
checkError(h.T(), err, "cannot remove nfs pvc : nfs-pv-claim-bigger")
|
||||
|
||||
err = h.k8shelper.DeleteResource("pv", "nfs-pv")
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot remove nfs pv : nfs-pv"))
|
||||
checkError(h.T(), err, "cannot remove nfs pv : nfs-pv")
|
||||
|
||||
err = h.k8shelper.DeleteResource("pv", "nfs-pv1")
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot remove nfs pv : nfs-pv1"))
|
||||
checkError(h.T(), err, "cannot remove nfs pv : nfs-pv1")
|
||||
|
||||
err = h.k8shelper.DeleteResource("-n", namespace, "nfsservers.nfs.rook.io", namespace)
|
||||
checkError(h.T(), err, fmt.Sprintf("cannot remove nfsserver %s", namespace))
|
||||
|
||||
@@ -81,7 +81,7 @@ func CreateK8sHelper(t func() *testing.T) (*K8sHelper, error) {
|
||||
}
|
||||
|
||||
h := &K8sHelper{executor: executor, Clientset: clientset, RookClientset: rookClientset, T: t}
|
||||
if strings.Index(config.Host, "//10.") != -1 {
|
||||
if strings.Contains(config.Host, "//10.") {
|
||||
h.RunningInCluster = true
|
||||
}
|
||||
return h, err
|
||||
@@ -148,7 +148,7 @@ func (k8sh *K8sHelper) KubectlWithStdin(stdin string, args ...string) (string, e
|
||||
|
||||
if cmdOut.ExitCode != 0 {
|
||||
k8slogger.Errorf("Failed to execute stdin: kubectl %v : %v", args, cmdOut.Err.Error())
|
||||
if strings.Index(cmdOut.Err.Error(), "(NotFound)") != -1 || strings.Index(cmdOut.StdErr, "(NotFound)") != -1 {
|
||||
if strings.Contains(cmdOut.Err.Error(), "(NotFound)") || strings.Contains(cmdOut.StdErr, "(NotFound)") {
|
||||
return cmdOut.StdErr, errors.NewNotFound(schema.GroupResource{}, "")
|
||||
}
|
||||
return cmdOut.StdErr, fmt.Errorf("Failed to run stdin: kubectl %v : %v", args, cmdOut.StdErr)
|
||||
@@ -556,7 +556,6 @@ func (k8sh *K8sHelper) GetEventsFromNamespace(namespace, testName, platformName
|
||||
return
|
||||
}
|
||||
file.WriteString(events)
|
||||
return
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) appendPodDescribe(file *os.File, namespace, name string) {
|
||||
@@ -1464,10 +1463,7 @@ func (k8sh *K8sHelper) RestoreHostnames() ([]string, error) {
|
||||
func (k8sh *K8sHelper) IsRookInstalled(namespace string) bool {
|
||||
opts := metav1.GetOptions{}
|
||||
_, err := k8sh.Clientset.CoreV1().Services(namespace).Get("rook-ceph-mgr", opts)
|
||||
if err == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// CollectPodLogsFromLabel collects logs for pods with the given label
|
||||
|
||||
@@ -120,10 +120,7 @@ func (h *MySQLHelper) TableRowCount() (count int) {
|
||||
// TableExists checks if a table exists
|
||||
func (h *MySQLHelper) TableExists() bool {
|
||||
_, err := h.DB.Query("SELECT 1 FROM LONGHAUL LIMIT 1 ")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// DeleteRandomRow deletes a random row
|
||||
|
||||
Reference in New Issue
Block a user