If the upsert request does not contain previous object's summary id, the summar id will be reset to 1 and cause inconsistency between expectedRunningJobId and runningJobId.
For example, an existing target box-truck with job id 4 and status success exists. When I try to update the target with rest API "/targets/registry", it will reset the job id to 1 and the job will be pending because the expected job id 4 is greater than 1:
From client side RestAPI, get the current object first and compare the annotations with the request body. Compare and merge the annotations before update the object. We should also update the ResourceVersion when we perform the update operation. The drawback is it will not support clean up annotations on purpose.
Add an inspection in webhook for correctness of annotations. However, we should only allow internal updates to change the system level information, and protect the system data (eg. jobId) from customer changes. For this approach, we need to investigate if we can distinguish the request identity.
In k8s state provider, when update an existing object, the annotations are directly adopted from the incoming request https://github.com/eclipse-symphony/symphony/blob/7971d7ec6ac13314096e12eb147fef9f64ac3732/api/pkg/apis/v1alpha1/providers/states/k8s/k8s.go#L246-L256
If the upsert request does not contain previous object's summary id, the summar id will be reset to 1 and cause inconsistency between
expectedRunningJobId
andrunningJobId
.For example, an existing target
box-truck
with job id 4 and status success exists. When I try to update the target with rest API "/targets/registry", it will reset the job id to 1 and the job will be pending because the expected job id 4 is greater than 1:We need to think of a solution to ensure the upsert operation preserve the correct summary job id.