From 55b8742f82c525c1a7751fdf28cdcef73a80115b Mon Sep 17 00:00:00 2001 From: Michael Morello Date: Mon, 24 Jun 2019 08:10:28 +0200 Subject: [PATCH 1/3] Keep nil value in status --- .../controller/elasticsearch/remotecluster/elasticsearch.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go index 0fcfe393ff..c17ff6c256 100644 --- a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go +++ b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go @@ -75,7 +75,9 @@ func UpdateRemoteCluster( } } // Update state - reconcileState.UpdateRemoteClusters(currentRemoteClusters) + if len(currentRemoteClusters) > 0 { + reconcileState.UpdateRemoteClusters(currentRemoteClusters) + } return nil } From f3ce9955ce7fe67476b3879fa769e5424adcb2bf Mon Sep 17 00:00:00 2001 From: Michael Morello Date: Mon, 24 Jun 2019 08:21:32 +0200 Subject: [PATCH 2/3] Add comment --- .../pkg/controller/elasticsearch/remotecluster/elasticsearch.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go index c17ff6c256..85fbdf2e6d 100644 --- a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go +++ b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go @@ -75,6 +75,8 @@ func UpdateRemoteCluster( } } // Update state + // If the map is empty then it must be stored as nil, not an empty map. It is retrieved as a nil value from the API + // and it could lead to some reconcile loops that never converge on Openshift. if len(currentRemoteClusters) > 0 { reconcileState.UpdateRemoteClusters(currentRemoteClusters) } From 538cf2a8622e2e5f9a1f5c39c1a859d0223e2dd3 Mon Sep 17 00:00:00 2001 From: Michael Morello Date: Tue, 25 Jun 2019 07:27:24 +0200 Subject: [PATCH 3/3] Ensure map is nil if empty --- .../controller/elasticsearch/remotecluster/elasticsearch.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go index 85fbdf2e6d..ded51028fb 100644 --- a/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go +++ b/operators/pkg/controller/elasticsearch/remotecluster/elasticsearch.go @@ -79,6 +79,9 @@ func UpdateRemoteCluster( // and it could lead to some reconcile loops that never converge on Openshift. if len(currentRemoteClusters) > 0 { reconcileState.UpdateRemoteClusters(currentRemoteClusters) + } else { + // ensure that map is nil in the status if empty + reconcileState.UpdateRemoteClusters(nil) } return nil }