Skip to content

improve: managed dependent reconciliation results not optional #2212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/documentation/v5-0-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ permalink: /docs/v5-0-migration
---

# Migrating from v4.7 to v5.0

## API Tweaks

1. [Result of managed dependent resources](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedDependentResourceContext.java#L55-L57)
is not `Optional` anymore. In case you use this result, simply use the result
objects directly.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public DefaultManagedDependentResourceContext setWorkflowCleanupResult(
}

@Override
public Optional<WorkflowReconcileResult> getWorkflowReconcileResult() {
return Optional.ofNullable(workflowReconcileResult);
public WorkflowReconcileResult getWorkflowReconcileResult() {
return workflowReconcileResult;
}

@Override
public Optional<WorkflowCleanupResult> getWorkflowCleanupResult() {
return Optional.ofNullable(workflowCleanupResult);
public WorkflowCleanupResult getWorkflowCleanupResult() {
return workflowCleanupResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface ManagedDependentResourceContext {
@SuppressWarnings("unused")
<T> T getMandatory(Object key, Class<T> expectedType);

Optional<WorkflowReconcileResult> getWorkflowReconcileResult();
WorkflowReconcileResult getWorkflowReconcileResult();

Optional<WorkflowCleanupResult> getWorkflowCleanupResult();
WorkflowCleanupResult getWorkflowCleanupResult();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent;
import io.javaoperatorsdk.operator.processing.dependent.workflow.WorkflowReconcileResult;

@ControllerConfiguration(dependents = @Dependent(readyPostcondition = SampleBulkCondition.class,
type = CRUDConfigMapBulkDependentResource.class))
Expand All @@ -23,7 +22,8 @@ public UpdateControl<BulkDependentTestCustomResource> reconcile(
numberOfExecutions.incrementAndGet();

var ready = context.managedDependentResourceContext().getWorkflowReconcileResult()
.map(WorkflowReconcileResult::allDependentResourcesReady).orElseThrow();
.allDependentResourcesReady();


resource.setStatus(new BulkDependentTestStatus());
resource.getStatus().setReady(ready);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public UpdateControl<ComplexDependentCustomResource> reconcile(
ComplexDependentCustomResource resource,
Context<ComplexDependentCustomResource> context) throws Exception {
var ready = context.managedDependentResourceContext().getWorkflowReconcileResult()
.orElseThrow().allDependentResourcesReady();
.allDependentResourcesReady();

var status = Objects.requireNonNullElseGet(resource.getStatus(), ComplexDependentStatus::new);
status.setStatus(ready ? RECONCILE_STATUS.READY : RECONCILE_STATUS.NOT_READY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public UpdateControl<WorkflowAllFeatureCustomResource> reconcile(
resource.getStatus()
.setReady(
context.managedDependentResourceContext()
.getWorkflowReconcileResult().orElseThrow()
.getWorkflowReconcileResult()
.allDependentResourcesReady());
return UpdateControl.patchStatus(resource);
}
Expand Down