From d52c64ccd7ba44b0ef37037c5acd747a7f29ee76 Mon Sep 17 00:00:00 2001 From: Thomas Pantelis Date: Mon, 6 Jul 2020 14:54:24 -0400 Subject: [PATCH] Federator should sync the "status" field (#82) The broker Federator previously stripped out the "status" field to avoid potential performance issues but lighthouse needs it synced. Instead of automatically stripping it, we can defer to the TransformFunc or add a flag to do it later if needed. Signed-off-by: Tom Pantelis --- pkg/syncer/broker/federator.go | 1 - pkg/syncer/broker/federator_test.go | 14 ++++++++++++++ pkg/syncer/test/util.go | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/syncer/broker/federator.go b/pkg/syncer/broker/federator.go index d7f68081..4c5a5b3f 100644 --- a/pkg/syncer/broker/federator.go +++ b/pkg/syncer/broker/federator.go @@ -86,7 +86,6 @@ func (f *federator) prepareResourceForSync(resource *unstructured.Unstructured) } } - unstructured.RemoveNestedField(resource.Object, "status") resource.SetNamespace(f.brokerNamespace) } diff --git a/pkg/syncer/broker/federator_test.go b/pkg/syncer/broker/federator_test.go index 0abf2d04..d7da8d3e 100644 --- a/pkg/syncer/broker/federator_test.go +++ b/pkg/syncer/broker/federator_test.go @@ -58,6 +58,20 @@ func testDistribute() { }) }) + When("the resource contains Status data", func() { + BeforeEach(func() { + resource.Status = corev1.PodStatus{ + Phase: "PodRunning", + Message: "Pod is running", + } + }) + + It("should create the resource with the Status data", func() { + Expect(f.Distribute(resource)).To(Succeed()) + test.VerifyResource(resourceClient, resource, test.RemoteNamespace, localClusterID) + }) + }) + When("create fails", func() { JustBeforeEach(func() { resourceClient.FailOnCreate = apierrors.NewServiceUnavailable("fake") diff --git a/pkg/syncer/test/util.go b/pkg/syncer/test/util.go index 62ef300a..7b52206c 100644 --- a/pkg/syncer/test/util.go +++ b/pkg/syncer/test/util.go @@ -57,6 +57,7 @@ func VerifyResource(resourceInterface dynamic.ResourceInterface, expected *corev Expect(actual.GetNamespace()).To(Equal(expNamespace)) Expect(actual.GetAnnotations()).To(Equal(expected.GetAnnotations())) Expect(actual.Spec).To(Equal(expected.Spec)) + Expect(actual.Status).To(Equal(expected.Status)) Expect(actual.GetUID()).NotTo(Equal(expected.GetUID())) Expect(actual.GetResourceVersion()).NotTo(Equal(expected.GetResourceVersion()))