From ab166742c5329dcc51502905bc0b67fa4950b7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 2 Sep 2021 11:25:33 +0200 Subject: [PATCH 1/2] ceph: avoid double reconcile with default value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting a default values with kubebuilder flags it seems that the kube operator intercepts the API call, mutate the CR and inject it. This results in two events, one for creation and one for edition and we end up with 2 reconciles. Let's avoid this. Signed-off-by: Sébastien Han --- cluster/charts/rook-ceph/templates/resources.yaml | 1 - cluster/examples/kubernetes/ceph/crds.yaml | 1 - pkg/apis/ceph.rook.io/v1/types.go | 1 - 3 files changed, 3 deletions(-) diff --git a/cluster/charts/rook-ceph/templates/resources.yaml b/cluster/charts/rook-ceph/templates/resources.yaml index a0148a7bf..74c8554f8 100644 --- a/cluster/charts/rook-ceph/templates/resources.yaml +++ b/cluster/charts/rook-ceph/templates/resources.yaml @@ -1244,7 +1244,6 @@ spec: description: HostNetwork to enable host network type: boolean ipFamily: - default: IPv4 description: IPFamily is the single stack IPv6 or IPv4 protocol enum: - IPv4 diff --git a/cluster/examples/kubernetes/ceph/crds.yaml b/cluster/examples/kubernetes/ceph/crds.yaml index 303d8a1c6..e7b1f64fa 100644 --- a/cluster/examples/kubernetes/ceph/crds.yaml +++ b/cluster/examples/kubernetes/ceph/crds.yaml @@ -1244,7 +1244,6 @@ spec: description: HostNetwork to enable host network type: boolean ipFamily: - default: IPv4 description: IPFamily is the single stack IPv6 or IPv4 protocol enum: - IPv4 diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 5685a4c74..3059f2d10 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -1644,7 +1644,6 @@ type NetworkSpec struct { // IPFamily is the single stack IPv6 or IPv4 protocol // +kubebuilder:validation:Enum=IPv4;IPv6 - // +kubebuilder:default=IPv4 // +nullable // +optional IPFamily IPFamilyType `json:"ipFamily,omitempty"` From 072c8f43df42934208c104c6165895e0ac6cd812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 2 Sep 2021 11:28:02 +0200 Subject: [PATCH 2/2] ceph: do not reconcile if the op is not ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the op is initializing, the ceph config is not ready and thus we should reconcile. This avoids a double reconcile. Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/watcher.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/operator/ceph/cluster/watcher.go b/pkg/operator/ceph/cluster/watcher.go index e6b3ffac8..9e3bf676c 100644 --- a/pkg/operator/ceph/cluster/watcher.go +++ b/pkg/operator/ceph/cluster/watcher.go @@ -19,11 +19,13 @@ package cluster import ( "context" + "strings" cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" cephclient "github.com/rook/rook/pkg/daemon/ceph/client" discoverDaemon "github.com/rook/rook/pkg/daemon/discover" + opcontroller "github.com/rook/rook/pkg/operator/ceph/controller" "github.com/rook/rook/pkg/operator/k8sutil" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -107,6 +109,10 @@ func (c *clientCluster) onK8sNode(object runtime.Object) bool { clusterInfo := cephclient.AdminClusterInfo(cluster.Namespace) osds, err := cephclient.GetOSDOnHost(c.context, clusterInfo, nodeName) if err != nil { + if strings.Contains(err.Error(), opcontroller.UninitializedCephConfigError) { + logger.Debug(opcontroller.OperatorNotInitializedMessage) + return false + } // If it fails, this might be due to the the operator just starting and catching an add event for that node logger.Debugf("failed to get osds on node %q, assume reconcile is necessary", nodeName) return true