UBERF-8044: staging model version (#6492)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-09-09 19:17:19 +04:00 committed by GitHub
parent 04e93939f6
commit 743c88c30d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 20 deletions

View File

@ -40,6 +40,7 @@ env:
.prettierrc
tools
PublishTempFolder: publish_artifacts
MODEL_VERSION_MODE: ${{ startsWith(github.ref, 'refs/tags/s') && 'tagTime' || 'file' }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

View File

@ -15,12 +15,40 @@
const fs = require('fs')
const path = require('path')
const exec = require('child_process').exec
try {
const versionFilePath = path.resolve(__dirname, 'version.txt')
const version = fs.readFileSync(versionFilePath, 'utf8').trim()
console.log(version)
} catch (error) {
console.log('0.6.0')
function main (mode) {
exec('git describe --tags --abbrev=0', (err, stdout) => {
if (err !== null) {
console.log('"0.7.0"')
return
}
const tag = stdout.trim()
if (mode === 'tagTime') {
// Take tagged git commit date as model version
exec(`git for-each-ref --shell --format="%(creatordate:format:%s)" "refs/tags/${tag}"`, (err, stdout) => {
console.log(`"0.7.${err === null ? stdout.trim().slice(1, -1) : 0}"`)
})
} else {
// Take version from file
let version
try {
const versionFilePath = path.resolve(__dirname, 'version.txt')
version = fs.readFileSync(versionFilePath, 'utf8').trim()
} catch (error) {
version = '"0.6.0"'
}
console.log(version)
}
})
}
let mode = process.env.MODEL_VERSION_MODE
if (mode !== 'tagTime') {
mode = 'file'
}
main(mode)

View File

@ -1480,22 +1480,20 @@ export async function getPendingWorkspace (
? pendingUpgradeQuery
: [...pendingCreationQuery, ...pendingUpgradeQuery]
}
let query: Filter<Workspace>
const attemptsQuery = { $or: [{ attempts: { $exists: false } }, { attempts: { $lte: 3 } }] }
if (region !== '') {
query = {
...operationQuery,
region
}
} else {
query = {
$and: [operationQuery, defaultRegionQuery]
}
// We must have all the conditions in the DB query and we cannot filter anything in the code
// because of possible concurrency between account services. We have to update "lastProcessingTime"
// at the time of retrieval and not after some additional processing.
const query: Filter<Workspace> = {
$and: [
operationQuery,
attemptsQuery,
region !== '' ? { region } : defaultRegionQuery,
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } }
]
}
query.lastProcessingTime = { $lt: Date.now() - processingTimeoutMs }
query.attempts = { $lte: 3 }
return (
(await wsCollection.findOneAndUpdate(
query,