Skip to content

Commit

Permalink
Add delete precondition to V2 state machine for Verified ReplicaSet (#…
Browse files Browse the repository at this point in the history
…552)

Here I've added the precondition on resource versions to delete requests
sent by the model (and the exec) state machines. The conformance proof
still goes through.

Signed-off-by: Cody Rivera <[email protected]>
  • Loading branch information
codyjrivera authored Oct 2, 2024
1 parent b8f30ad commit f3fe6d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/v2/controllers/vreplicaset_controller/exec/reconciler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ pub fn reconcile_core(v_replica_set: &VReplicaSet, resp_o: Option<Response<Empty
api_resource: Pod::api_resource(),
name: pod_name_or_none.unwrap(),
namespace: namespace,
preconditions: None,
preconditions: {
let mut pre = Preconditions::default();
pre.set_resource_version_from_object_meta(filtered_pods[diff - 1].metadata());
Some(pre)
},
});
let state_prime = VReplicaSetReconcileState {
reconcile_step: VReplicaSetReconcileStep::AfterDeletePod(diff - 1),
Expand Down Expand Up @@ -203,8 +207,13 @@ pub fn reconcile_core(v_replica_set: &VReplicaSet, resp_o: Option<Response<Empty
api_resource: Pod::api_resource(),
name: pod_name_or_none.unwrap(),
namespace: namespace,
// TODO: set the resource version to be the precondition
preconditions: None,
preconditions: {
let mut pre = Preconditions::default();
pre.set_resource_version_from_object_meta(
state.filtered_pods.as_ref().unwrap()[diff - 1].metadata()
);
Some(pre)
},
});
let state_prime = VReplicaSetReconcileState {
reconcile_step: VReplicaSetReconcileStep::AfterDeletePod(diff - 1),
Expand Down
10 changes: 8 additions & 2 deletions src/v2/controllers/vreplicaset_controller/model/reconciler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ pub open spec fn reconcile_core(
name: pod_name_or_none.unwrap(),
namespace: namespace,
},
preconditions: None,
preconditions: Some(PreconditionsView {
uid: None,
resource_version: filtered_pods[diff - 1].metadata.resource_version
}),
});
let state_prime = VReplicaSetReconcileState {
reconcile_step: VReplicaSetReconcileStep::AfterDeletePod((diff - 1) as usize),
Expand Down Expand Up @@ -184,7 +187,10 @@ pub open spec fn reconcile_core(
name: pod_name_or_none.unwrap(),
namespace: namespace,
},
preconditions: None,
preconditions: Some(PreconditionsView {
uid: None,
resource_version: state.filtered_pods.unwrap()[diff - 1].metadata.resource_version
}),
});
let state_prime = VReplicaSetReconcileState {
reconcile_step: VReplicaSetReconcileStep::AfterDeletePod((diff - 1) as usize),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub open spec fn current_state_matches(vrs: VReplicaSetView) -> StatePred<Cluste

pub open spec fn owned_selector_match_is(vrs: VReplicaSetView, obj: DynamicObjectView) -> bool {
&&& obj.kind == PodView::kind()
&&& obj.metadata.namespace.is_Some()
&&& obj.metadata.namespace == vrs.metadata.namespace
&&& obj.metadata.owner_references_contains(vrs.controller_owner_ref())
&&& vrs.spec.selector.matches(obj.metadata.labels.unwrap_or(Map::empty()))
Expand Down

0 comments on commit f3fe6d9

Please sign in to comment.