uberf-9382: fix upgrading workspace access (#7908)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2025-02-04 17:11:23 +04:00 committed by GitHub
parent e3b9ae7b28
commit 5cdf19a945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 10 deletions

View File

@ -810,7 +810,9 @@ export interface BackupStatus {
export interface WorkspaceInfoWithStatus extends WorkspaceInfo {
isDisabled?: boolean
version?: Data<Version>
versionMajor: number
versionMinor: number
versionPatch: number
lastVisit?: number
mode: WorkspaceMode
processingProgress?: number

View File

@ -38,7 +38,9 @@ import core, {
buildSocialIdString,
type PersonId,
type WorkspaceDataId,
type PersonUuid
type PersonUuid,
Data,
Version
} from '@hcengineering/core'
import { getClient as getAccountClient, isWorkspaceLoginInfo } from '@hcengineering/account-client'
import { unknownError, type Status } from '@hcengineering/platform'
@ -407,16 +409,21 @@ class TSessionManager implements SessionManager {
return { error: new Error('Account not found or not available'), terminate: true }
}
const wsVersion: Data<Version> = {
major: workspaceInfo.versionMajor,
minor: workspaceInfo.versionMinor,
patch: workspaceInfo.versionPatch
}
if (
this.modelVersion !== '' &&
workspaceInfo.version !== undefined &&
this.modelVersion !== versionToString(workspaceInfo.version) &&
this.modelVersion !== versionToString(wsVersion) &&
token.extra?.model !== 'upgrade' &&
token.extra?.mode !== 'backup'
) {
ctx.warn('Model version mismatch', {
version: this.modelVersion,
workspaceVersion: versionToString(workspaceInfo.version),
workspaceVersion: versionToString(wsVersion),
workspace: workspaceInfo.uuid,
workspaceUrl: workspaceInfo.url,
account: token.account,

View File

@ -313,11 +313,16 @@ export class WorkspaceWorker {
}
}
const workspaceVersion = {
major: ws.versionMajor,
minor: ws.versionMinor,
patch: ws.versionPatch
}
const logger = opt.console ? ctxModelLogger : new FileModelLogger(path.join(opt.logs, `${ws.uuid}.log`))
ctx.info('---UPGRADING----', {
workspace: ws.uuid,
workspaceVersion: ws.version,
workspaceVersion,
requestedVersion: this.version,
region: this.region
})
@ -351,7 +356,7 @@ export class WorkspaceWorker {
)
ctx.info('---UPGRADE-DONE---------', {
workspace: ws.uuid,
oldWorkspaceVersion: ws.version,
oldWorkspaceVersion: workspaceVersion,
requestedVersion: this.version,
region: this.region,
time: Date.now() - t
@ -367,7 +372,7 @@ export class WorkspaceWorker {
ctx.error('---UPGRADE-FAILED---------', {
workspace: ws.uuid,
oldWorkspaceVersion: ws.version,
oldWorkspaceVersion: workspaceVersion,
requestedVersion: this.version,
region: this.region,
time: Date.now() - t

View File

@ -234,14 +234,19 @@ export async function upgradeWorkspaceWith (
external: boolean = false
): Promise<void> {
const versionStr = versionToString(version)
const workspaceVersion = {
major: ws.versionMajor,
minor: ws.versionMinor,
patch: ws.versionPatch
}
if (ws?.version !== undefined && !forceUpdate && versionStr === versionToString(ws.version)) {
if (!forceUpdate && versionStr === versionToString(workspaceVersion)) {
return
}
ctx.info('upgrading', {
force: forceUpdate,
currentVersion: ws?.version !== undefined ? versionToString(ws.version) : '',
currentVersion: versionToString(workspaceVersion),
toVersion: versionStr,
workspace: ws.uuid
})