Files
my-rook-config/tests/framework/installer/ceph_helm_installer.go
T
Joshua Hoblitt cff8b7f311 ci: reduce CephUpgradeSuite flakes
The CephUpgradeSuite workflow failed ~31% of PR runs vs the ~19%
broken-PR baseline of the other integration suites. Classifying the
failing step of every failed run from the last ~400 PR runs and the
logs of every failure on non-dependabot branches shows the excess
comes from a handful of too-tight waits, unretried network fetches,
and environment races rather than from the upgrade logic itself:

- The biggest class (21 of 44 genuine test-phase failure runs):
  "giving up waiting for deployment(s) with label
  app=rook-ceph-{rgw,osd},ceph-version!=..." during the
  Squid->Tentacle upgrade. The operator updates daemons sequentially
  (mons, mgr, osds with PG health gates between them, mds, rgw), so
  each later daemon's fixed 275s wait also absorbs the time spent on
  every daemon before it; rgw, last in the sequence, failed most
  often. The mon wait was already extended for slow image pulls in
  98bd03a42; extend the same retry count to all the daemon waits.

- ~7 runs: "snapshot controller is not ready" in the Helm upgrade
  path. WaitForSnapshotController(30) allows only 150s, and the logs
  show the deployment still converging (readyreplicas 1 < replicas 2)
  on the final poll. Raise to 90 retries.

- InstallOrUpgradeHelmRepoChart ran helm with no retry; an observed
  failure fetched the ceph-csi-drivers chart tarball from GitHub
  release assets and got a 504. Retry up to 5 times, as
  InstallLocalHelmChart already does.

- Raise the go test timeouts (2400s->3600s rook, 1800s->2700s helm).
  Failed runs ended in "panic: test timed out" during teardown, which
  aborts cleanup and log collection; the longer daemon waits above
  also need the headroom.

- The "setup cluster resources" composite action (shared by all
  suites) accounted for half of all failed jobs. The one steady class
  there (8 distinct runs across 7 different days): minikube exits with
  K8S_FAIL_CONNECT (code 40) when the requested kubernetes version is
  missing from its bundled version list, because it then validates the
  version with an anonymous GitHub API request (GITHUB_TOKEN is not
  honored on that code path), and anonymous requests from shared
  runner IPs are regularly rate-limited. minikube 1.38.x predates
  v1.35.5, so only the v1.35.5 jobs hit this class. Pass --force to
  minikube start to skip that check: the kubernetes versions used in
  CI are pinned constants already validated by the PRs that bump
  them, and an invalid version would still fail fast at the kubeadm
  download. Also seen twice: dpkg failing on a corrupt cri-dockerd .deb
  because curl ran without --fail and saved an HTTP error page as the
  package; add --fail and retries.

- On runners without the /mnt resource disk, the fallback OSD disk is
  an iSCSI (LIO) device and use_local_disk_for_integration_test
  returned early on those runners, skipping the udev nowatch
  workaround for the device re-probe storms of rook issue 8975. A burn-in
  failure on this PR captured the consequence with full kernel
  forensics: ~100 udev change events on the OSD disk, and ceph-volume
  activate wedged in uninterruptible sleep on the block device lock
  (blkdev_llseek -> rwsem_down_write_slowpath) for 18+ minutes during
  the ceph version upgrade while the cluster's only OSD stayed down.
  Install the nowatch rule before the early return so it applies to
  every runner type, and before the disk is first written rather than
  after.

- One burn-in round failed before the upgrade even began: the
  pre-upgrade PVC create on the Helm path expired WaitUntilPVCIsBound
  (RetryLoop, 275s) while the CSI provisioner pods were still
  starting. Set RETRY_MAX=110 for this workflow to double the
  framework's base wait budget, instead of extending individual waits
  one flake at a time.

- minikube also exits with GUEST_START (code 80) when its internal 6
  minute node-ready wait expires on slow runners (5 runs in the
  dataset, two more observed while burning in this PR, one of them on
  another suite). Pass --wait-timeout=15m to minikube start.

Not addressed (small or episodic classes): OSDs never coming up on
initial deploy (3 runs, possibly the same udev/iSCSI wedge), the
filesystem not becoming active (2 runs), and several day-clustered
minikube incidents (exit codes 65/67/90).

Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
2026-06-11 15:27:02 -07:00

412 lines
14 KiB
Go

/*
Copyright 2021 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 installer
import (
"context"
"fmt"
"time"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
kerrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
OperatorChartName = "rook-ceph"
CephClusterChartName = "rook-ceph-cluster"
cephCsiOperatorHelmRepoURL = "https://ceph.github.io/ceph-csi-operator"
cephCsiOperatorHelmRepoName = "ceph-csi-operator"
cephCsiDriversChartName = "ceph-csi-drivers"
cephCsiDriversChartVersion = "1.0.1"
cephCsiDriversReleaseName = "ceph-csi-drivers"
)
// The Ceph Storage CustomResource and StorageClass names used in testing
const (
BlockPoolName = "ceph-block-test"
BlockPoolSCName = "ceph-block-test-sc"
FilesystemName = "ceph-filesystem-test"
FilesystemSCName = "ceph-filesystem-test-sc"
ObjectStoreName = "ceph-objectstore-test"
ObjectStoreSCName = "ceph-bucket-test-sc"
)
// CreateRookOperatorViaHelm creates rook operator via Helm chart named local/rook present in local repo
func (h *CephInstaller) CreateRookOperatorViaHelm() error {
return h.configureRookOperatorViaHelm(false)
}
func (h *CephInstaller) UpgradeRookOperatorViaHelm() error {
return h.configureRookOperatorViaHelm(true)
}
func (h *CephInstaller) configureRookOperatorViaHelm(upgrade bool) error {
values := map[string]interface{}{
"enableDiscoveryDaemon": h.settings.EnableDiscovery,
"image": map[string]interface{}{"tag": h.settings.RookVersion},
"monitoring": map[string]interface{}{"enabled": true},
"revisionHistoryLimit": "3",
"enforceHostNetwork": "false",
}
// create the operator namespace
if err := h.k8shelper.CreateNamespace(h.settings.OperatorNamespace); err != nil {
return errors.Errorf("failed to create namespace %s. %v", h.settings.Namespace, err)
}
if h.settings.RookVersion == LocalBuildTag {
if err := h.helmHelper.InstallLocalHelmChart(upgrade, h.settings.OperatorNamespace, OperatorChartName, values); err != nil {
return errors.Errorf("failed to install rook operator via helm, err : %v", err)
}
} else {
// Install a specific version of the chart, from which the test will upgrade later
if err := h.helmHelper.InstallVersionedChart(h.settings.OperatorNamespace, OperatorChartName, h.settings.RookVersion, values); err != nil {
return errors.Errorf("failed to install rook operator via helm, err : %v", err)
}
}
return nil
}
// CreateRookCephClusterViaHelm creates rook cluster via Helm
func (h *CephInstaller) CreateRookCephClusterViaHelm() error {
return h.configureRookCephClusterViaHelm(false)
}
func (h *CephInstaller) UpgradeRookCephClusterViaHelm() error {
return h.configureRookCephClusterViaHelm(true)
}
func (h *CephInstaller) configureRookCephClusterViaHelm(upgrade bool) error {
values := map[string]interface{}{
"image": "rook/ceph:" + h.settings.RookVersion,
}
// Set the host path the first time, but use the same path for an upgrade
if h.settings.DataDirHostPath == "" {
var err error
h.settings.DataDirHostPath, err = h.initTestDir(h.settings.Namespace)
if err != nil {
return err
}
}
var clusterCRD map[string]interface{}
if err := yaml.Unmarshal([]byte(h.Manifests.GetCephCluster()), &clusterCRD); err != nil {
return err
}
values["cephClusterSpec"] = clusterCRD["spec"]
values["operatorNamespace"] = h.settings.OperatorNamespace
values["configOverride"] = clusterCustomSettings
values["toolbox"] = map[string]interface{}{
"enabled": true,
"resources": nil,
}
values["monitoring"] = map[string]interface{}{
"enabled": true,
"createPrometheusRules": true,
}
values["ingress"] = map[string]interface{}{
"dashboard": map[string]interface{}{
"annotations": map[string]interface{}{
"kubernetes.io/ingress-class": "nginx",
"nginx.ingress.kubernetes.io/rewrite-target": "/ceph-dashboard/$2",
},
"host": map[string]interface{}{
"name": "localhost",
"path": "/ceph-dashboard(/|$)(.*)",
"pathType": "ImplementationSpecific",
},
},
}
if err := h.CreateBlockPoolConfiguration(values, BlockPoolName, BlockPoolSCName); err != nil {
return err
}
if err := h.CreateFileSystemConfiguration(values, FilesystemName, FilesystemSCName); err != nil {
return err
}
if err := h.CreateObjectStoreConfiguration(values, ObjectStoreName, ObjectStoreSCName); err != nil {
return err
}
logger.Infof("Creating ceph cluster using Helm with values: %+v", values)
if h.settings.RookVersion == LocalBuildTag {
if err := h.helmHelper.InstallLocalHelmChart(upgrade, h.settings.Namespace, CephClusterChartName, values); err != nil {
return err
}
} else {
// Install official version of the chart
if err := h.helmHelper.InstallVersionedChart(h.settings.Namespace, CephClusterChartName, h.settings.RookVersion, values); err != nil {
return err
}
}
if h.settings.RookVersion == LocalBuildTag && h.settings.UseHelm {
if err := h.InstallCephCsiDriversViaHelm(); err != nil {
return errors.Wrap(err, "failed to install ceph-csi-drivers chart")
}
}
return nil
}
func csiDriverChartValues(driverName string) map[string]interface{} {
return map[string]interface{}{
"name": driverName,
"enabled": true,
"snapshotPolicy": "volumeSnapshot",
"imageSet": map[string]interface{}{
"name": "rook-csi-operator-image-set-configmap",
},
"nodePlugin": map[string]interface{}{
"kubeletDirPath": "/var/lib/kubelet",
"priorityClassName": "system-node-critical",
"enableSeLinuxHostMount": false,
},
"controllerPlugin": map[string]interface{}{
"priorityClassName": "system-cluster-critical",
"replicas": 2,
"deploymentStrategy": map[string]interface{}{
"type": "Recreate",
},
},
}
}
func (h *CephInstaller) InstallCephCsiDriversViaHelm() error {
if err := h.k8shelper.CreateSnapshotCRD("create"); err != nil {
return errors.Wrap(err, "failed to install snapshot CRDs")
}
if err := h.k8shelper.CreateSnapshotController("create"); err != nil {
return errors.Wrap(err, "failed to install snapshot controller")
}
// the snapshot controller is installed while the cluster is busy rolling daemons during
// upgrade tests, and its image pull plus rollout regularly exceeds 150s in CI
if err := h.k8shelper.WaitForSnapshotController(90); err != nil {
return errors.Wrap(err, "snapshot controller is not ready")
}
op := h.settings.OperatorNamespace
drivers := map[string]interface{}{
"rbd": csiDriverChartValues(fmt.Sprintf("%s.rbd.csi.ceph.com", op)),
"cephfs": csiDriverChartValues(fmt.Sprintf("%s.cephfs.csi.ceph.com", op)),
"nvmeof": map[string]interface{}{"enabled": false},
}
if h.settings.TestNFSCSI {
drivers["nfs"] = csiDriverChartValues(fmt.Sprintf("%s.nfs.csi.ceph.com", op))
} else {
drivers["nfs"] = map[string]interface{}{"enabled": false}
}
values := map[string]interface{}{
"operatorConfig": map[string]interface{}{
"name": "ceph-csi-operator-config",
"namespace": op,
"create": true,
"driverSpecDefaults": map[string]interface{}{
"log": map[string]interface{}{"verbosity": 0},
"imageSet": map[string]interface{}{
"name": "rook-csi-operator-image-set-configmap",
},
"snapshotPolicy": "volumeSnapshot",
"enableMetadata": false,
"generateOMapInfo": false,
"fsGroupPolicy": "File",
"deployCsiAddons": false,
"cephFsClientType": "kernel",
"nodePlugin": map[string]interface{}{
"kubeletDirPath": "/var/lib/kubelet",
"priorityClassName": "system-node-critical",
"enableSeLinuxHostMount": false,
},
"controllerPlugin": map[string]interface{}{
"priorityClassName": "system-cluster-critical",
"replicas": 2,
"deploymentStrategy": map[string]interface{}{
"type": "Recreate",
},
},
},
},
"drivers": drivers,
}
return h.helmHelper.InstallOrUpgradeHelmRepoChart(
op,
cephCsiDriversReleaseName,
cephCsiOperatorHelmRepoURL,
cephCsiOperatorHelmRepoName,
cephCsiDriversChartName,
cephCsiDriversChartVersion,
values,
)
}
// removeCephClusterHelmResources tidies up the helm created CRs and Storage Classes, as they interfere with other tests.
func (h *CephInstaller) removeCephClusterHelmResources() {
if err := h.k8shelper.Clientset.StorageV1().StorageClasses().Delete(context.TODO(), BlockPoolSCName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.Clientset.StorageV1().StorageClasses().Delete(context.TODO(), FilesystemSCName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.Clientset.StorageV1().StorageClasses().Delete(context.TODO(), ObjectStoreSCName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.RookClientset.CephV1().CephBlockPools(h.settings.Namespace).Delete(context.TODO(), BlockPoolName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.RookClientset.CephV1().CephFilesystemSubVolumeGroups(h.settings.Namespace).Delete(context.TODO(), FilesystemName+"-csi", v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.RookClientset.CephV1().CephFilesystems(h.settings.Namespace).Delete(context.TODO(), FilesystemName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if err := h.k8shelper.RookClientset.CephV1().CephObjectStores(h.settings.Namespace).Delete(context.TODO(), ObjectStoreName, v1.DeleteOptions{}); err != nil {
assert.True(h.T(), kerrors.IsNotFound(err))
}
if !h.k8shelper.WaitUntilPodWithLabelDeleted(fmt.Sprintf("rook_object_store=%s", ObjectStoreName), h.settings.Namespace) {
assert.Fail(h.T(), "rgw did not stop via helm uninstall")
}
}
// ConfirmHelmClusterInstalledCorrectly runs some validation to check whether the helm chart installed correctly.
func (h *CephInstaller) ConfirmHelmClusterInstalledCorrectly() error {
storageClassList, err := h.k8shelper.Clientset.StorageV1().StorageClasses().List(context.TODO(), v1.ListOptions{})
if err != nil {
return err
}
foundStorageClasses := 0
for _, storageClass := range storageClassList.Items {
switch storageClass.Name {
case BlockPoolSCName:
foundStorageClasses++
case FilesystemSCName:
foundStorageClasses++
case ObjectStoreSCName:
foundStorageClasses++
}
}
if foundStorageClasses != 3 {
return fmt.Errorf("did not find the three storage classes which should have been deployed")
}
// check that ObjectStore is created
logger.Infof("Check that RGW pods are Running")
for i := 0; i < 24 && !h.k8shelper.CheckPodCountAndState("rook-ceph-rgw", h.settings.Namespace, 2, "Running"); i++ {
logger.Infof("(%d) RGW pod check sleeping for 5 seconds ...", i)
time.Sleep(5 * time.Second)
}
if !h.k8shelper.CheckPodCountAndState("rook-ceph-rgw", h.settings.Namespace, 2, "Running") {
return fmt.Errorf("did not find the rados gateway pod, which should have been deployed")
}
return nil
}
// CreateBlockPoolConfiguration creates a block store configuration
func (h *CephInstaller) CreateBlockPoolConfiguration(values map[string]interface{}, name, scName string) error {
testBlockPoolBytes := []byte(h.Manifests.GetBlockPool("testPool", "1"))
var testBlockPoolCRD map[string]interface{}
if err := yaml.Unmarshal(testBlockPoolBytes, &testBlockPoolCRD); err != nil {
return err
}
storageClassBytes := []byte(h.Manifests.GetBlockStorageClass(name, scName, "Delete"))
var testBlockSC map[string]interface{}
if err := yaml.Unmarshal(storageClassBytes, &testBlockSC); err != nil {
return err
}
values["cephBlockPools"] = []map[string]interface{}{
{
"name": name,
"spec": testBlockPoolCRD["spec"],
"storageClass": map[string]interface{}{
"enabled": true,
"isDefault": true,
"name": scName,
"parameters": testBlockSC["parameters"],
"reclaimPolicy": "Delete",
"allowVolumeExpansion": true,
},
},
}
return nil
}
// CreateFileSystemConfiguration creates a filesystem configuration
func (h *CephInstaller) CreateFileSystemConfiguration(values map[string]interface{}, name, scName string) error {
testFilesystemBytes := []byte(h.Manifests.GetFilesystem("testFilesystem", 1))
var testFilesystemCRD map[string]interface{}
if err := yaml.Unmarshal(testFilesystemBytes, &testFilesystemCRD); err != nil {
return err
}
storageClassBytes := []byte(h.Manifests.GetFileStorageClass(name, scName))
var testFileSystemSC map[string]interface{}
if err := yaml.Unmarshal(storageClassBytes, &testFileSystemSC); err != nil {
return err
}
values["cephFileSystems"] = []map[string]interface{}{
{
"name": name,
"spec": testFilesystemCRD["spec"],
"storageClass": map[string]interface{}{
"enabled": true,
"name": scName,
"parameters": testFileSystemSC["parameters"],
"reclaimPolicy": "Delete",
},
},
}
return nil
}
// CreateObjectStoreConfiguration creates an object store configuration
func (h *CephInstaller) CreateObjectStoreConfiguration(values map[string]interface{}, name, scName string) error {
testObjectStoreBytes := []byte(h.Manifests.GetObjectStore(name, 2, 8080, false, false))
var testObjectStoreCRD map[string]interface{}
if err := yaml.Unmarshal(testObjectStoreBytes, &testObjectStoreCRD); err != nil {
return err
}
storageClassBytes := []byte(h.Manifests.GetBucketStorageClass(name, scName, "Delete"))
var testObjectStoreSC map[string]interface{}
if err := yaml.Unmarshal(storageClassBytes, &testObjectStoreSC); err != nil {
return err
}
values["cephObjectStores"] = []map[string]interface{}{
{
"name": name,
"spec": testObjectStoreCRD["spec"],
"storageClass": map[string]interface{}{
"enabled": true,
"name": scName,
"parameters": testObjectStoreSC["parameters"],
"reclaimPolicy": "Delete",
},
},
}
return nil
}