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 { export interface WorkspaceInfoWithStatus extends WorkspaceInfo {
isDisabled?: boolean isDisabled?: boolean
version?: Data<Version> versionMajor: number
versionMinor: number
versionPatch: number
lastVisit?: number lastVisit?: number
mode: WorkspaceMode mode: WorkspaceMode
processingProgress?: number processingProgress?: number

View File

@ -38,7 +38,9 @@ import core, {
buildSocialIdString, buildSocialIdString,
type PersonId, type PersonId,
type WorkspaceDataId, type WorkspaceDataId,
type PersonUuid type PersonUuid,
Data,
Version
} from '@hcengineering/core' } from '@hcengineering/core'
import { getClient as getAccountClient, isWorkspaceLoginInfo } from '@hcengineering/account-client' import { getClient as getAccountClient, isWorkspaceLoginInfo } from '@hcengineering/account-client'
import { unknownError, type Status } from '@hcengineering/platform' 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 } 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 ( if (
this.modelVersion !== '' && this.modelVersion !== '' &&
workspaceInfo.version !== undefined && this.modelVersion !== versionToString(wsVersion) &&
this.modelVersion !== versionToString(workspaceInfo.version) &&
token.extra?.model !== 'upgrade' && token.extra?.model !== 'upgrade' &&
token.extra?.mode !== 'backup' token.extra?.mode !== 'backup'
) { ) {
ctx.warn('Model version mismatch', { ctx.warn('Model version mismatch', {
version: this.modelVersion, version: this.modelVersion,
workspaceVersion: versionToString(workspaceInfo.version), workspaceVersion: versionToString(wsVersion),
workspace: workspaceInfo.uuid, workspace: workspaceInfo.uuid,
workspaceUrl: workspaceInfo.url, workspaceUrl: workspaceInfo.url,
account: token.account, 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`)) const logger = opt.console ? ctxModelLogger : new FileModelLogger(path.join(opt.logs, `${ws.uuid}.log`))
ctx.info('---UPGRADING----', { ctx.info('---UPGRADING----', {
workspace: ws.uuid, workspace: ws.uuid,
workspaceVersion: ws.version, workspaceVersion,
requestedVersion: this.version, requestedVersion: this.version,
region: this.region region: this.region
}) })
@ -351,7 +356,7 @@ export class WorkspaceWorker {
) )
ctx.info('---UPGRADE-DONE---------', { ctx.info('---UPGRADE-DONE---------', {
workspace: ws.uuid, workspace: ws.uuid,
oldWorkspaceVersion: ws.version, oldWorkspaceVersion: workspaceVersion,
requestedVersion: this.version, requestedVersion: this.version,
region: this.region, region: this.region,
time: Date.now() - t time: Date.now() - t
@ -367,7 +372,7 @@ export class WorkspaceWorker {
ctx.error('---UPGRADE-FAILED---------', { ctx.error('---UPGRADE-FAILED---------', {
workspace: ws.uuid, workspace: ws.uuid,
oldWorkspaceVersion: ws.version, oldWorkspaceVersion: workspaceVersion,
requestedVersion: this.version, requestedVersion: this.version,
region: this.region, region: this.region,
time: Date.now() - t time: Date.now() - t

View File

@ -234,14 +234,19 @@ export async function upgradeWorkspaceWith (
external: boolean = false external: boolean = false
): Promise<void> { ): Promise<void> {
const versionStr = versionToString(version) 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 return
} }
ctx.info('upgrading', { ctx.info('upgrading', {
force: forceUpdate, force: forceUpdate,
currentVersion: ws?.version !== undefined ? versionToString(ws.version) : '', currentVersion: versionToString(workspaceVersion),
toVersion: versionStr, toVersion: versionStr,
workspace: ws.uuid workspace: ws.uuid
}) })