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 .prettierrc
tools tools
PublishTempFolder: publish_artifacts 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 # A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:

View File

@ -15,12 +15,40 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const exec = require('child_process').exec
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 { try {
const versionFilePath = path.resolve(__dirname, 'version.txt') const versionFilePath = path.resolve(__dirname, 'version.txt')
const version = fs.readFileSync(versionFilePath, 'utf8').trim() version = fs.readFileSync(versionFilePath, 'utf8').trim()
} catch (error) {
version = '"0.6.0"'
}
console.log(version) console.log(version)
} catch (error) {
console.log('0.6.0')
} }
})
}
let mode = process.env.MODEL_VERSION_MODE
if (mode !== 'tagTime') {
mode = 'file'
}
main(mode)

View File

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