core: fix golangci-lint check ST1019
This change cleans up and standardizes import statements across the Ceph operator code. It removes redundant or duplicate imports and reorganizes alias names for improved clarity and consistency. Additionally, the ST1019 exception was removed from .golangci.yaml now that the code complies with the rule. Signed-off-by: Carlos Barria <cbarria@yahoo.com>
This commit is contained in:
1 parent
ad16cb7262
commit
c63ebbe0e3
18 files changed
+81
-101
No files matched your search
@@ -25,9 +25,6 @@ linters:
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "QF1001:" # could apply De Morgan's law (staticcheck)
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "ST1019" # package "github.com/rook/rook/pkg/daemon/ceph/client" is being imported more than once (staticcheck)
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "QF1006:" # could lift into loop condition (staticcheck)
|
||||
|
||||
@@ -21,11 +21,10 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
)
|
||||
|
||||
func RadosNamespaceCleanup(context *clusterd.Context, clusterInfo *client.ClusterInfo, poolName, radosNamespace string) error {
|
||||
func RadosNamespaceCleanup(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, poolName, radosNamespace string) error {
|
||||
logger.Infof("starting clean up of CephBlockPoolRadosNamespace %q resources in cephblockpool %q", radosNamespace, poolName)
|
||||
|
||||
err := cleanupImages(context, clusterInfo, poolName, radosNamespace)
|
||||
@@ -38,7 +37,7 @@ func RadosNamespaceCleanup(context *clusterd.Context, clusterInfo *client.Cluste
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanupImages(context *clusterd.Context, clusterInfo *client.ClusterInfo, poolName, radosNamespace string) error {
|
||||
func cleanupImages(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, poolName, radosNamespace string) error {
|
||||
msg := fmt.Sprintf("cephblockpool %q", poolName)
|
||||
if radosNamespace != "" {
|
||||
msg = fmt.Sprintf("%s in rados namespace %q", msg, radosNamespace)
|
||||
@@ -80,7 +79,7 @@ func cleanupImages(context *clusterd.Context, clusterInfo *client.ClusterInfo, p
|
||||
return retErr
|
||||
}
|
||||
|
||||
func BlockPoolCleanup(context *clusterd.Context, clusterInfo *client.ClusterInfo, poolName string) error {
|
||||
func BlockPoolCleanup(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, poolName string) error {
|
||||
logger.Infof("starting clean up of CephBlockPool %q resource", poolName)
|
||||
|
||||
err := cleanupImages(context, clusterInfo, poolName, "")
|
||||
|
||||
@@ -22,11 +22,10 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
)
|
||||
|
||||
func SubVolumeGroupCleanup(context *clusterd.Context, clusterInfo *client.ClusterInfo, fsName, svg, poolName, csiNamespace string) error {
|
||||
func SubVolumeGroupCleanup(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, fsName, svg, poolName, csiNamespace string) error {
|
||||
logger.Infof("starting clean up cephFS subVolumeGroup resource %q", svg)
|
||||
|
||||
subVolumeList, err := cephclient.ListSubvolumesInGroup(context, clusterInfo, fsName, svg)
|
||||
@@ -77,7 +76,7 @@ func SubVolumeGroupCleanup(context *clusterd.Context, clusterInfo *client.Cluste
|
||||
return nil
|
||||
}
|
||||
|
||||
func CancelPendingClones(context *clusterd.Context, clusterInfo *client.ClusterInfo, snapshots cephclient.SubVolumeSnapshots, fsName, subvol, svg string) error {
|
||||
func CancelPendingClones(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, snapshots cephclient.SubVolumeSnapshots, fsName, subvol, svg string) error {
|
||||
for _, snapshot := range snapshots {
|
||||
logger.Infof("deleting any pending clones of snapshot %q of subvolume %q of group %q", snapshot.Name, subvol, svg)
|
||||
pendingClones, err := cephclient.ListSubVolumeSnapshotPendingClones(context, clusterInfo, fsName, subvol, snapshot.Name, svg)
|
||||
@@ -94,7 +93,7 @@ func CancelPendingClones(context *clusterd.Context, clusterInfo *client.ClusterI
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteSubVolumeSnapshots(context *clusterd.Context, clusterInfo *client.ClusterInfo, snapshots cephclient.SubVolumeSnapshots, fsName, subvol, svg string) error {
|
||||
func DeleteSubVolumeSnapshots(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, snapshots cephclient.SubVolumeSnapshots, fsName, subvol, svg string) error {
|
||||
for _, snapshot := range snapshots {
|
||||
logger.Infof("deleting snapshot %q for subvolume %q in group %q", snapshot.Name, subvol, svg)
|
||||
err := cephclient.DeleteSubvolumeSnapshot(context, clusterInfo, fsName, subvol, svg, snapshot.Name)
|
||||
@@ -106,7 +105,7 @@ func DeleteSubVolumeSnapshots(context *clusterd.Context, clusterInfo *client.Clu
|
||||
return nil
|
||||
}
|
||||
|
||||
func CleanUpOMAPDetails(context *clusterd.Context, clusterInfo *client.ClusterInfo, objName, poolName, namespace string) error {
|
||||
func CleanUpOMAPDetails(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, objName, poolName, namespace string) error {
|
||||
omapValue := getOMAPValue(objName)
|
||||
if omapValue == "" {
|
||||
return errors.New(fmt.Sprintf("failed to get OMAP value for object %q", objName))
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/version"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@@ -126,7 +125,7 @@ func enablePoolMirroring(context *clusterd.Context, clusterInfo *ClusterInfo, po
|
||||
logger.Infof("enabling mirroring type %q for pool %q", pool.Mirroring.Mode, pool.Name)
|
||||
|
||||
if pool.Mirroring.Mode == mirrorModeInitOnly && !clusterInfo.CephVersion.IsAtLeastTentacle() {
|
||||
return fmt.Errorf("ceph version %q does not support mirroring mode %s, minimum ceph version required is %q", clusterInfo.CephVersion.String(), pool.Mirroring.Mode, version.Tentacle.String())
|
||||
return fmt.Errorf("ceph version %q does not support mirroring mode %s, minimum ceph version required is %q", clusterInfo.CephVersion.String(), pool.Mirroring.Mode, cephver.Tentacle.String())
|
||||
}
|
||||
|
||||
mirrorInfo, err := GetPoolMirroringInfo(context, clusterInfo, pool.Name)
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/rbd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/ceph/file/mds"
|
||||
"github.com/rook/rook/pkg/operator/ceph/file/mirror"
|
||||
@@ -76,7 +75,7 @@ func (c *ClusterController) startCleanUpJobs(cluster *cephv1.CephCluster, cephHo
|
||||
jobName := k8sutil.TruncateNodeNameForJob("cluster-cleanup-job-%s", hostName)
|
||||
podSpec := c.cleanUpJobTemplateSpec(cluster, monSecret, clusterFSID)
|
||||
podSpec.Spec.NodeSelector = map[string]string{k8sutil.LabelHostname(): hostName}
|
||||
labels := controller.AppLabels(CleanupAppName, cluster.Namespace)
|
||||
labels := opcontroller.AppLabels(CleanupAppName, cluster.Namespace)
|
||||
labels[CleanupAppName] = "true"
|
||||
job := &batch.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -122,7 +121,7 @@ func (c *ClusterController) cleanUpJobContainer(cluster *cephv1.CephCluster, mon
|
||||
{Name: sanitizeDataSource, Value: cluster.Spec.CleanupPolicy.SanitizeDisks.DataSource.String()},
|
||||
{Name: sanitizeIteration, Value: strconv.Itoa(int(cluster.Spec.CleanupPolicy.SanitizeDisks.Iteration))},
|
||||
}...)
|
||||
if controller.LoopDevicesAllowed() {
|
||||
if opcontroller.LoopDevicesAllowed() {
|
||||
envVars = append(envVars, v1.EnvVar{Name: "CEPH_VOLUME_ALLOW_LOOP_DEVICES", Value: "true"})
|
||||
}
|
||||
}
|
||||
@@ -131,7 +130,7 @@ func (c *ClusterController) cleanUpJobContainer(cluster *cephv1.CephCluster, mon
|
||||
// See https://tracker.ceph.com/issues/53511
|
||||
// Also, it's hard to catch the ceph version since the cluster is being deleted so not
|
||||
// implementing a version check and simply always run this as root
|
||||
securityContext := controller.PrivilegedContext(true)
|
||||
securityContext := opcontroller.PrivilegedContext(true)
|
||||
|
||||
return v1.Container{
|
||||
Name: "host-cleanup",
|
||||
@@ -256,7 +255,7 @@ func (c *ClusterController) getCephHosts(namespace string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *ClusterController) getCleanUpDetails(cephClusterSpec *cephv1.ClusterSpec, namespace string) (string, string, error) {
|
||||
clusterInfo, _, _, err := controller.LoadClusterInfo(c.context, c.OpManagerCtx, namespace, cephClusterSpec)
|
||||
clusterInfo, _, _, err := opcontroller.LoadClusterInfo(c.context, c.OpManagerCtx, namespace, cephClusterSpec)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "failed to get cluster info")
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/telemetry"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
testop "github.com/rook/rook/pkg/operator/test"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -567,7 +566,7 @@ func TestFetchCephConfigFromSecrets(t *testing.T) {
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
clientset := test.New(t, 1)
|
||||
clientset := testop.New(t, 1)
|
||||
clusterInfo := cephclient.AdminTestClusterInfo("rook-ceph")
|
||||
|
||||
for _, s := range tc.secrets {
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
clienttest "github.com/rook/rook/pkg/daemon/ceph/client/test"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
testopk8s "github.com/rook/rook/pkg/operator/k8sutil/test"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
@@ -799,7 +798,7 @@ func TestExternalMons_notInSpec_InQuorum(t *testing.T) {
|
||||
cm, err := c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM := controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM := opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 5)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, inital5Mons[id].Name, mon.Name)
|
||||
@@ -824,7 +823,7 @@ func TestExternalMons_notInSpec_InQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 4)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, inital5Mons[id].Name, mon.Name)
|
||||
@@ -848,7 +847,7 @@ func TestExternalMons_notInSpec_InQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 5)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, c.ClusterInfo.InternalMonitors[id].Name, mon.Name)
|
||||
@@ -924,7 +923,7 @@ func TestExternalMons_inSpec_notInQuorum(t *testing.T) {
|
||||
cm, err := c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM := controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM := opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 5)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, inital5Mons[id].Name, mon.Name)
|
||||
@@ -947,7 +946,7 @@ func TestExternalMons_inSpec_notInQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 4)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, inital5Mons[id].Name, mon.Name)
|
||||
@@ -971,7 +970,7 @@ func TestExternalMons_inSpec_notInQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 5)
|
||||
for id, mon := range monsFromCM {
|
||||
assert.Equal(t, c.ClusterInfo.InternalMonitors[id].Name, mon.Name)
|
||||
@@ -1055,7 +1054,7 @@ func TestExternalMons_inSpec_inQuorum(t *testing.T) {
|
||||
cm, err := c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "ext-mon-id", cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM := controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM := opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 6)
|
||||
for id, mon := range monsFromCM {
|
||||
if id == "ext-mon-id" {
|
||||
@@ -1084,7 +1083,7 @@ func TestExternalMons_inSpec_inQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "ext-mon-id", cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 5)
|
||||
for id, mon := range monsFromCM {
|
||||
if id == "ext-mon-id" {
|
||||
@@ -1119,7 +1118,7 @@ func TestExternalMons_inSpec_inQuorum(t *testing.T) {
|
||||
cm, err = c.context.Clientset.CoreV1().ConfigMaps(c.Namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "ext-mon-id", cm.Data[EndpointExternalMonsKey])
|
||||
monsFromCM = controller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
monsFromCM = opcontroller.ParseMonEndpoints(cm.Data[EndpointDataKey])
|
||||
assert.Len(t, monsFromCM, 6)
|
||||
for id, mon := range monsFromCM {
|
||||
if id == "ext-mon-id" {
|
||||
|
||||
@@ -45,7 +45,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discoveryv1 "k8s.io/api/discovery/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -160,7 +159,7 @@ type monConfig struct {
|
||||
}
|
||||
|
||||
type SchedulingResult struct {
|
||||
Node *v1.Node
|
||||
Node *corev1.Node
|
||||
CanaryDeployment *apps.Deployment
|
||||
CanaryPVC string
|
||||
}
|
||||
@@ -695,7 +694,7 @@ func scheduleMonitor(c *Cluster, mon *monConfig) (*apps.Deployment, error) {
|
||||
// the canary and real monitor deployments will mount the same storage. to
|
||||
// avoid issues with the real deployment, the canary should be careful not
|
||||
// to modify the storage by instead running an innocuous command.
|
||||
d.Spec.Template.Spec.InitContainers = []v1.Container{}
|
||||
d.Spec.Template.Spec.InitContainers = []corev1.Container{}
|
||||
d.Spec.Template.Spec.Containers[0].Image = c.rookImage
|
||||
d.Spec.Template.Spec.Containers[0].Command = []string{"sleep"} // sleep responds to signals so we don't need to wrap it
|
||||
d.Spec.Template.Spec.Containers[0].Args = []string{"3600"}
|
||||
@@ -992,7 +991,7 @@ func (c *Cluster) assignMons(mons []*monConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) monVolumeClaimTemplate(mon *monConfig) *v1.PersistentVolumeClaim {
|
||||
func (c *Cluster) monVolumeClaimTemplate(mon *monConfig) *corev1.PersistentVolumeClaim {
|
||||
if c.spec.ZonesRequired() {
|
||||
// If a stretch cluster, a zone can override the template from the default.
|
||||
|
||||
@@ -1325,7 +1324,7 @@ func (c *Cluster) createEndpointSliceForAddresses(addresses []string, addressTyp
|
||||
}
|
||||
|
||||
func (c *Cluster) persistExpectedMonDaemonsInConfigMap() error {
|
||||
configMap := &v1.ConfigMap{
|
||||
configMap := &corev1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: EndpointConfigMapName,
|
||||
Namespace: c.Namespace,
|
||||
@@ -1652,7 +1651,7 @@ func isMonIPUpdateRequiredForHostNetwork(mon string, isMonUsingHostNetwork bool,
|
||||
return false
|
||||
}
|
||||
|
||||
func hasMonPathChanged(d *apps.Deployment, claim *v1.PersistentVolumeClaim) bool {
|
||||
func hasMonPathChanged(d *apps.Deployment, claim *corev1.PersistentVolumeClaim) bool {
|
||||
if d.Labels["pvc_name"] == "" && claim != nil {
|
||||
logger.Infof("skipping update for mon %q where path has changed from hostPath to pvc", d.Name)
|
||||
return true
|
||||
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
clienttest "github.com/rook/rook/pkg/daemon/ceph/client/test"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -1081,7 +1080,7 @@ func TestSkipReconcile(t *testing.T) {
|
||||
deployment, err := c.context.Clientset.AppsV1().Deployments(c.ClusterInfo.Namespace).Create(c.ClusterInfo.Context, monDeployment, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
result, err := controller.GetDaemonsToSkipReconcile(c.ClusterInfo.Context, c.context, c.ClusterInfo.Namespace, config.MonType, AppName)
|
||||
result, err := opcontroller.GetDaemonsToSkipReconcile(c.ClusterInfo.Context, c.context, c.ClusterInfo.Namespace, config.MonType, AppName)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, result.Len())
|
||||
|
||||
@@ -1092,7 +1091,7 @@ func TestSkipReconcile(t *testing.T) {
|
||||
_, err = c.context.Clientset.AppsV1().Deployments(c.ClusterInfo.Namespace).Update(c.ClusterInfo.Context, deployment, metav1.UpdateOptions{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
result, err = controller.GetDaemonsToSkipReconcile(c.ClusterInfo.Context, c.context, c.ClusterInfo.Namespace, config.MonType, AppName)
|
||||
result, err = opcontroller.GetDaemonsToSkipReconcile(c.ClusterInfo.Context, c.context, c.ClusterInfo.Namespace, config.MonType, AppName)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, result.Len())
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
kms "github.com/rook/rook/pkg/daemon/ceph/osd/kms"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
batch "k8s.io/api/batch/v1"
|
||||
@@ -77,7 +76,7 @@ func (c *Cluster) makeJob(osdProps osdProperties, provisionConfig *provisionConf
|
||||
}
|
||||
|
||||
k8sutil.AddRookVersionLabelToJob(job)
|
||||
controller.AddCephVersionLabelToJob(c.clusterInfo.CephVersion, job)
|
||||
opcontroller.AddCephVersionLabelToJob(c.clusterInfo.CephVersion, job)
|
||||
err = c.clusterInfo.OwnerInfo.SetControllerReference(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -103,7 +102,7 @@ func (c *Cluster) provisionPodTemplateSpec(osdProps osdProperties, restart v1.Re
|
||||
|
||||
// ceph-volume is currently set up to use /etc/ceph/ceph.conf; this means no user config
|
||||
// overrides will apply to ceph-volume, but this is unnecessary anyway
|
||||
volumes := append(controller.PodVolumes(provisionConfig.DataPathMap, c.spec.DataDirHostPath, c.spec.DataDirHostPath, true), copyBinariesVolume)
|
||||
volumes := append(opcontroller.PodVolumes(provisionConfig.DataPathMap, c.spec.DataDirHostPath, c.spec.DataDirHostPath, true), copyBinariesVolume)
|
||||
volumes = c.updateCephConfigVolume(volumes, osdProps.crushHostname)
|
||||
|
||||
// create a volume on /dev so the pod can access devices on the host
|
||||
@@ -239,14 +238,14 @@ func (c *Cluster) provisionOSDContainer(osdProps osdProperties, copyBinariesMoun
|
||||
envVars = append(envVars, metadataDeviceEnvVar(osdProps.metadataDevice))
|
||||
}
|
||||
|
||||
volumeMounts := append(controller.CephVolumeMounts(provisionConfig.DataPathMap, true), []v1.VolumeMount{
|
||||
volumeMounts := append(opcontroller.CephVolumeMounts(provisionConfig.DataPathMap, true), []v1.VolumeMount{
|
||||
{Name: "devices", MountPath: "/dev"},
|
||||
{Name: "udev", MountPath: "/run/udev"},
|
||||
copyBinariesMount,
|
||||
mon.CephSecretVolumeMount(),
|
||||
}...)
|
||||
|
||||
if controller.LoopDevicesAllowed() {
|
||||
if opcontroller.LoopDevicesAllowed() {
|
||||
envVars = append(envVars, v1.EnvVar{Name: "CEPH_VOLUME_ALLOW_LOOP_DEVICES", Value: "true"})
|
||||
}
|
||||
|
||||
@@ -334,7 +333,7 @@ func (c *Cluster) provisionOSDContainer(osdProps osdProperties, copyBinariesMoun
|
||||
Args: []string{"ceph", "osd", "provision"},
|
||||
Name: "provision",
|
||||
Image: c.spec.CephVersion.Image,
|
||||
ImagePullPolicy: controller.GetContainerImagePullPolicy(c.spec.CephVersion.ImagePullPolicy),
|
||||
ImagePullPolicy: opcontroller.GetContainerImagePullPolicy(c.spec.CephVersion.ImagePullPolicy),
|
||||
VolumeMounts: volumeMounts,
|
||||
Env: envVars,
|
||||
EnvFrom: getEnvFromSources(),
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
opconfig "github.com/rook/rook/pkg/operator/ceph/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -137,7 +136,7 @@ done
|
||||
func configOverrideConfigMapVolumeAndMount() (v1.Volume, v1.VolumeMount) {
|
||||
secretAndConfigMapVolumeProjections := []v1.VolumeProjection{}
|
||||
name := k8sutil.ConfigOverrideName // configmap name and name of volume
|
||||
dir := config.EtcCephDir
|
||||
dir := opconfig.EtcCephDir
|
||||
file := "ceph.conf"
|
||||
// TL;DR: mount the configmap's "config" to a file called "ceph.conf" with 0444 permissions
|
||||
// security: allow to be read by everyone since now ceph processes run as 'ceph' and not 'root' user
|
||||
@@ -179,7 +178,7 @@ func configOverrideConfigMapVolumeAndMount() (v1.Volume, v1.VolumeMount) {
|
||||
// ConfGeneratedInPodVolumeAndMount generate an empty dir of /etc/ceph
|
||||
func ConfGeneratedInPodVolumeAndMount() (v1.Volume, v1.VolumeMount) {
|
||||
name := "ceph-conf-emptydir"
|
||||
dir := config.EtcCephDir
|
||||
dir := opconfig.EtcCephDir
|
||||
v := v1.Volume{Name: name, VolumeSource: v1.VolumeSource{
|
||||
EmptyDir: &v1.EmptyDirVolumeSource{},
|
||||
}}
|
||||
@@ -193,7 +192,7 @@ func ConfGeneratedInPodVolumeAndMount() (v1.Volume, v1.VolumeMount) {
|
||||
|
||||
// PodVolumes fills in the volumes parameter with the common list of Kubernetes volumes for use in Ceph pods.
|
||||
// This function is only used for OSDs.
|
||||
func PodVolumes(dataPaths *config.DataPathMap, dataDirHostPath string, exporterHostPath string, confGeneratedInPod bool) []v1.Volume {
|
||||
func PodVolumes(dataPaths *opconfig.DataPathMap, dataDirHostPath string, exporterHostPath string, confGeneratedInPod bool) []v1.Volume {
|
||||
dataDirSource := v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}
|
||||
if dataDirHostPath != "" {
|
||||
dataDirSource = v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: dataDirHostPath}}
|
||||
@@ -217,7 +216,7 @@ func PodVolumes(dataPaths *config.DataPathMap, dataDirHostPath string, exporterH
|
||||
|
||||
// CephVolumeMounts returns the common list of Kubernetes volume mounts for Ceph containers.
|
||||
// This function is only used for OSDs.
|
||||
func CephVolumeMounts(dataPaths *config.DataPathMap, confGeneratedInPod bool) []v1.VolumeMount {
|
||||
func CephVolumeMounts(dataPaths *opconfig.DataPathMap, confGeneratedInPod bool) []v1.VolumeMount {
|
||||
_, configMount := configOverrideConfigMapVolumeAndMount()
|
||||
if confGeneratedInPod {
|
||||
_, configMount = ConfGeneratedInPodVolumeAndMount()
|
||||
@@ -236,12 +235,12 @@ func CephVolumeMounts(dataPaths *config.DataPathMap, confGeneratedInPod bool) []
|
||||
|
||||
// RookVolumeMounts returns the common list of Kubernetes volume mounts for Rook containers.
|
||||
// This function is only used by OSDs.
|
||||
func RookVolumeMounts(dataPaths *config.DataPathMap, confGeneratedInPod bool) []v1.VolumeMount {
|
||||
func RookVolumeMounts(dataPaths *opconfig.DataPathMap, confGeneratedInPod bool) []v1.VolumeMount {
|
||||
return CephVolumeMounts(dataPaths, confGeneratedInPod)
|
||||
}
|
||||
|
||||
// DaemonVolumesBase returns the common / static set of volumes.
|
||||
func DaemonVolumesBase(dataPaths *config.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.Volume {
|
||||
func DaemonVolumesBase(dataPaths *opconfig.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.Volume {
|
||||
configOverrideVolume, _ := configOverrideConfigMapVolumeAndMount()
|
||||
vols := []v1.Volume{
|
||||
configOverrideVolume,
|
||||
@@ -276,7 +275,7 @@ func DaemonVolumesDataPVC(pvcName string) v1.Volume {
|
||||
|
||||
// DaemonVolumesDataHostPath returns HostPath volume source for daemon container
|
||||
// data.
|
||||
func DaemonVolumesDataHostPath(dataPaths *config.DataPathMap) []v1.Volume {
|
||||
func DaemonVolumesDataHostPath(dataPaths *opconfig.DataPathMap) []v1.Volume {
|
||||
vols := []v1.Volume{}
|
||||
if dataPaths.ContainerDataDir == "" {
|
||||
// no data is stored in container, and therefore no data can be persisted to host
|
||||
@@ -304,7 +303,7 @@ func DaemonVolumesContainsPVC(volumes []v1.Volume) bool {
|
||||
|
||||
// DaemonVolumes returns the pod volumes used by all Ceph daemons. If keyring resource name is
|
||||
// empty, there will be no keyring volume created from a secret.
|
||||
func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.Volume {
|
||||
func DaemonVolumes(dataPaths *opconfig.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.Volume {
|
||||
vols := DaemonVolumesBase(dataPaths, keyringResourceName, dataDirHostPath)
|
||||
vols = append(vols, DaemonVolumesDataHostPath(dataPaths)...)
|
||||
return vols
|
||||
@@ -313,7 +312,7 @@ func DaemonVolumes(dataPaths *config.DataPathMap, keyringResourceName string, da
|
||||
// DaemonVolumeMounts returns volume mounts which correspond to the DaemonVolumes. These
|
||||
// volume mounts are shared by most all Ceph daemon containers, both init and standard. If keyring
|
||||
// resource name is empty, there will be no keyring mounted in the container.
|
||||
func DaemonVolumeMounts(dataPaths *config.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.VolumeMount {
|
||||
func DaemonVolumeMounts(dataPaths *opconfig.DataPathMap, keyringResourceName string, dataDirHostPath string) []v1.VolumeMount {
|
||||
_, configOverrideMount := configOverrideConfigMapVolumeAndMount()
|
||||
mounts := []v1.VolumeMount{
|
||||
configOverrideMount,
|
||||
@@ -366,14 +365,14 @@ func AddVolumeMountSubPath(podSpec *v1.PodSpec, volumeMountName string) {
|
||||
// DaemonFlags returns the command line flags used by all Ceph daemons.
|
||||
func DaemonFlags(cluster *client.ClusterInfo, spec *cephv1.ClusterSpec, daemonID string) []string {
|
||||
flags := append(
|
||||
config.DefaultFlags(cluster.FSID, keyring.VolumeMount().KeyringFilePath()),
|
||||
config.NewFlag("id", daemonID),
|
||||
opconfig.DefaultFlags(cluster.FSID, keyring.VolumeMount().KeyringFilePath()),
|
||||
opconfig.NewFlag("id", daemonID),
|
||||
// Ceph daemons in Rook will run as 'ceph' instead of 'root'
|
||||
// If we run on a version of Ceph does not these flags it will simply ignore them
|
||||
// run ceph daemon process under the 'ceph' user
|
||||
config.NewFlag("setuser", "ceph"),
|
||||
opconfig.NewFlag("setuser", "ceph"),
|
||||
// run ceph daemon process under the 'ceph' group
|
||||
config.NewFlag("setgroup", "ceph"),
|
||||
opconfig.NewFlag("setgroup", "ceph"),
|
||||
)
|
||||
flags = append(flags, NetworkBindingFlags(cluster, spec)...)
|
||||
|
||||
@@ -383,9 +382,9 @@ func DaemonFlags(cluster *client.ClusterInfo, spec *cephv1.ClusterSpec, daemonID
|
||||
// AdminFlags returns the command line flags used for Ceph commands requiring admin authentication.
|
||||
func AdminFlags(cluster *client.ClusterInfo) []string {
|
||||
return append(
|
||||
config.DefaultFlags(cluster.FSID, keyring.VolumeMount().AdminKeyringFilePath()),
|
||||
config.NewFlag("setuser", "ceph"),
|
||||
config.NewFlag("setgroup", "ceph"),
|
||||
opconfig.DefaultFlags(cluster.FSID, keyring.VolumeMount().AdminKeyringFilePath()),
|
||||
opconfig.NewFlag("setuser", "ceph"),
|
||||
opconfig.NewFlag("setgroup", "ceph"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -397,16 +396,16 @@ func NetworkBindingFlags(cluster *client.ClusterInfo, spec *cephv1.ClusterSpec)
|
||||
if !spec.Network.DualStack {
|
||||
switch spec.Network.IPFamily {
|
||||
case cephv1.IPv4:
|
||||
args = append(args, config.NewFlag("ms-bind-ipv4", "true"))
|
||||
args = append(args, config.NewFlag("ms-bind-ipv6", "false"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv4", "true"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv6", "false"))
|
||||
|
||||
case cephv1.IPv6:
|
||||
args = append(args, config.NewFlag("ms-bind-ipv4", "false"))
|
||||
args = append(args, config.NewFlag("ms-bind-ipv6", "true"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv4", "false"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv6", "true"))
|
||||
}
|
||||
} else {
|
||||
args = append(args, config.NewFlag("ms-bind-ipv4", "true"))
|
||||
args = append(args, config.NewFlag("ms-bind-ipv6", "true"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv4", "true"))
|
||||
args = append(args, opconfig.NewFlag("ms-bind-ipv6", "true"))
|
||||
}
|
||||
|
||||
return args
|
||||
@@ -425,7 +424,7 @@ func DaemonEnvVars(cephClusterSpec *cephv1.ClusterSpec) []v1.EnvVar {
|
||||
|
||||
return append(
|
||||
cephDaemonsEnvVars,
|
||||
config.StoredMonHostEnvVars()...,
|
||||
opconfig.StoredMonHostEnvVars()...,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -529,7 +528,7 @@ func CheckPodMemory(name string, resources v1.ResourceRequirements, cephPodMinim
|
||||
// directory. This is a race condition for all daemons; therefore, do this in an init container.
|
||||
// See more discussion here: https://github.com/rook/rook/pull/3594#discussion_r312279176
|
||||
func ChownCephDataDirsInitContainer(
|
||||
dpm config.DataPathMap,
|
||||
dpm opconfig.DataPathMap,
|
||||
containerImage string,
|
||||
containerImagePullPolicy v1.PullPolicy,
|
||||
volumeMounts []v1.VolumeMount,
|
||||
@@ -542,8 +541,8 @@ func ChownCephDataDirsInitContainer(
|
||||
"--verbose",
|
||||
"--recursive",
|
||||
"ceph:ceph",
|
||||
config.VarLogCephDir,
|
||||
config.VarLibCephCrashDir,
|
||||
opconfig.VarLogCephDir,
|
||||
opconfig.VarLibCephCrashDir,
|
||||
daemonSocketDir,
|
||||
)
|
||||
if configDir != "" {
|
||||
@@ -604,7 +603,7 @@ cat ` + cfgPath + `
|
||||
Image: containerImage,
|
||||
ImagePullPolicy: containerImagePullPolicy,
|
||||
VolumeMounts: volumeMounts,
|
||||
Env: config.StoredMonHostEnvVars(),
|
||||
Env: opconfig.StoredMonHostEnvVars(),
|
||||
Resources: resources,
|
||||
SecurityContext: securityContext,
|
||||
}
|
||||
@@ -690,7 +689,7 @@ func GenerateStartupProbeExecDaemon(daemonType, daemonID string) *v1.Probe {
|
||||
probe.InitialDelaySeconds = 10
|
||||
probe.PeriodSeconds = 10
|
||||
|
||||
if daemonType == config.OsdType {
|
||||
if daemonType == opconfig.OsdType {
|
||||
probe.FailureThreshold = startupProbeFailuresDaemonOSD
|
||||
} else {
|
||||
probe.FailureThreshold = startupProbeFailuresDaemonDefault
|
||||
@@ -716,7 +715,7 @@ func (c *daemonConfig) buildSocketPath() string {
|
||||
|
||||
func (c *daemonConfig) buildAdminSocketCommand() string {
|
||||
command := "status"
|
||||
if c.daemonType == config.MonType {
|
||||
if c.daemonType == opconfig.MonType {
|
||||
command = "mon_status"
|
||||
}
|
||||
|
||||
@@ -824,7 +823,7 @@ func LogCollectorContainer(daemonID, ns string, c cephv1.ClusterSpec, env []v1.E
|
||||
},
|
||||
Image: c.CephVersion.Image,
|
||||
ImagePullPolicy: GetContainerImagePullPolicy(c.CephVersion.ImagePullPolicy),
|
||||
VolumeMounts: DaemonVolumeMounts(config.NewDatalessDaemonDataPathMap(ns, c.DataDirHostPath), "", c.DataDirHostPath),
|
||||
VolumeMounts: DaemonVolumeMounts(opconfig.NewDatalessDaemonDataPathMap(ns, c.DataDirHostPath), "", c.DataDirHostPath),
|
||||
SecurityContext: PodSecurityContext(),
|
||||
Resources: cephv1.GetLogCollectorResources(c.Resources),
|
||||
// We need a TTY for the bash job control (enabled by -m)
|
||||
@@ -841,11 +840,11 @@ func RgwOpsLogSidecarContainer(opsLogFile, ns string, c cephv1.ClusterSpec, env
|
||||
"bash",
|
||||
"-x", // Enable debugging mode
|
||||
"-c", // Run the following command
|
||||
fmt.Sprintf("tail -n+1 -F %s", path.Join(config.VarLogCephDir, opsLogFile)),
|
||||
fmt.Sprintf("tail -n+1 -F %s", path.Join(opconfig.VarLogCephDir, opsLogFile)),
|
||||
},
|
||||
Image: c.CephVersion.Image,
|
||||
ImagePullPolicy: GetContainerImagePullPolicy(c.CephVersion.ImagePullPolicy),
|
||||
VolumeMounts: DaemonVolumeMounts(config.NewDatalessDaemonDataPathMap(ns, c.DataDirHostPath), "", c.DataDirHostPath),
|
||||
VolumeMounts: DaemonVolumeMounts(opconfig.NewDatalessDaemonDataPathMap(ns, c.DataDirHostPath), "", c.DataDirHostPath),
|
||||
SecurityContext: PodSecurityContext(),
|
||||
Resources: Resources,
|
||||
// We need a TTY for the bash job control (enabled by -m)
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
k8scsiv1 "k8s.io/api/storage/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
@@ -222,7 +221,7 @@ func (r ReconcileCSI) createOrUpdateDriverResource(clusterInfo *cephclient.Clust
|
||||
|
||||
err := r.client.Get(r.opManagerContext, types.NamespacedName{Name: driverResource.Name, Namespace: r.opConfig.OperatorNamespace}, driverResource)
|
||||
if err != nil {
|
||||
if kerrors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
err = r.client.Create(r.opManagerContext, driverResource)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create CSI-operator driver CR %q", driverResource.Name)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
v1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
@@ -153,7 +152,7 @@ func TestRunAdminCommandNoMultisite(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with multus - we use the remote executor", func(t *testing.T) {
|
||||
objContext.clusterInfo.NetworkSpec = v1.NetworkSpec{Provider: "multus"}
|
||||
objContext.clusterInfo.NetworkSpec = cephv1.NetworkSpec{Provider: "multus"}
|
||||
_, err := RunAdminCommandNoMultisite(objContext, true, []string{"zone", "get"}...)
|
||||
assert.Error(t, err)
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/ceph/go-ceph/rgw/admin"
|
||||
"github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
|
||||
bktv1alpha1 "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
|
||||
apibkt "github.com/kube-object-storage/lib-bucket-provisioner/pkg/provisioner/api"
|
||||
"github.com/pkg/errors"
|
||||
@@ -94,7 +93,7 @@ func (p *Provisioner) createCephUser(username string) (accKey string, secKey str
|
||||
return u.Keys[0].AccessKey, u.Keys[0].SecretKey, nil
|
||||
}
|
||||
|
||||
func (p *Provisioner) genUserName(obc *v1alpha1.ObjectBucketClaim) string {
|
||||
func (p *Provisioner) genUserName(obc *bktv1alpha1.ObjectBucketClaim) string {
|
||||
// A deterministic user name can be generated from the OBC's UID. We
|
||||
// cannot simply use the OBC's namespace and name, because they can be
|
||||
// reused, while the preceding bucket might be retained by reclaimPolicy.
|
||||
@@ -177,7 +176,7 @@ func (p *Provisioner) deleteOBUser(ob *bktv1alpha1.ObjectBucket) error {
|
||||
}
|
||||
|
||||
// test a string to determine if is likely to be a user name generated by the provisioner
|
||||
func (p *Provisioner) isObcGeneratedUser(userName string, obc *v1alpha1.ObjectBucketClaim) bool {
|
||||
func (p *Provisioner) isObcGeneratedUser(userName string, obc *bktv1alpha1.ObjectBucketClaim) bool {
|
||||
// If the user name string is the same as the explicitly set bucketOwner we will
|
||||
// assume it is not a machine generated user name.
|
||||
if obc.Spec.AdditionalConfig != nil &&
|
||||
|
||||
@@ -19,7 +19,6 @@ package cosi
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -51,7 +50,7 @@ func createCephCOSIDriverDeployment(cephCOSIDriver *cephv1.CephCOSIDriver) (*app
|
||||
Labels: getCOSILabels(cephCOSIDriver.Name, cephCOSIDriver.Namespace),
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
RevisionHistoryLimit: controller.RevisionHistoryLimit(),
|
||||
RevisionHistoryLimit: opcontroller.RevisionHistoryLimit(),
|
||||
Replicas: &replica,
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: getCOSILabels(cephCOSIDriver.Name, cephCOSIDriver.Namespace),
|
||||
@@ -73,7 +72,7 @@ func setCOSILabels(label map[string]string) {
|
||||
}
|
||||
|
||||
func getCOSILabels(name, namespace string) map[string]string {
|
||||
label := controller.AppLabels(name, namespace)
|
||||
label := opcontroller.AppLabels(name, namespace)
|
||||
setCOSILabels(label)
|
||||
return label
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -194,7 +193,7 @@ func TestCephBucketTopicController(t *testing.T) {
|
||||
"mon-secret": []byte("monsecret"),
|
||||
"admin-secret": []byte("adminsecret"),
|
||||
}
|
||||
secret := &v1.Secret{
|
||||
secret := &corev1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "rook-ceph-mon",
|
||||
Namespace: namespace,
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
discoverDaemon "github.com/rook/rook/pkg/daemon/discover"
|
||||
"github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/util/sys"
|
||||
@@ -124,7 +123,7 @@ func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, disco
|
||||
Name: discoverDaemonsetName,
|
||||
Image: discoverImage,
|
||||
Args: discoveryParameters,
|
||||
SecurityContext: controller.PrivilegedContext(true),
|
||||
SecurityContext: opcontroller.PrivilegedContext(true),
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
{
|
||||
Name: "dev",
|
||||
@@ -235,7 +234,7 @@ func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, disco
|
||||
ds.Spec.Template.ObjectMeta.Labels = podLabels
|
||||
}
|
||||
|
||||
if controller.LoopDevicesAllowed() {
|
||||
if opcontroller.LoopDevicesAllowed() {
|
||||
ds.Spec.Template.Spec.Containers[0].Env = append(ds.Spec.Template.Spec.Containers[0].Env,
|
||||
v1.EnvVar{Name: "CEPH_VOLUME_ALLOW_LOOP_DEVICES", Value: "true"})
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
|
||||
"github.com/ceph/go-ceph/rgw/admin"
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
"github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
|
||||
bktv1alpha1 "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
"github.com/rook/rook/tests/framework/installer"
|
||||
@@ -576,7 +575,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
require.NoError(t, err)
|
||||
obName := liveObc.Spec.ObjectBucketName
|
||||
|
||||
var liveOb *v1alpha1.ObjectBucket
|
||||
var liveOb *bktv1alpha1.ObjectBucket
|
||||
inSync := utils.Retry(40, time.Second, "OB is Bound", func() bool {
|
||||
var err error
|
||||
liveOb, err = k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBuckets().Get(ctx, obName, metav1.GetOptions{})
|
||||
@@ -628,7 +627,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("obc %q has bucketOwner %q set", obc2.Name, obc2.Spec.AdditionalConfig["bucketOwner"]), func(t *testing.T) {
|
||||
var liveObc *v1alpha1.ObjectBucketClaim
|
||||
var liveObc *bktv1alpha1.ObjectBucketClaim
|
||||
obcBound := utils.Retry(40, time.Second, "OBC is Bound", func() bool {
|
||||
var err error
|
||||
liveObc, err = k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBucketClaims(ns.Name).Get(ctx, obc2.Name, metav1.GetOptions{})
|
||||
@@ -636,7 +635,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
return false
|
||||
}
|
||||
|
||||
return liveObc.Status.Phase == v1alpha1.ObjectBucketClaimStatusPhaseBound
|
||||
return liveObc.Status.Phase == bktv1alpha1.ObjectBucketClaimStatusPhaseBound
|
||||
})
|
||||
require.True(t, obcBound)
|
||||
|
||||
@@ -649,7 +648,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
require.NoError(t, err)
|
||||
obName := liveObc.Spec.ObjectBucketName
|
||||
|
||||
var liveOb *v1alpha1.ObjectBucket
|
||||
var liveOb *bktv1alpha1.ObjectBucket
|
||||
obBound := utils.Retry(40, time.Second, "OB is Bound", func() bool {
|
||||
var err error
|
||||
liveOb, err = k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBuckets().Get(ctx, obName, metav1.GetOptions{})
|
||||
@@ -657,7 +656,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
return false
|
||||
}
|
||||
|
||||
return liveOb.Status.Phase == v1alpha1.ObjectBucketStatusPhaseBound
|
||||
return liveOb.Status.Phase == bktv1alpha1.ObjectBucketStatusPhaseBound
|
||||
})
|
||||
require.True(t, obBound)
|
||||
|
||||
@@ -757,7 +756,7 @@ func TestObjectBucketClaimBucketOwner(t *testing.T, k8sh *utils.K8sHelper, insta
|
||||
liveObc, err := k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBucketClaims(obcBogusOwner.Namespace).Get(ctx, obcBogusOwner.Name, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, v1alpha1.ObjectBucketClaimStatusPhasePending == liveObc.Status.Phase)
|
||||
assert.True(t, bktv1alpha1.ObjectBucketClaimStatusPhasePending == liveObc.Status.Phase)
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("user %q does not exist", obcBogusOwner.Spec.AdditionalConfig["bucketOwner"]), func(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user