operator-framework / josdk-spring-boot-starter

Apache License 2.0
39 stars 20 forks source link

Mock Kubernetes server doesn't handle resource updates properly #4

Closed vadeg closed 1 year ago

vadeg commented 3 years ago

Create the following integration test

On the last step controller will not get the resource update / delete event. This happens because of two things:

  1. All operator sdk controllers by default use generation metadata property to decide what to do with resource event. There is a function called CustomResourceEventSource.skipBecauseOfGeneration, which rejects events with a generation lower or equal to existing one.
  2. KubernetesCrudDispatcher. setDefaultMetadata from fabric8io/kubernetes-client library never increase the generation property.

Only if to set @Controller(generationAwareEventProcessing = false) then update events will reach out to controller. I think the MockServer should be updated to be in sync with a default Controller settings.

m-kay commented 1 year ago

I can not reproduce this issue anymore in version 5.2.0.

Not sure how exactly did you update your resource. When retrieving the current resource via KubernetesClient and then using the patch() method, it all works fine for me.

This looks as following in my test:

val myResources = kubernetesClient.resources(MyResource::class.java)
myResources.load(ClassPathResource("test-resource.yaml").inputStream).create()

await atMost Duration.ofSeconds(5) until {
    myResources.withName("my-resource").get().status?.observedGeneration == 1L
}

val resource = myResources.withName("my-resource").get()
resource.spec.version = "1.3.3"
myResources.resource(resource).patch()
await atMost Duration.ofSeconds(5) until {
    myResources.withName("my-resource").get().status?.observedGeneration == 2L
}
csviri commented 1 year ago

great, thank you @m-kay , probably was fixed in fabric8 client, will close the issue!