-
Notifications
You must be signed in to change notification settings - Fork 219
Non destructive upgrades in vscode #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aeisenberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a partial review. Looks good. Just some small things. I'll finish this off on Monday.
22770d2 to
5335a84
Compare
5335a84 to
3c81e06
Compare
3c81e06 to
2cc06d4
Compare
|
You comment have made me realise that we can simplify the queryserver api, but it will mean that we need to wait for another codeql release to get this in. |
c1d906c to
bff5e2f
Compare
|
Ok this should be ready for re-review. Sorry I was so slow at coming back to this. |
aeisenberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only major issue is the missing await clause. Everything else is just wording and naming changes.
| /** | ||
| * Compile an upgrade script to upgrade a dataset. | ||
| */ | ||
| export const compileUpgradeSequence = new rpc.RequestType<WithProgressId<CompileUpgradeSequenceParams>, CompiledUpgradeSequence, void, void>('compilation/compileUpgradeSequence'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our naming convention is usually XxxParams and XxxResult. Here it's CompileUpgradeSequenceParams and CompiledUpgradeSequence. Can you follow the same convention here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...and I see below that EvaluateQueriesParams and EvaluationComplete does not follow the convention either. I still think it's useful to do so in order to know how these two interfaces are related.
I may fix that in a later PR.
| } | ||
|
|
||
| function reportNoUpgradePath(query: QueryInfo) { | ||
| throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace. Please try using a newer version of the query libraries.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Consider emphasizing the proposed solution so it's not hidden in a wall of text.
| throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace. Please try using a newer version of the query libraries.`); | |
| throw new Error(`Query ${query.program.queryPath} expects database scheme ${query.queryDbscheme}, but the current database has a different scheme, and no database upgrades are available. The current database scheme may be newer than the CodeQL query libraries in your workspace.\n\nPlease try using a newer version of the query libraries.`); |
| await checkDbschemeCompatibility(cliServer, qs, query, progress, token); | ||
|
|
||
| let errors; | ||
| const upgradeDir = tmp.dirSync({ dir: upgradesTmpDir.name }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using sync functions in user code. You can use the tmp-promise package to make an async call to creating a tmp directory. After changing the import statement, all you need to do is this:
| const upgradeDir = tmp.dirSync({ dir: upgradesTmpDir.name }); | |
| const upgradeDir = await tmp.dir({ dir: upgradesTmpDir.name }); |
| if (result.resultType !== messages.QueryResultType.SUCCESS) { | ||
| const message = result.message || 'Failed to run query'; | ||
| logger.log(message); | ||
| helpers.showAndLogErrorMessage(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should already be imported directly.
| helpers.showAndLogErrorMessage(message); | |
| showAndLogErrorMessage(message); |
extensions/ql-vscode/src/upgrades.ts
Outdated
| } | ||
| finally { | ||
| qs.logger.log('Done checking database upgrade.'); | ||
| if (!hasNondestructiveUpgradeCapabilities(qs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice...code scanning worked here. This expression needs an await.
extensions/ql-vscode/src/upgrades.ts
Outdated
| finally { | ||
| qs.logger.log('Done checking database upgrade.'); | ||
| if (!hasNondestructiveUpgradeCapabilities(qs)) { | ||
| throw new Error('The version of codeql is to old to run non-destructive upgrades.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new Error('The version of codeql is to old to run non-destructive upgrades.'); | |
| throw new Error('The version of codeql is to old too run non-destructive upgrades.'); |
| db: DatabaseItem, | ||
| resolvedSequence: string[], | ||
| currentUpgradeTmp: tmp.DirResult, | ||
| currentUpgradeTmp: tmp.DirectoryResult, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that the type names were slightly different.


This depends on a rebased copy of #639 and also on some unreleased cli features and shouldn't be merged until we know which version they will be released in.
This PR makes us use silent non-destructive upgrades. It also refactors the current upgrade mechanism in places so we have slightly fewer code paths.
There are a few identation changes so you may want to add
?w=1to the url when reviewing to ignore those changes.