forked from rook/rook
We now always perform ok-to-stop change when the deployment is going to be updated. This could be for various reasons like change in the spec or a new Ceph image. In any case, if Ceph resources are going to be restarted this must be done carefully. Also trimmed the isUpgrade variable, the upcoming commit will remove the need of that variable. Keeping isUpgrade from the controller code since we need it to detect whether an orchestration upgrade should be triggered or not (based on the ceph cluster status). Also, we keep it on the child controllers so we don't go into an orchestration phase if the cluster image hasn't changed. The child does not need to be updated/go into its orchestration phase because the cluster CR changed. Closes: https://github.com/rook/rook/issues/4379 Signed-off-by: Sébastien Han <seb@redhat.com>
42 lines
2.0 KiB
Go
42 lines
2.0 KiB
Go
package test
|
|
|
|
import (
|
|
"github.com/rook/rook/pkg/clusterd"
|
|
"github.com/rook/rook/pkg/operator/ceph/version"
|
|
apps "k8s.io/api/apps/v1"
|
|
)
|
|
|
|
// UpdateDeploymentAndWaitStub returns a stub replacement for the UpdateDeploymentAndWait function
|
|
// for unit tests which always returns success (nil). The generated simple clientset doesn't seem to
|
|
// handle the Deployment.Update method as expected. The deployment is instead zero-ed out when the
|
|
// deployment is updated with an unchanged version, which breaks unit tests.
|
|
// In order to still test the UpdateDeploymentAndWait function, the stub function returned will
|
|
// append a copy of the deployment used as input to the list of deployments updated. The function
|
|
// returns a pointer to this slice which the calling func may use to verify the expected contents of
|
|
// deploymentsUpdated based on expected behavior.
|
|
func UpdateDeploymentAndWaitStub() (
|
|
stubFunc func(context *clusterd.Context, deployment *apps.Deployment, namespace, daemonType, daemonName string, cephVersion version.CephVersion, skipUpgradeChecks, continueUpgradeAfterChecksEvenIfNotHealthy bool) error,
|
|
deploymentsUpdated *[]*apps.Deployment,
|
|
) {
|
|
deploymentsUpdated = &[]*apps.Deployment{}
|
|
stubFunc = func(context *clusterd.Context, deployment *apps.Deployment, namespace, daemonType, daemonName string, cephVersion version.CephVersion, skipUpgradeChecks, continueUpgradeAfterChecksEvenIfNotHealthy bool) error {
|
|
*deploymentsUpdated = append(*deploymentsUpdated, deployment)
|
|
return nil
|
|
}
|
|
return stubFunc, deploymentsUpdated
|
|
}
|
|
|
|
// DeploymentNamesUpdated converts a deploymentsUpdated slice into a string slice of deployment names
|
|
func DeploymentNamesUpdated(deploymentsUpdated *[]*apps.Deployment) []string {
|
|
ns := []string{}
|
|
for _, d := range *deploymentsUpdated {
|
|
ns = append(ns, d.GetName())
|
|
}
|
|
return ns
|
|
}
|
|
|
|
// ClearDeploymentsUpdated clears the deploymentsUpdated list
|
|
func ClearDeploymentsUpdated(deploymentsUpdated *[]*apps.Deployment) {
|
|
*deploymentsUpdated = []*apps.Deployment{}
|
|
}
|