Skip to content

Commit

Permalink
Federator should sync the "status" field (submariner-io#82)
Browse files Browse the repository at this point in the history
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 <tompantelis@gmail.com>
  • Loading branch information
tpantelis authored Jul 6, 2020
1 parent 4a239c5 commit d52c64c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/syncer/broker/federator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func (f *federator) prepareResourceForSync(resource *unstructured.Unstructured)
}
}

unstructured.RemoveNestedField(resource.Object, "status")
resource.SetNamespace(f.brokerNamespace)
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/syncer/broker/federator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions pkg/syncer/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit d52c64c

Please sign in to comment.