Configure the Ceph mds daemon completely from the operator a la the recent changes to the Ceph mon and mgr operators. Create the mds deployments first and then create the keyring secrets for them with their owner reference as the corresponding deployment. This will mean that the secrets do not need to be micromanaged. When the deployment is deleted, the secret is also deleted. This has not been necessary for the mons or the manager since the mons share a keyring with a lifespan of the cluster, as does the mgr, which currently has single-mgr support only. Signed-off-by: Blaine Gardner <blaine.gardner@suse.com>
43 lines
1.9 KiB
Go
43 lines
1.9 KiB
Go
package test
|
|
|
|
import (
|
|
"github.com/rook/rook/pkg/clusterd"
|
|
"k8s.io/api/apps/v1"
|
|
apps "k8s.io/api/apps/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/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 string) (*v1.Deployment, error),
|
|
deploymentsUpdated *[]*apps.Deployment,
|
|
) {
|
|
deploymentsUpdated = &[]*apps.Deployment{}
|
|
stubFunc = func(context *clusterd.Context, deployment *apps.Deployment, namespace string) (*v1.Deployment, error) {
|
|
*deploymentsUpdated = append(*deploymentsUpdated, deployment)
|
|
return &v1.Deployment{ObjectMeta: metav1.ObjectMeta{UID: "stub-deployment-uid"}}, 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{}
|
|
}
|