Skip to content

Commit 62afda2

Browse files
committed
Sync WCI compute status to worker deployment version state
Add DescribeWorkerControllerInstanceStatus activity to fetch the WCI validation status and map it to a ComputeStatus. During handleSyncState, invoke syncVersionDataToComputeStatus to update the version state's ComputeStatus with the provider validation result. The sync is gated behind the "sync-compute-validation-status" workflow version for backward compatibility.
1 parent a31f476 commit 62afda2

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

service/worker/workerdeployment/version_activities.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ func (a *VersionActivities) GetVersionDrainageStatus(ctx context.Context, versio
199199
}, nil
200200
}
201201

202+
func (a *VersionActivities) DescribeWorkerControllerInstanceStatus(ctx context.Context, version *deploymentspb.WorkerDeploymentVersion) (*deploymentpb.ComputeStatus, error) {
203+
resp, _, err := a.WorkerControllerInstanceClient.DescribeWorkerControllerInstance(ctx, a.namespace, &deploymentpb.WorkerDeploymentVersion{DeploymentName: version.GetDeploymentName(), BuildId: version.GetBuildId()})
204+
if err != nil {
205+
return nil, err
206+
}
207+
208+
return wciValidationStatusToComputeStatus(resp.ValidationStatus), nil
209+
}
210+
202211
func (a *VersionActivities) UpdateWorkerControllerInstance(ctx context.Context, input *deploymentspb.UpdateWorkerControllerInstanceInput) (*computepb.ComputeConfigSummary, error) {
203212
upserts := scalingGroupUpdatesToWCI(input.GetUpsertScalingGroups())
204213
resp, err := a.WorkerControllerInstanceClient.UpdateWorkerControllerInstance(ctx, a.namespace, input.GetVersion(), nil, input.GetIdentity(), upserts, input.GetRemoveScalingGroups())

service/worker/workerdeployment/version_workflow.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,10 @@ func (d *VersionWorkflowRunner) handleSyncState(ctx workflow.Context, args *depl
964964
state.LastDeactivationTime = nil
965965
}
966966

967+
if err := d.syncVersionDataToComputeStatus(ctx); err != nil {
968+
return nil, err
969+
}
970+
967971
return &deploymentspb.SyncVersionStateResponse{
968972
Summary: versionStateToSummary(state),
969973
}, nil
@@ -1244,6 +1248,27 @@ func (d *VersionWorkflowRunner) syncVersionStatusAfterDrainageStatusChange(ctx w
12441248
return d.syncVersionDataToTaskQueues(ctx, versionData)
12451249
}
12461250

1251+
// syncVersionDataToComputeStatus is a helper that syncs the compute status from WCI to the worker deployment version
1252+
func (d *VersionWorkflowRunner) syncVersionDataToComputeStatus(ctx workflow.Context) error {
1253+
if workflow.GetVersion(ctx, "sync-compute-validation-status", workflow.DefaultVersion, 0) == workflow.DefaultVersion {
1254+
return nil
1255+
}
1256+
1257+
state := d.GetVersionState()
1258+
1259+
var result deploymentpb.ComputeStatus
1260+
resp := workflow.ExecuteActivity(workflow.WithActivityOptions(ctx, defaultActivityOptions), d.a.DescribeWorkerControllerInstanceStatus, state.GetVersion())
1261+
if err := resp.Get(ctx, &result); err != nil {
1262+
return err
1263+
}
1264+
if result.ProviderValidation == nil {
1265+
return nil
1266+
}
1267+
1268+
state.ComputeStatus = &result
1269+
return nil
1270+
}
1271+
12471272
// syncVersionDataToTaskQueues is a helper that syncs the provided version data to all task queues.
12481273
// This function does NOT acquire the workflow lock - the caller is responsible for that.
12491274
func (d *VersionWorkflowRunner) syncVersionDataToTaskQueues(ctx workflow.Context, versionData *deploymentspb.DeploymentVersionData) error {

0 commit comments

Comments
 (0)