core: import packages only once
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
(cherry picked from commit 235ac293ff)
This commit is contained in:
1 parent
7c657e3f70
commit
b81d618de5
24 files changed
+72
-98
No files matched your search
@@ -31,7 +31,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
osddaemon "github.com/rook/rook/pkg/daemon/ceph/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
osdcfg "github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -257,7 +256,7 @@ func prepareOSD(cmd *cobra.Command, args []string) error {
|
||||
kv := k8sutil.NewConfigMapKVStore(clusterInfo.Namespace, context.Clientset, ownerInfo)
|
||||
|
||||
// destroy the OSD using the OSD ID
|
||||
var replaceOSD *osd.OSDReplaceInfo
|
||||
var replaceOSD *oposd.OSDReplaceInfo
|
||||
if replaceOSDID != -1 {
|
||||
logger.Infof("destroying osd.%d and cleaning its backing device", replaceOSDID)
|
||||
replaceOSD, err = osddaemon.DestroyOSD(context, &clusterInfo, replaceOSDID, cfg.pvcBacked, cfg.storeConfig.EncryptedDevice)
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/util/sys"
|
||||
@@ -600,7 +599,7 @@ func getVolumeGroupName(lvPath string) string {
|
||||
}
|
||||
|
||||
// GetOSDInfoById returns the osdInfo using the ceph volume list
|
||||
func GetOSDInfoById(context *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int) (*osd.OSDInfo, error) {
|
||||
func GetOSDInfoById(context *clusterd.Context, clusterInfo *client.ClusterInfo, osdID int) (*oposd.OSDInfo, error) {
|
||||
// LVM mode OSDs
|
||||
osdLVMList, err := GetCephVolumeLVMOSDs(context, clusterInfo, clusterInfo.FSID, "", false, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
)
|
||||
@@ -131,7 +130,7 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
|
||||
logger.Errorf("failed to delete deployment for OSD %d. %v", osdID, err)
|
||||
}
|
||||
}
|
||||
if pvcName, ok := deployment.GetLabels()[osd.OSDOverPVCLabelKey]; ok {
|
||||
if pvcName, ok := deployment.GetLabels()[oposd.OSDOverPVCLabelKey]; ok {
|
||||
removeOSDPrepareJob(clusterdContext, clusterInfo, pvcName)
|
||||
removePVCs(clusterdContext, clusterInfo, pvcName, preservePVC)
|
||||
} else {
|
||||
@@ -164,7 +163,7 @@ func removeOSD(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInf
|
||||
}
|
||||
|
||||
func removeOSDPrepareJob(clusterdContext *clusterd.Context, clusterInfo *client.ClusterInfo, pvcName string) {
|
||||
labelSelector := fmt.Sprintf("%s=%s", osd.OSDOverPVCLabelKey, pvcName)
|
||||
labelSelector := fmt.Sprintf("%s=%s", oposd.OSDOverPVCLabelKey, pvcName)
|
||||
prepareJobList, err := clusterdContext.Clientset.BatchV1().Jobs(clusterInfo.Namespace).List(clusterInfo.Context, metav1.ListOptions{LabelSelector: labelSelector})
|
||||
if err != nil && !kerrors.IsNotFound(err) {
|
||||
logger.Errorf("failed to list osd prepare jobs with pvc %q. %v ", pvcName, err)
|
||||
@@ -188,10 +187,10 @@ func removePVCs(clusterdContext *clusterd.Context, clusterInfo *client.ClusterIn
|
||||
return
|
||||
}
|
||||
labels := dataPVC.GetLabels()
|
||||
deviceSet := labels[osd.CephDeviceSetLabelKey]
|
||||
setIndex := labels[osd.CephSetIndexLabelKey]
|
||||
deviceSet := labels[oposd.CephDeviceSetLabelKey]
|
||||
setIndex := labels[oposd.CephSetIndexLabelKey]
|
||||
|
||||
labelSelector := fmt.Sprintf("%s=%s,%s=%s", osd.CephDeviceSetLabelKey, deviceSet, osd.CephSetIndexLabelKey, setIndex)
|
||||
labelSelector := fmt.Sprintf("%s=%s,%s=%s", oposd.CephDeviceSetLabelKey, deviceSet, oposd.CephSetIndexLabelKey, setIndex)
|
||||
listOptions := metav1.ListOptions{LabelSelector: labelSelector}
|
||||
pvcs, err := clusterdContext.Clientset.CoreV1().PersistentVolumeClaims(clusterInfo.Namespace).List(clusterInfo.Context, listOptions)
|
||||
if err != nil {
|
||||
@@ -204,10 +203,10 @@ func removePVCs(clusterdContext *clusterd.Context, clusterInfo *client.ClusterIn
|
||||
if preservePVC {
|
||||
// Detach the OSD PVC from Rook. We will continue OSD deletion even if failed to remove PVC label
|
||||
logger.Infof("detach the OSD PVC %q from Rook", pvc.Name)
|
||||
delete(labels, osd.CephDeviceSetPVCIDLabelKey)
|
||||
delete(labels, oposd.CephDeviceSetPVCIDLabelKey)
|
||||
pvc.SetLabels(labels)
|
||||
if _, err := clusterdContext.Clientset.CoreV1().PersistentVolumeClaims(clusterInfo.Namespace).Update(clusterInfo.Context, &pvcs.Items[i], metav1.UpdateOptions{}); err != nil {
|
||||
logger.Errorf("failed to remove label %q from pvc for OSD %q. %v", osd.CephDeviceSetPVCIDLabelKey, pvc.Name, err)
|
||||
logger.Errorf("failed to remove label %q from pvc for OSD %q. %v", oposd.CephDeviceSetPVCIDLabelKey, pvc.Name, err)
|
||||
}
|
||||
} else {
|
||||
// Remove the OSD PVC
|
||||
@@ -249,7 +248,7 @@ func archiveCrash(clusterdContext *clusterd.Context, clusterInfo *client.Cluster
|
||||
}
|
||||
|
||||
// DestroyOSD fetches the OSD to be replaced based on the ID and then destroys that OSD and zaps the backing device
|
||||
func DestroyOSD(context *clusterd.Context, clusterInfo *client.ClusterInfo, id int, isPVC, isEncrypted bool) (*osd.OSDReplaceInfo, error) {
|
||||
func DestroyOSD(context *clusterd.Context, clusterInfo *client.ClusterInfo, id int, isPVC, isEncrypted bool) (*oposd.OSDReplaceInfo, error) {
|
||||
var block string
|
||||
osdInfo, err := GetOSDInfoById(context, clusterInfo, id)
|
||||
if err != nil {
|
||||
@@ -293,5 +292,5 @@ func DestroyOSD(context *clusterd.Context, clusterInfo *client.ClusterInfo, id i
|
||||
logger.Infof("%s\n", output)
|
||||
logger.Infof("successfully zapped osd.%d path %q", osdInfo.ID, block)
|
||||
|
||||
return &osd.OSDReplaceInfo{ID: osdInfo.ID, Path: block}, nil
|
||||
return &oposd.OSDReplaceInfo{ID: osdInfo.ID, Path: block}, nil
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
@@ -1192,7 +1191,7 @@ func TestInitializeBlockPVC(t *testing.T) {
|
||||
assert.Equal(t, "", walBlockPath)
|
||||
|
||||
// Test for condition when osd is prepared with existing osd ID
|
||||
a = &OsdAgent{clusterInfo: clusterInfo, nodeName: "node1", storeConfig: config.StoreConfig{StoreType: "bluestore"}, replaceOSD: &osd.OSDReplaceInfo{ID: 3, Path: "/dev/sda"}}
|
||||
a = &OsdAgent{clusterInfo: clusterInfo, nodeName: "node1", storeConfig: config.StoreConfig{StoreType: "bluestore"}, replaceOSD: &oposd.OSDReplaceInfo{ID: 3, Path: "/dev/sda"}}
|
||||
devices = &DeviceOsdMapping{
|
||||
Entries: map[string]*DeviceOsdIDEntry{
|
||||
"data": {Data: -1, Metadata: nil, Config: DesiredDevice{Name: "/mnt/set1-data-0-rpf2k"}, DeviceInfo: &sys.LocalDisk{RealPath: "/dev/sda"}},
|
||||
@@ -1213,7 +1212,7 @@ func TestInitializeBlockPVC(t *testing.T) {
|
||||
assert.Equal(t, "", walBlockPath)
|
||||
|
||||
// Test for condition that --osd-id is not passed for the devices that don't match the OSD to be replaced.
|
||||
a = &OsdAgent{clusterInfo: clusterInfo, nodeName: "node1", storeConfig: config.StoreConfig{StoreType: "bluestore"}, replaceOSD: &osd.OSDReplaceInfo{ID: 3, Path: "/dev/sda"}}
|
||||
a = &OsdAgent{clusterInfo: clusterInfo, nodeName: "node1", storeConfig: config.StoreConfig{StoreType: "bluestore"}, replaceOSD: &oposd.OSDReplaceInfo{ID: 3, Path: "/dev/sda"}}
|
||||
devices = &DeviceOsdMapping{
|
||||
Entries: map[string]*DeviceOsdIDEntry{
|
||||
"data": {Data: -1, Metadata: nil, Config: DesiredDevice{Name: "/mnt/set1-data-0-rpf2k"}, DeviceInfo: &sys.LocalDisk{RealPath: "/dev/sdb"}},
|
||||
|
||||
@@ -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"
|
||||
"github.com/rook/rook/pkg/operator/ceph/version"
|
||||
testopk8s "github.com/rook/rook/pkg/operator/k8sutil/test"
|
||||
@@ -241,7 +240,7 @@ func TestTrackMonsOutOfQuorum(t *testing.T) {
|
||||
|
||||
cm, err := clientset.CoreV1().ConfigMaps(c.Namespace).Get(context.TODO(), EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "a", cm.Data[controller.OutOfQuorumKey])
|
||||
assert.Equal(t, "a", cm.Data[opcontroller.OutOfQuorumKey])
|
||||
|
||||
// Put mon.a back in quorum
|
||||
updated, err = c.trackMonInOrOutOfQuorum("a", true)
|
||||
@@ -250,7 +249,7 @@ func TestTrackMonsOutOfQuorum(t *testing.T) {
|
||||
|
||||
cm, err = clientset.CoreV1().ConfigMaps(c.Namespace).Get(context.TODO(), EndpointConfigMapName, metav1.GetOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", cm.Data[controller.OutOfQuorumKey])
|
||||
assert.Equal(t, "", cm.Data[opcontroller.OutOfQuorumKey])
|
||||
}
|
||||
|
||||
func TestSkipMonFailover(t *testing.T) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
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"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
@@ -172,7 +171,7 @@ func getCephExporterDaemonContainer(cephCluster cephv1.CephCluster, cephVersion
|
||||
|
||||
envVars := append(
|
||||
controller.DaemonEnvVars(&cephCluster.Spec),
|
||||
v1.EnvVar{Name: "CEPH_ARGS", Value: fmt.Sprintf("-m $(ROOK_CEPH_MON_HOST) -k %s", keyring.VolumeMount().AdminKeyringFilePath())})
|
||||
corev1.EnvVar{Name: "CEPH_ARGS", Value: fmt.Sprintf("-m $(ROOK_CEPH_MON_HOST) -k %s", keyring.VolumeMount().AdminKeyringFilePath())})
|
||||
|
||||
args := []string{
|
||||
"--sock-dir", sockDir,
|
||||
@@ -202,22 +201,22 @@ func getCephExporterDaemonContainer(cephCluster cephv1.CephCluster, cephVersion
|
||||
}
|
||||
|
||||
// MakeCephExporterMetricsService generates the Kubernetes service object for the exporter monitoring service
|
||||
func MakeCephExporterMetricsService(cephCluster cephv1.CephCluster, servicePortMetricName string, scheme *runtime.Scheme) (*v1.Service, error) {
|
||||
func MakeCephExporterMetricsService(cephCluster cephv1.CephCluster, servicePortMetricName string, scheme *runtime.Scheme) (*corev1.Service, error) {
|
||||
labels := controller.AppLabels(cephExporterAppName, cephCluster.Namespace)
|
||||
|
||||
svc := &v1.Service{
|
||||
svc := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: cephExporterAppName,
|
||||
Namespace: cephCluster.Namespace,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
Ports: []v1.ServicePort{
|
||||
Spec: corev1.ServiceSpec{
|
||||
Type: corev1.ServiceTypeClusterIP,
|
||||
Ports: []corev1.ServicePort{
|
||||
{
|
||||
Name: servicePortMetricName,
|
||||
Port: int32(DefaultMetricsPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
Selector: labels,
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
"k8s.io/api/batch/v1beta1"
|
||||
corev1 "k8s.io/api/core/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/util/version"
|
||||
@@ -160,9 +159,9 @@ func (r *ReconcileNode) createOrUpdateCephCron(cephCluster cephv1.CephCluster, c
|
||||
func (r *ReconcileNode) deletev1betaJob(objectMeta metav1.ObjectMeta) {
|
||||
// delete v1beta1 cronJob on an update to v1 job,only if v1 job is not created yet
|
||||
if _, err := r.context.Clientset.BatchV1().CronJobs(objectMeta.Namespace).Get(r.opManagerContext, prunerName, metav1.GetOptions{}); err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
if kerrors.IsNotFound(err) {
|
||||
err = r.client.Delete(r.opManagerContext, &v1beta1.CronJob{ObjectMeta: objectMeta})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
if err != nil && !kerrors.IsNotFound(err) {
|
||||
logger.Debugf("could not delete CronJob v1Beta1 %q. %v", prunerName, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,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"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
osdconfig "github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd/topology"
|
||||
@@ -888,7 +887,7 @@ func (c *Cluster) updateCephStorageStatus() error {
|
||||
cephCluster := cephv1.CephCluster{}
|
||||
cephClusterStorage := cephv1.CephStorage{}
|
||||
|
||||
deviceClasses, err := client.GetDeviceClasses(c.context, c.clusterInfo)
|
||||
deviceClasses, err := cephclient.GetDeviceClasses(c.context, c.clusterInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get osd device classes")
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
fakeclient "github.com/rook/rook/pkg/client/clientset/versioned/fake"
|
||||
"github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclientfake "github.com/rook/rook/pkg/daemon/ceph/client/fake"
|
||||
discoverDaemon "github.com/rook/rook/pkg/daemon/discover"
|
||||
@@ -35,7 +34,6 @@ import (
|
||||
opconfig "github.com/rook/rook/pkg/operator/ceph/config"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/operator/test"
|
||||
testexec "github.com/rook/rook/pkg/operator/test"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -177,7 +175,7 @@ func TestAddRemoveNode(t *testing.T) {
|
||||
clientset := fake.NewSimpleClientset()
|
||||
t.Setenv(k8sutil.PodNamespaceEnvVar, "rook-system")
|
||||
|
||||
test.AddReadyNode(t, clientset, nodeName, "23.23.23.23")
|
||||
testexec.AddReadyNode(t, clientset, nodeName, "23.23.23.23")
|
||||
cmErr := createDiscoverConfigmap(nodeName, "rook-system", clientset)
|
||||
assert.Nil(t, cmErr)
|
||||
|
||||
@@ -872,7 +870,7 @@ func TestReplaceOSDForNewStore(t *testing.T) {
|
||||
|
||||
func TestUpdateCephStorageStatus(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
clusterInfo := client.AdminTestClusterInfo("fake")
|
||||
clusterInfo := cephclient.AdminTestClusterInfo("fake")
|
||||
executor := &exectest.MockExecutor{
|
||||
MockExecuteCommandWithOutput: func(command string, args ...string) (string, error) {
|
||||
logger.Infof("ExecuteCommandWithOutputFile: %s %v", command, args)
|
||||
|
||||
@@ -34,7 +34,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -72,7 +71,7 @@ func checkStorageForNode(cluster *cephv1.CephCluster) bool {
|
||||
|
||||
// onK8sNodeAdd is triggered when a node is added in the Kubernetes cluster
|
||||
func (c *clientCluster) onK8sNode(ctx context.Context, object runtime.Object) bool {
|
||||
node, ok := object.(*v1.Node)
|
||||
node, ok := object.(*corev1.Node)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
@@ -91,7 +90,7 @@ func (c *clientCluster) onK8sNode(ctx context.Context, object runtime.Object) bo
|
||||
}
|
||||
|
||||
if !k8sutil.GetNodeSchedulable(*node) {
|
||||
logger.Debugf("node watcher: skipping cluster update. added node %q is unschedulable", node.Labels[v1.LabelHostname])
|
||||
logger.Debugf("node watcher: skipping cluster update. added node %q is unschedulable", node.Labels[corev1.LabelHostname])
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -116,7 +115,7 @@ func (c *clientCluster) onK8sNode(ctx context.Context, object runtime.Object) bo
|
||||
err := k8sutil.ValidNode(*node, cephv1.GetOSDPlacement(cluster.Spec.Placement))
|
||||
if err == nil {
|
||||
nodeName := node.Name
|
||||
hostname, ok := node.Labels[v1.LabelHostname]
|
||||
hostname, ok := node.Labels[corev1.LabelHostname]
|
||||
if ok && hostname != "" {
|
||||
nodeName = hostname
|
||||
}
|
||||
@@ -138,7 +137,7 @@ func (c *clientCluster) onK8sNode(ctx context.Context, object runtime.Object) bo
|
||||
|
||||
// Reconcile if there are no OSDs in the CRUSH map and if the host does not exist in the CRUSH map.
|
||||
if osds == "" {
|
||||
logger.Infof("node watcher: adding node %q to cluster %q", node.Labels[v1.LabelHostname], cluster.Namespace)
|
||||
logger.Infof("node watcher: adding node %q to cluster %q", node.Labels[corev1.LabelHostname], cluster.Namespace)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -148,7 +147,7 @@ func (c *clientCluster) onK8sNode(ctx context.Context, object runtime.Object) bo
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *clientCluster) handleNodeFailure(ctx context.Context, cluster *cephv1.CephCluster, node *v1.Node) error {
|
||||
func (c *clientCluster) handleNodeFailure(ctx context.Context, cluster *cephv1.CephCluster, node *corev1.Node) error {
|
||||
watchForNodeLoss, err := k8sutil.GetOperatorSetting(ctx, c.context.Clientset, opcontroller.OperatorSettingConfigMapName, "ROOK_WATCH_FOR_NODE_FAILURE", "true")
|
||||
if err != nil {
|
||||
return pkgerror.Wrapf(err, "failed to get configmap value `ROOK_WATCH_FOR_NODE_FAILURE`.")
|
||||
@@ -170,7 +169,7 @@ func (c *clientCluster) handleNodeFailure(ctx context.Context, cluster *cephv1.C
|
||||
|
||||
nodeHasOutOfServiceTaint := false
|
||||
for _, taint := range node.Spec.Taints {
|
||||
if taint.Key == v1.TaintNodeOutOfService {
|
||||
if taint.Key == corev1.TaintNodeOutOfService {
|
||||
nodeHasOutOfServiceTaint = true
|
||||
logger.Infof("Found taint: Key=%v, Value=%v on node %s\n", taint.Key, taint.Value, node.Name)
|
||||
break
|
||||
@@ -238,7 +237,7 @@ func (c *clientCluster) fenceNode(ctx context.Context, node *corev1.Node, cluste
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCephVolumesInUse(cluster *cephv1.CephCluster, volumesInUse []v1.UniqueVolumeName) []string {
|
||||
func getCephVolumesInUse(cluster *cephv1.CephCluster, volumesInUse []corev1.UniqueVolumeName) []string {
|
||||
var rbdVolumesInUse []string
|
||||
|
||||
for _, volume := range volumesInUse {
|
||||
@@ -252,7 +251,7 @@ func getCephVolumesInUse(cluster *cephv1.CephCluster, volumesInUse []v1.UniqueVo
|
||||
return rbdVolumesInUse
|
||||
}
|
||||
|
||||
func trimeVolumeInUse(volume v1.UniqueVolumeName) []string {
|
||||
func trimeVolumeInUse(volume corev1.UniqueVolumeName) []string {
|
||||
volumesInuseRemoveK8sPrefix := strings.TrimPrefix(string(volume), "kubernetes.io/csi/")
|
||||
splitVolumeInUseBased := strings.Split(volumesInuseRemoveK8sPrefix, "^")
|
||||
return splitVolumeInUseBased
|
||||
@@ -410,7 +409,7 @@ func (c *clientCluster) unfenceAndDeleteNetworkFence(ctx context.Context, node c
|
||||
} else if errors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
logger.Infof("node %s does not have taint %s, unfencing networkFence CR", node.Name, v1.TaintNodeOutOfService)
|
||||
logger.Infof("node %s does not have taint %s, unfencing networkFence CR", node.Name, corev1.TaintNodeOutOfService)
|
||||
|
||||
// Unfencing is required to unblock the node and then delete the network fence CR
|
||||
networkFence.Spec.FenceState = addonsv1alpha1.Unfenced
|
||||
@@ -449,13 +448,13 @@ func (c *clientCluster) unfenceAndDeleteNetworkFence(ctx context.Context, node c
|
||||
|
||||
// onDeviceCMUpdate is trigger when the hot plug config map is updated
|
||||
func (c *clientCluster) onDeviceCMUpdate(oldObj, newObj runtime.Object) bool {
|
||||
oldCm, ok := oldObj.(*v1.ConfigMap)
|
||||
oldCm, ok := oldObj.(*corev1.ConfigMap)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
logger.Debugf("hot-plug cm watcher: onDeviceCMUpdate old device cm: %+v", oldCm)
|
||||
|
||||
newCm, ok := newObj.(*v1.ConfigMap)
|
||||
newCm, ok := newObj.(*corev1.ConfigMap)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil/cmdreporter"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const detectNetworkCIDRTimeout = 15 * time.Minute
|
||||
@@ -338,9 +337,9 @@ func networkStatusVolumeAndMount() (corev1.Volume, corev1.VolumeMount) {
|
||||
Name: "network-status",
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
DownwardAPI: &corev1.DownwardAPIVolumeSource{
|
||||
Items: []v1.DownwardAPIVolumeFile{{
|
||||
Items: []corev1.DownwardAPIVolumeFile{{
|
||||
Path: "network-status",
|
||||
FieldRef: &v1.ObjectFieldSelector{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: `metadata.annotations['` + nadv1.NetworkStatusAnnot + `']`,
|
||||
}}}}}}
|
||||
mnt := corev1.VolumeMount{
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@@ -108,10 +107,10 @@ func MonEndpoints(mons map[string]*cephclient.MonInfo, requireMsgr2 bool) []stri
|
||||
endpoint := m.Endpoint
|
||||
if requireMsgr2 {
|
||||
logger.Debugf("evaluating mon %q for msgr1 on endpoint %q", m.Name, m.Endpoint)
|
||||
msgr1Suffix := fmt.Sprintf(":%d", client.Msgr1port)
|
||||
msgr1Suffix := fmt.Sprintf(":%d", cephclient.Msgr1port)
|
||||
if strings.HasSuffix(m.Endpoint, msgr1Suffix) {
|
||||
address := m.Endpoint[0:strings.LastIndex(m.Endpoint, msgr1Suffix)]
|
||||
endpoint = fmt.Sprintf("%s:%d", address, client.Msgr2port)
|
||||
endpoint = fmt.Sprintf("%s:%d", address, cephclient.Msgr2port)
|
||||
logger.Debugf("mon %q will use the msgrv2 port: %q", m.Name, endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
k8scsi "k8s.io/api/storage/v1beta1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -145,7 +144,7 @@ var (
|
||||
DefaultCSIAddonsImage = "quay.io/csiaddons/k8s-sidecar:v0.7.0"
|
||||
|
||||
// image pull policy
|
||||
DefaultCSIImagePullPolicy = string(v1.PullIfNotPresent)
|
||||
DefaultCSIImagePullPolicy = string(corev1.PullIfNotPresent)
|
||||
|
||||
// Local package template path for RBD
|
||||
//go:embed template/rbd/csi-rbdplugin.yaml
|
||||
@@ -742,7 +741,7 @@ func (r *ReconcileCSI) validateCSIVersion(ownerInfo *k8sutil.OwnerInfo) (*CephCS
|
||||
[]string{"--version"},
|
||||
r.opConfig.Image,
|
||||
CSIParam.CSIPluginImage,
|
||||
v1.PullPolicy(CSIParam.ImagePullPolicy),
|
||||
corev1.PullPolicy(CSIParam.ImagePullPolicy),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookclient "github.com/rook/rook/pkg/client/clientset/versioned/fake"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
@@ -76,7 +75,7 @@ func TestReconcileCSI_configureHolders(t *testing.T) {
|
||||
},
|
||||
clusterInfo: &cephclient.ClusterInfo{
|
||||
Monitors: map[string]*cephclient.MonInfo{"a": {Name: "a", Endpoint: "10.0.0.1:6789"}},
|
||||
OwnerInfo: client.NewMinimumOwnerInfoWithOwnerRef()},
|
||||
OwnerInfo: cephclient.NewMinimumOwnerInfoWithOwnerRef()},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func TestDaemonSetTemplate(t *testing.T) {
|
||||
@@ -157,7 +156,7 @@ func Test_applyVolumeToPodSpec(t *testing.T) {
|
||||
assert.Len(t, ds.Spec.Template.Spec.Volumes, defaultVolumes+2)
|
||||
// override existing volume configuration
|
||||
volumes[1].VolumeSource = corev1.VolumeSource{
|
||||
HostPath: &v1.HostPathVolumeSource{Path: "/run/test/run"}}
|
||||
HostPath: &corev1.HostPathVolumeSource{Path: "/run/test/run"}}
|
||||
volumeRaw, err = yaml.Marshal(volumes)
|
||||
assert.Nil(t, err)
|
||||
config[configKey] = string(volumeRaw)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
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"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/util"
|
||||
"github.com/rook/rook/pkg/util/dependents"
|
||||
@@ -54,7 +53,7 @@ var ignoredDependentSubvolumeGroups = []string{"_nogroup", "_index", "_legacy",
|
||||
var CephFilesystemDependents = cephFilesystemDependents
|
||||
|
||||
// check filesystem whether it exists
|
||||
func filesystemExists(clusterdCtx *clusterd.Context, clusterInfo *client.ClusterInfo, name, nsName string) (bool, error) {
|
||||
func filesystemExists(clusterdCtx *clusterd.Context, clusterInfo *cephclient.ClusterInfo, name, nsName string) (bool, error) {
|
||||
_, err := cephclient.GetFilesystem(clusterdCtx, clusterInfo, name)
|
||||
if err != nil {
|
||||
if code, ok := kexec.ExitStatus(err); ok && code == int(syscall.ENOENT) {
|
||||
@@ -67,7 +66,7 @@ func filesystemExists(clusterdCtx *clusterd.Context, clusterInfo *client.Cluster
|
||||
}
|
||||
|
||||
// with above, allow this to be overridden for unit testing
|
||||
func cephFilesystemDependents(clusterdCtx *clusterd.Context, clusterInfo *client.ClusterInfo, filesystem *v1.CephFilesystem) (*dependents.DependentList, error) {
|
||||
func cephFilesystemDependents(clusterdCtx *clusterd.Context, clusterInfo *cephclient.ClusterInfo, filesystem *v1.CephFilesystem) (*dependents.DependentList, error) {
|
||||
nsName := fmt.Sprintf("%s/%s", filesystem.Namespace, filesystem.Name)
|
||||
baseErrMsg := fmt.Sprintf("failed to get dependents of CephFilesystem %q", nsName)
|
||||
|
||||
@@ -101,18 +100,18 @@ func cephFilesystemDependents(clusterdCtx *clusterd.Context, clusterInfo *client
|
||||
}
|
||||
|
||||
// return subvolume groups that have 1 or more subvolumes present in them
|
||||
func subvolumeGroupDependents(clusterdCtx *clusterd.Context, clusterInfo *client.ClusterInfo, filesystem *v1.CephFilesystem) (*dependents.DependentList, error) {
|
||||
func subvolumeGroupDependents(clusterdCtx *clusterd.Context, clusterInfo *cephclient.ClusterInfo, filesystem *v1.CephFilesystem) (*dependents.DependentList, error) {
|
||||
baseErr := "failed to get Ceph subvolume groups containing subvolumes"
|
||||
|
||||
deps := dependents.NewDependentList()
|
||||
|
||||
svgs, err := client.ListSubvolumeGroups(clusterdCtx, clusterInfo, filesystem.Name)
|
||||
svgs, err := cephclient.ListSubvolumeGroups(clusterdCtx, clusterInfo, filesystem.Name)
|
||||
if err != nil {
|
||||
return deps, errors.Wrap(err, baseErr)
|
||||
}
|
||||
|
||||
// also check the case where subvolumes are not in a group
|
||||
svgs = append(svgs, client.SubvolumeGroup{Name: client.NoSubvolumeGroup})
|
||||
svgs = append(svgs, cephclient.SubvolumeGroup{Name: cephclient.NoSubvolumeGroup})
|
||||
|
||||
errs := []error{}
|
||||
for _, svg := range svgs {
|
||||
@@ -120,14 +119,14 @@ func subvolumeGroupDependents(clusterdCtx *clusterd.Context, clusterInfo *client
|
||||
continue
|
||||
}
|
||||
|
||||
svs, err := client.ListSubvolumesInGroup(clusterdCtx, clusterInfo, filesystem.Name, svg.Name)
|
||||
svs, err := cephclient.ListSubvolumesInGroup(clusterdCtx, clusterInfo, filesystem.Name, svg.Name)
|
||||
if err != nil {
|
||||
errs = append(errs, errors.Wrapf(err, "failed to list subvolumes in subvolume group %q", svg.Name))
|
||||
}
|
||||
|
||||
if len(svs) > 0 {
|
||||
name := svg.Name
|
||||
if name == client.NoSubvolumeGroup {
|
||||
if name == cephclient.NoSubvolumeGroup {
|
||||
// identify the "no group" case clearly for users
|
||||
name = noGroupDependentName
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"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"
|
||||
apibkt "github.com/kube-object-storage/lib-bucket-provisioner/pkg/provisioner/api"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
@@ -63,7 +62,7 @@ func NewProvisioner(context *clusterd.Context, clusterInfo *client.ClusterInfo)
|
||||
return &Provisioner{context: context, clusterInfo: clusterInfo}
|
||||
}
|
||||
|
||||
func (p Provisioner) GenerateUserID(obc *v1alpha1.ObjectBucketClaim, ob *v1alpha1.ObjectBucket) (string, error) {
|
||||
func (p Provisioner) GenerateUserID(obc *bktv1alpha1.ObjectBucketClaim, ob *bktv1alpha1.ObjectBucket) (string, error) {
|
||||
if ob != nil {
|
||||
return getCephUser(ob), nil
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"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"
|
||||
"github.com/kube-object-storage/lib-bucket-provisioner/pkg/provisioner"
|
||||
"github.com/pkg/errors"
|
||||
@@ -93,7 +92,7 @@ func MaxSizeQuota(AdditionalConfig map[string]string) string {
|
||||
return AdditionalConfig["maxSize"]
|
||||
}
|
||||
|
||||
func GetObjectStoreNameFromBucket(ob *v1alpha1.ObjectBucket) (types.NamespacedName, error) {
|
||||
func GetObjectStoreNameFromBucket(ob *bktv1alpha1.ObjectBucket) (types.NamespacedName, error) {
|
||||
// Rook v1.11 OBCs have additional state labels that tell the object store namespace and name.
|
||||
// This is critical for CephObjectStores in external mode that connect to RGW endpoints directly
|
||||
// which don't have a deterministic domain structure.
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
rookclient "github.com/rook/rook/pkg/client/clientset/versioned/fake"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
@@ -226,7 +225,7 @@ func TestCephObjectStoreDependents(t *testing.T) {
|
||||
logger.Infof("Command: %s %v", command, args)
|
||||
if args[0] == "osd" {
|
||||
if args[1] == "lspools" {
|
||||
pools := []*client.CephStoragePoolSummary{}
|
||||
pools := []*cephclient.CephStoragePoolSummary{}
|
||||
output, err := json.Marshal(pools)
|
||||
assert.Nil(t, err)
|
||||
return string(output), nil
|
||||
@@ -243,7 +242,7 @@ func TestCephObjectStoreDependents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
pools := []*client.CephStoragePoolSummary{
|
||||
pools := []*cephclient.CephStoragePoolSummary{
|
||||
{Name: "my-store.rgw.control"},
|
||||
{Name: "my-store.rgw.meta"},
|
||||
{Name: "my-store.rgw.log"},
|
||||
@@ -253,7 +252,7 @@ func TestCephObjectStoreDependents(t *testing.T) {
|
||||
{Name: "my-store.rgw.buckets.index"},
|
||||
{Name: "my-store.rgw.otp"},
|
||||
}
|
||||
zoneBPools := []*client.CephStoragePoolSummary{
|
||||
zoneBPools := []*cephclient.CephStoragePoolSummary{
|
||||
{Name: "zone-b.rgw.control"},
|
||||
{Name: "zone-b.rgw.meta"},
|
||||
{Name: "zone-b.rgw.log"},
|
||||
@@ -263,7 +262,7 @@ func TestCephObjectStoreDependents(t *testing.T) {
|
||||
{Name: "zone-b.rgw.buckets.index"},
|
||||
{Name: "zone-b.rgw.otp"},
|
||||
}
|
||||
zoneAPools := []*client.CephStoragePoolSummary{
|
||||
zoneAPools := []*cephclient.CephStoragePoolSummary{
|
||||
{Name: "zone-a.rgw.control"},
|
||||
{Name: "zone-a.rgw.meta"},
|
||||
{Name: "zone-a.rgw.log"},
|
||||
@@ -291,7 +290,7 @@ func TestCephObjectStoreDependents(t *testing.T) {
|
||||
setMultisiteContext := func(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, store *cephv1.CephObjectStore) *Context {
|
||||
return &Context{Context: context, Name: store.Name, clusterInfo: clusterInfo, Realm: "realm-a", ZoneGroup: "zonegroup-a", Zone: store.Spec.Zone.Name}
|
||||
}
|
||||
clusterInfo := client.AdminTestClusterInfo(ns)
|
||||
clusterInfo := cephclient.AdminTestClusterInfo(ns)
|
||||
// Create objectmeta with the given name in our test namespace
|
||||
meta := func(name string) v1.ObjectMeta {
|
||||
return v1.ObjectMeta{
|
||||
|
||||
@@ -43,7 +43,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/object"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
@@ -208,7 +207,7 @@ func (r *ReconcileObjectStoreUser) reconcile(request reconcile.Request) (reconci
|
||||
if err != nil {
|
||||
return reconcile.Result{}, *cephObjectStoreUser, errors.Wrap(err, "failed to remove finalizer")
|
||||
}
|
||||
r.recorder.Event(cephObjectStoreUser, v1.EventTypeNormal, string(cephv1.ReconcileSucceeded), "successfully removed finalizer")
|
||||
r.recorder.Event(cephObjectStoreUser, corev1.EventTypeNormal, string(cephv1.ReconcileSucceeded), "successfully removed finalizer")
|
||||
|
||||
// Return and do not requeue. Successful deletion.
|
||||
return reconcile.Result{}, *cephObjectStoreUser, nil
|
||||
@@ -226,7 +225,7 @@ func (r *ReconcileObjectStoreUser) reconcile(request reconcile.Request) (reconci
|
||||
// DELETE: the CR was deleted
|
||||
if !cephObjectStoreUser.GetDeletionTimestamp().IsZero() {
|
||||
logger.Debugf("deleting object store user %q", request.NamespacedName)
|
||||
r.recorder.Eventf(cephObjectStoreUser, v1.EventTypeNormal, string(cephv1.ReconcileStarted), "deleting CephObjectStoreUser %q", cephObjectStoreUser.Name)
|
||||
r.recorder.Eventf(cephObjectStoreUser, corev1.EventTypeNormal, string(cephv1.ReconcileStarted), "deleting CephObjectStoreUser %q", cephObjectStoreUser.Name)
|
||||
|
||||
err := r.deleteUser(cephObjectStoreUser)
|
||||
if err != nil {
|
||||
@@ -238,7 +237,7 @@ func (r *ReconcileObjectStoreUser) reconcile(request reconcile.Request) (reconci
|
||||
if err != nil {
|
||||
return reconcile.Result{}, *cephObjectStoreUser, errors.Wrap(err, "failed to remove finalizer")
|
||||
}
|
||||
r.recorder.Event(cephObjectStoreUser, v1.EventTypeNormal, string(cephv1.ReconcileSucceeded), "successfully removed finalizer")
|
||||
r.recorder.Event(cephObjectStoreUser, corev1.EventTypeNormal, string(cephv1.ReconcileSucceeded), "successfully removed finalizer")
|
||||
|
||||
// Return and do not requeue. Successful deletion.
|
||||
return reconcile.Result{}, *cephObjectStoreUser, nil
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
exectest "github.com/rook/rook/pkg/util/exec/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -82,7 +81,7 @@ func TestCephObjectZoneDependentStores(t *testing.T) {
|
||||
})
|
||||
t.Run("one objectstores exists", func(t *testing.T) {
|
||||
c = newClusterdCtx(executor)
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreA, v1.CreateOptions{})
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreA, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
deps, err := CephObjectZoneDependentStores(c, clusterInfo, objectZoneA, object.NewContext(c, clusterInfo, objectZoneA.Name))
|
||||
assert.NoError(t, err)
|
||||
@@ -91,7 +90,7 @@ func TestCephObjectZoneDependentStores(t *testing.T) {
|
||||
})
|
||||
t.Run("objectstore exists for different zone", func(t *testing.T) {
|
||||
c = newClusterdCtx(executor)
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreB, v1.CreateOptions{})
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreB, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
deps, err := CephObjectZoneDependentStores(c, clusterInfo, objectZoneA, object.NewContext(c, clusterInfo, objectZoneA.Name))
|
||||
assert.NoError(t, err)
|
||||
@@ -99,10 +98,10 @@ func TestCephObjectZoneDependentStores(t *testing.T) {
|
||||
})
|
||||
t.Run("multipleobjectstore exists for zone", func(t *testing.T) {
|
||||
c = newClusterdCtx(executor)
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreA, v1.CreateOptions{})
|
||||
_, err := c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreA, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
objectStoreB.Spec.Zone.Name = "zone-a"
|
||||
_, err = c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreB, v1.CreateOptions{})
|
||||
_, err = c.RookClientset.CephV1().CephObjectStores(clusterInfo.Namespace).Create(context.TODO(), objectStoreB, metav1.CreateOptions{})
|
||||
assert.NoError(t, err)
|
||||
deps, err := CephObjectZoneDependentStores(c, clusterInfo, objectZoneA, object.NewContext(c, clusterInfo, objectZoneA.Name))
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/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/client-go/kubernetes"
|
||||
@@ -78,7 +77,7 @@ func GetOperatorSetting(context context.Context, clientset kubernetes.Interface,
|
||||
namespace := os.Getenv(PodNamespaceEnvVar)
|
||||
cm, err := clientset.CoreV1().ConfigMaps(namespace).Get(context, configMapName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
if kerrors.IsNotFound(err) {
|
||||
if settingValue, ok := os.LookupEnv(settingName); ok {
|
||||
logger.Infof("%s=%q (env var)", settingName, settingValue)
|
||||
return settingValue, nil
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
monitoringclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
kerror "k8s.io/apimachinery/pkg/api/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
@@ -114,7 +113,7 @@ func DeleteServiceMonitor(context *clusterd.Context, ctx context.Context, ns str
|
||||
}
|
||||
err = client.MonitoringV1().ServiceMonitors(ns).Delete(ctx, name, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
if kerror.IsNotFound(err) {
|
||||
if kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "failed to delete service monitor %q", name)
|
||||
|
||||
@@ -24,9 +24,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
kerror "k8s.io/apimachinery/pkg/api/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
@@ -43,7 +41,7 @@ func CreateOrUpdateService(
|
||||
|
||||
s, err := clientset.CoreV1().Services(namespace).Create(ctx, serviceDefinition, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
if !kerror.IsAlreadyExists(err) {
|
||||
if !kerrors.IsAlreadyExists(err) {
|
||||
return nil, fmt.Errorf("failed to create service %s. %+v", name, err)
|
||||
}
|
||||
s, err = UpdateService(ctx, clientset, namespace, serviceDefinition)
|
||||
@@ -78,7 +76,7 @@ func UpdateService(
|
||||
func DeleteService(ctx context.Context, clientset kubernetes.Interface, namespace, name string) error {
|
||||
err := clientset.CoreV1().Services(namespace).Delete(ctx, name, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
if kerror.IsNotFound(err) {
|
||||
if kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -166,7 +164,7 @@ func verifyExportedService(ctx context.Context, client *mcsv1Client.Clientset, n
|
||||
}
|
||||
|
||||
for _, condition := range exportedService.Status.Conditions {
|
||||
if condition.Type == mcsv1a1.ServiceExportValid && condition.Status == corev1.ConditionFalse {
|
||||
if condition.Type == mcsv1a1.ServiceExportValid && condition.Status == v1.ConditionFalse {
|
||||
return fmt.Errorf(*condition.Message)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user