mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Enabled Azure Arc data controller upgrade for direct and indirect mode (#19060)
* Fixed a connect to Server typo * Added upgrade tab with description and title. Table is still stuck loading. * Renamed backups to upgrades. * Removed loading icon * Table appearing and not stuck loading * Saving for now to upgrade arc and azcli versions * Added upgrade confirmation dialog, populated dummy data and added upgrade apis. * Added parsing of versions and current version from listupgrades * Upgrade itself not working, but added upgrade as a part of azure cli api. * Table now populating with release dates and version numbers. Upgrade button only shows for appropriate cells. Upgrade done but no release version column. * Changed text using PM advice * Removed comments from controllerUpgrades.ts * Replaced code in upgradecontroller.ts and made refresh work * Removed one call to handleTablesUpdated * Removed some code in upgradeControllers.ts and it still works * removing more code for pitr refresh from upgradeController.ts * Created and used UpgradeModel even though it is empty * Added upgrademodel * PR comments addressed Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -54,6 +54,23 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
validateAz(azToolService.localAz);
|
||||
return azToolService.localAz!.arcdata.dc.config.show(namespace, additionalEnvVars);
|
||||
}
|
||||
},
|
||||
listUpgrades: async (namespace: string, usek8s?: boolean, additionalEnvVars?: azExt.AdditionalEnvVars) => {
|
||||
await localAzDiscovered;
|
||||
validateAz(azToolService.localAz);
|
||||
return azToolService.localAz!.arcdata.dc.listUpgrades(namespace, usek8s, additionalEnvVars);
|
||||
},
|
||||
upgrade: async (
|
||||
desiredVersion: string,
|
||||
name: string,
|
||||
resourceGroup?: string,
|
||||
namespace?: string,
|
||||
usek8s?: boolean,
|
||||
additionalEnvVars?: azExt.AdditionalEnvVars
|
||||
) => {
|
||||
await localAzDiscovered;
|
||||
validateAz(azToolService.localAz);
|
||||
return azToolService.localAz!.arcdata.dc.upgrade(desiredVersion, name, resourceGroup, namespace, usek8s, additionalEnvVars);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -90,6 +90,37 @@ export class AzTool implements azExt.IAzApi {
|
||||
show: (namespace: string, additionalEnvVars?: azExt.AdditionalEnvVars): Promise<azExt.AzOutput<azExt.DcConfigShowResult>> => {
|
||||
return this.executeCommand<azExt.DcConfigShowResult>(['arcdata', 'dc', 'config', 'show', '--k8s-namespace', namespace, '--use-k8s'], additionalEnvVars);
|
||||
}
|
||||
},
|
||||
listUpgrades: async (namespace: string, usek8s?: boolean, additionalEnvVars?: azExt.AdditionalEnvVars): Promise<azExt.AzOutput<azExt.DcListUpgradesResult>> => {
|
||||
const argsArray = ['arcdata', 'dc', 'list-upgrades'];
|
||||
if (namespace) { argsArray.push('--k8s-namespace', namespace); }
|
||||
if (usek8s) { argsArray.push('--use-k8s'); }
|
||||
|
||||
const output = await this.executeCommand<string>(argsArray, additionalEnvVars);
|
||||
const versions = <string[]>parseDcListUpgrades(output.stdout);
|
||||
const currentVersion = <string>parseCurrentVersion(output.stdout);
|
||||
let dates: string[] = [];
|
||||
for (let i = 0; i < versions.length; i++) {
|
||||
dates.push(parseReleaseDateFromUpgrade(versions[i]));
|
||||
}
|
||||
return {
|
||||
stdout: {
|
||||
versions: versions,
|
||||
currentVersion: currentVersion,
|
||||
dates: dates
|
||||
},
|
||||
stderr: output.stderr
|
||||
};
|
||||
},
|
||||
upgrade: (desiredVersion: string, name: string, resourceGroup?: string, namespace?: string, usek8s?: boolean, additionalEnvVars?: azExt.AdditionalEnvVars): Promise<azExt.AzOutput<void>> => {
|
||||
const argsArray = ['arcdata', 'dc', 'upgrade', '--desired-version', desiredVersion, '--name', name];
|
||||
// Direct mode argument
|
||||
if (resourceGroup) { argsArray.push('--resource-group', resourceGroup); }
|
||||
// Indirect mode arguments
|
||||
|
||||
if (namespace) { argsArray.push('--k8s-namespace', namespace); }
|
||||
if (usek8s) { argsArray.push('--use-k8s'); }
|
||||
return this.executeCommand<void>(argsArray, additionalEnvVars);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -556,6 +587,70 @@ function parseArcExtensionVersion(raw: string): string | undefined {
|
||||
return exp.exec(raw)?.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses out all available upgrades
|
||||
* @param raw The raw version output from az arcdata dc list-upgrades
|
||||
*/
|
||||
function parseDcListUpgrades(raw: string): string[] | undefined {
|
||||
// Currently the version is a multi-line string that contains other version information such
|
||||
// as the Python installation, with the first line holding the version of az itself.
|
||||
//
|
||||
// Found 6 valid versions. The current datacontroller version is v1.2.0_2021-12-15.
|
||||
// v1.4.1_2022-03-08
|
||||
// v1.4.0_2022-02-25
|
||||
// v1.3.0_2022-01-27
|
||||
// v1.2.0_2021-12-15 << current version
|
||||
// v1.1.0_2021-11-02
|
||||
// v1.0.0_2021-07-30
|
||||
let versions: string[] = [];
|
||||
const lines = raw.split('\n');
|
||||
const exp = /^(v\d*.\d*.\d*.\d*.\d*.\d*.\d)/;
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
let result = exp.exec(lines[i])?.pop();
|
||||
if (result) {
|
||||
versions.push(result);
|
||||
}
|
||||
}
|
||||
return versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses out the release date from the upgrade version number and formats it into MM/DD/YYYY format.
|
||||
* For example: v1.4.1_2022-03-08 ==> 03/08/2022
|
||||
* @param raw The raw upgrade version number, such as: v1.4.1_2022-03-08
|
||||
*/
|
||||
function parseReleaseDateFromUpgrade(raw: string): string {
|
||||
let formattedDate = '';
|
||||
const exp = /^v\d*.\d*.\d*_(\d*).(\d*).(\d*.\d)/;
|
||||
let rawDate = exp.exec(raw);
|
||||
if (rawDate) {
|
||||
formattedDate += rawDate[2] + '/' + rawDate[3] + '/' + rawDate[1];
|
||||
} else {
|
||||
console.error(loc.releaseDateNotParsed);
|
||||
}
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses out the current version number out of all available upgrades
|
||||
* @param raw The raw version output from az arcdata dc list-upgrades
|
||||
*/
|
||||
function parseCurrentVersion(raw: string): string | undefined {
|
||||
// Currently the version is a multi-line string that contains other version information such
|
||||
// as the Python installation, with the first line holding the version of az itself.
|
||||
//
|
||||
// Found 6 valid versions. The current datacontroller version is v1.2.0_2021-12-15.
|
||||
// v1.4.1_2022-03-08
|
||||
// v1.4.0_2022-02-25
|
||||
// v1.3.0_2022-01-27
|
||||
// v1.2.0_2021-12-15 << current version
|
||||
// v1.1.0_2021-11-02
|
||||
// v1.0.0_2021-07-30
|
||||
|
||||
const exp = /The current datacontroller version is\s*(v\d*.\d*.\d*.\d*.\d*.\d*.\d)/;
|
||||
return exp.exec(raw)?.pop();
|
||||
}
|
||||
|
||||
async function executeAzCommand(command: string, args: string[], additionalEnvVars: azExt.AdditionalEnvVars = {}): Promise<ProcessOutput> {
|
||||
const debug = vscode.workspace.getConfiguration(azConfigSection).get(debugConfigKey);
|
||||
if (debug) {
|
||||
|
||||
@@ -72,3 +72,4 @@ export const userResponseToInstallPrompt = (response: string | undefined): strin
|
||||
export const userResponseToUpdatePrompt = (response: string | undefined): string => localize('az.userResponseUpdate', "User Response on prompt to update Azure CLI: {0}", response);
|
||||
export const userRequestedInstall = localize('az.userRequestedInstall', "User requested to install Azure CLI and arcdata extension using 'Azure CLI: Install' command");
|
||||
export const updateCheckSkipped = localize('az.updateCheckSkipped', "No check for new Azure CLI version availability performed as Azure CLI was not found to be installed");
|
||||
export const releaseDateNotParsed = localize('arc.releaseDateNotParsed', "Release date could not be parsed.");
|
||||
|
||||
10
extensions/azcli/src/typings/az-ext.d.ts
vendored
10
extensions/azcli/src/typings/az-ext.d.ts
vendored
@@ -116,6 +116,12 @@ declare module 'az-ext' {
|
||||
}
|
||||
}
|
||||
|
||||
export interface DcListUpgradesResult {
|
||||
versions: string[], // ["v1.4.1_2022-03-08", "v1.4.0_2022-02-25"]
|
||||
currentVersion: string, // "v1.4.1_2022-03-08"
|
||||
dates: string[] // ["03/08/2022", "02/25/2022"]
|
||||
}
|
||||
|
||||
export interface StorageVolume {
|
||||
className?: string, // "local-storage"
|
||||
size: string // "5Gi"
|
||||
@@ -332,7 +338,9 @@ declare module 'az-ext' {
|
||||
config: {
|
||||
list(additionalEnvVars?: AdditionalEnvVars): Promise<AzOutput<DcConfigListResult[]>>,
|
||||
show(namespace?: string, additionalEnvVars?: AdditionalEnvVars): Promise<AzOutput<DcConfigShowResult>>
|
||||
}
|
||||
},
|
||||
listUpgrades(namespace: string, usek8s?: boolean, additionalEnvVars?: AdditionalEnvVars): Promise<AzOutput<DcListUpgradesResult>>,
|
||||
upgrade(desiredVersion: string, name: string, resourceGroup?: string, namespace?: string, usek8s?: boolean, additionalEnvVars?: AdditionalEnvVars): Promise<AzOutput<void>>,
|
||||
}
|
||||
},
|
||||
postgres: {
|
||||
|
||||
Reference in New Issue
Block a user