Skip to content

Conversation

@acroca
Copy link
Member

@acroca acroca commented Nov 25, 2025

Implements the patching as described in the versioning proposal.

Quick summary of the changes added in this PR:

  • Support for adding ctx.IsPatched(patchName) bool to ongoing workflows
  • Set workflow instance to PendingVersion if the orchestrator find a patch mismatch
  • Add PendingVersion event when a patch mismatch is found
  • Populate state.IsPendingVersion acordingly

Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca acroca requested a review from a team as a code owner November 25, 2025 10:12
RUNTIME_STATUS_TERMINATED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_TERMINATED
RUNTIME_STATUS_PENDING OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_PENDING
RUNTIME_STATUS_SUSPENDED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_SUSPENDED
RUNTIME_STATUS_PENDING_VERSION OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_PENDING_VERSION

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be better to call this PENDING_PATCH_MISSMATCH ?

return protos.OrchestrationStatus_ORCHESTRATION_STATUS_SUSPENDED
} else if s.CompletedEvent != nil {
return s.CompletedEvent.GetOrchestrationStatus()
} else if s.IsPendingVersion {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: does suspended supersede pending?


if results.GetPatchMismatch() {
_ = runtimestate.AddEvent(wi.State, &protos.HistoryEvent{
EventId: -1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated note: we should update Event ID to be optional.

ExecutionPendingVersion: &protos.ExecutionPendingVersionEvent{},
},
})
w.logger.Warnf("%v: patch mismatch detected; setting version pending for orchestration instance", wi.InstanceID)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this log necessary? At minimum it should be debug I think.

if os := e.GetOrchestratorStarted(); os != nil {
os.Patches = results.Patches
for _, p := range results.Patches.Patches {
if err := helpers.StartAndEndNewPatchSpan(ctx, p, e.Timestamp.AsTime()); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an existing span we would add the patches as attributes to?

resp.Actions = results.Actions
resp.CustomStatus = results.GetCustomStatus()
resp.Patches = results.GetPatches()
resp.PatchMismatch = results.GetPatchMismatch()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we signal what patches were mismatched?

}
scheduleTask := a.GetScheduleTask()
if scheduleTask.GetName() != ts.GetName() {
if len(ctx.patches) > 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think I understand how this is working 🤔

Patch miss match should be evaluated server side.

}

func (ctx *OrchestrationContext) IsPatched(patchName string) bool {
isPatched := slices.Contains(ctx.patches, patchName)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches should be ordered.

}

// We're at the end of the history stream, we can run the patched version and save the decision for next rerun
ctx.newPatches = append(ctx.newPatches, patchName)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the variable name of patchesTaken and newPatchesTaken?

Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca acroca force-pushed the workflow-versioning branch from fb69eac to fd5db26 Compare November 28, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants