1280
1281
//nolint:staticcheck // deprecated stuff will be cleaned
1282
>
func (d *WorkflowRunner) handleSetCurrent(ctx workflow.Context, args *deploymentspb.SetCurrentVersionArgs) (*deploymentspb.SetCurrentVersionResponse, error) {
workflow.go
1283
>
if err := d.preUpdateChecks(ctx); err != nil {
1284
return nil, err
1285
}
1286
1287
// use lock to enforce only one update at a time
1289
>
if err != nil {
1290
d.logger.Error("Could not acquire workflow lock")
1291
return nil, serviceerror.NewDeadlineExceeded("Could not acquire workflow lock")
1292
}
1294
>
// Even if the update doesn't change the state we mark it as dirty because of created history events.
1295
>
d.setStateChanged()
1296
>
d.lock.Unlock()
1297
>
}()
1298
1299
// Log state before update
1300
// TODO(carlydf): remove verbose logging
1301
>
d.logger.Info("Starting SetCurrent update",
workflow.go
1302
>
//nolint:staticcheck // SA1019: worker versioning v0.31
1303
>
"current_version", d.State.GetRoutingConfig().GetCurrentVersion(),
1304
>
"new_version", args.Version,
1305
>
"routing_config", d.State.GetRoutingConfig())
1306
>
1307
>
// Validating the state before starting the SetCurrent operation. This is required due to the following reason:
1308
>
// The validator accepts/rejects updates based on the state of the deployment workflow. Theoretically, two concurrent update requests
1309
>
// might be accepted by the validator since the state of the workflow, at that point in time, is valid for the updates to take place. Since this update handler
1310
>
// enforces sequential updates, after the first update completes, the local state of the deployment workflow will change. The second update,
1311
>
// now already accepted by the validator, should now not be allowed to run since the state of the workflow is different.
1312
>
err = d.validateStateBeforeAcceptingSetCurrent(args)
1313
>
if err != nil {
1314
return nil, err
1315
}
1316
1317
>
prevCurrentVersion := d.State.RoutingConfig.CurrentVersion
workflow.go
1318
>
newCurrentVersion := args.Version
1319
>
updateTime := timestamppb.New(workflow.Now(ctx))
1320
>
1321
>
if _, ok := d.State.Versions[args.Version]; !ok &&
1322
>
args.Version != worker_versioning.UnversionedVersionId &&
1323
>
args.GetAllowNoPollers() {
1324
d.logger.Info("version not found in deployment, but AllowNoPollers is true, so we will create the version")
1325
if err := d.addVersionToWorkerDeployment(ctx, &deploymentspb.AddVersionUpdateArgs{Version: newCurrentVersion, CreateTime: updateTime}); err != nil {