Interface RmStatusReporter<T extends io.confluent.resourcemanager.api.model.HasMetadata>

Type Parameters:
T - The resource type (must implement HasMetadata and be a protobuf Message)
All Known Implementing Classes:
RmIspStatusReporter

public interface RmStatusReporter<T extends io.confluent.resourcemanager.api.model.HasMetadata>
Helper for managing RM resource status, finalizers, and observed generation. // To update with a new status condition reporter.reportStatus(isp, condition); // On spec changes (new generation) reporter.setObservedGeneration(isp); // To register cleanup ownership before processing a resource reporter.addFinalizer(isp, "broker.confluent.io/isp"); // Once cleanup is complete, release the finalizer so RM can finish deletion reporter.deleteFinalizer(isp, "broker.confluent.io/isp");
  • Method Summary

    Modifier and Type
    Method
    Description
    addFinalizer(T resource, String finalizer)
    Adds a finalizer to the resource's metadata.
    deleteFinalizer(T resource, String finalizer)
    Removes a finalizer from the resource's metadata, allowing deletion to proceed once all finalizers have been removed.
    getLatest(T resource)
    Re-reads the resource from RM by its identity (name + scopes), returning the currently persisted copy with the latest resourceVersion.
    reportStatus(T resource, io.confluent.resourcemanager.protobuf.apis.meta.v1.Condition condition)
    Sets the status condition for the resource.
    Updates the observed generation in the status field to match spec.generation
  • Method Details

    • reportStatus

      CompletableFuture<T> reportStatus(T resource, io.confluent.resourcemanager.protobuf.apis.meta.v1.Condition condition)
      Sets the status condition for the resource.
      Parameters:
      resource - The resource to update (observedGeneration is not updated - this must be set by the application beforehand)
      condition - The condition that consists of type, status, reason, message, and lastTransitionTime
      Returns:
      CompletableFuture with the updated resource
    • getLatest

      CompletableFuture<T> getLatest(T resource)
      Re-reads the resource from RM by its identity (name + scopes), returning the currently persisted copy with the latest resourceVersion. Use this before a status update to perform a read-modify-write and avoid optimistic-concurrency conflicts when other writers may have advanced the resource since it was last read.
      Parameters:
      resource - The resource whose identity to read; its contents other than identity are ignored
      Returns:
      CompletableFuture with the current resource, completing exceptionally if it no longer exists
    • setObservedGeneration

      T setObservedGeneration(T resource)
      Updates the observed generation in the status field to match spec.generation
      Parameters:
      resource - The resource to update (observedGeneration set to spec.generation)
      Returns:
      The updated resource with observedGeneration set
    • addFinalizer

      CompletableFuture<T> addFinalizer(T resource, String finalizer)
      Adds a finalizer to the resource's metadata. If the finalizer is already present on the supplied resource, the resource is left unchanged and no update is issued to RM.

      Note: The decision to skip the update is made against the finalizer list of the resource argument, not against current RM state. If a stale resource is passed whose finalizer list has diverged from RM, the returned future may report success without the finalizer actually being persisted. The caller is responsible to read current state, modify, then update, and retry on a resourceVersion conflict.

      Parameters:
      resource - The resource to update; must reflect current RM state
      finalizer - The finalizer to add
      Returns:
      CompletableFuture with the updated resource
    • deleteFinalizer

      CompletableFuture<T> deleteFinalizer(T resource, String finalizer)
      Removes a finalizer from the resource's metadata, allowing deletion to proceed once all finalizers have been removed. If the finalizer is not present on the supplied resource, the resource is left unchanged and no update is issued to RM.

      Note: The decision to skip the update is made against the finalizer list of the resource argument, not against current RM state. If a stale resource is passed whose finalizer list has diverged from RM, the returned future may report success without the finalizer actually being removed. The caller is responsible to read current state, modify, then update, and retry on a resourceVersion conflict.

      Parameters:
      resource - The resource to update; must reflect current RM state
      finalizer - The finalizer to remove
      Returns:
      CompletableFuture with the updated resource