1352
}
1353
1355
>
1356
>
var unversionedStatsByPriority map[int32]*taskqueuepb.TaskQueueStats
1357
>
var currentVersion *deploymentspb.WorkerDeploymentVersion
1358
>
var rampingVersion *deploymentspb.WorkerDeploymentVersion
1359
>
var rampPercentage float32
1360
>
var currentExists bool
1361
>
var rampingExists bool
1362
>
var isRamping bool
1363
>
var unversionedCurrentShareByPriority map[int32]*taskqueuepb.TaskQueueStats
1364
>
var unversionedRampingShareByPriority map[int32]*taskqueuepb.TaskQueueStats
1365
>
1366
>
if reportStats {
1367
>
// Consider the default/unversioned queue. For current/ramping deployment versions, tasks are backlogged
1368
>
// here, so we include this queue's stats if the version to describe is a current/ramping version.
1369
>
dbq := pm.defaultQueue()
1370
>
if dbq == nil {
1371
return nil, errDefaultQueueNotInit
1372
}
1374
>
1375
>
userData, _, err := pm.GetUserDataManager().GetUserData()
1376
>
if err != nil {
1377
return nil, err
1378
}
1380
>
deploymentData := perType.GetDeploymentData()
1381
>
1382
>
currentVersion, _, _, rampingVersion, isRamping, rampPercentage, _, _ =
1383
>
worker_versioning.CalculateTaskQueueVersioningInfo(deploymentData)
1384
>
1385
>
// Technically, one could have a current version of "unversioned" which shall make currentExists false according
1386
>
// to the current logic. However, as of now, the user cannot query the stats of the "unversioned" version so this
1387
>
// logic is fine. In other words, this logic is used to only attribute the unversioned backlog to the current version
1388
>
// when current version is NOT "unversioned".
1389
>
//
1390
>
// When the ramping version is "unversioned", isRamping is true which shall make the attribution logic work as expected.
1391
>
currentExists = currentVersion != nil
1392
>
rampingExists = isRamping && rampPercentage > 0
1393
>
1394
>
// Split the unversioned queue's stats per priority so TaskQueueStatsByPriorityKey can
1395
>
// be adjusted consistently with TaskQueueStats.
1396
>
unversionedCurrentShareByPriority = map[int32]*taskqueuepb.TaskQueueStats{}
1397
>
unversionedRampingShareByPriority = map[int32]*taskqueuepb.TaskQueueStats{}
1398
>
if rampingExists {
1399
unversionedCurrentShareByPriority, unversionedRampingShareByPriority =
1400
splitStatsByPriorityByRampPercentage(unversionedStatsByPriority, rampPercentage)
1402
// If there exist no ramping version, we attribute the entire unversioned backlog to the current version.
1403
unversionedCurrentShareByPriority = cloneStatsByPriority(unversionedStatsByPriority)