Skip to content

Commit b564d89

Browse files
laurenastrid1Lauren Nathan
andauthored
Temp fix for linux and mac sql server 2025 image (#19918) (#19976)
* temp fix for linux and mac sql server 2025 image * check for arm mac * added latest to string; remove uneccessary state updates in form validation * fix broken test * pr comments --------- Co-authored-by: Lauren Nathan <[email protected]>
1 parent 20ebe8e commit b564d89

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/containerDeployment/containerDeploymentWebviewController.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@ export class ContainerDeploymentWebviewController extends FormWebviewController<
9797
private registerRpcHandlers() {
9898
this.registerReducer("formAction", async (state, payload) => {
9999
(state.formState as any)[payload.event.propertyName] = payload.event.value;
100-
this.updateState(state);
101100

102101
const newState = await this.validateDockerConnectionProfile(
103102
state,
104103
this.state.formState,
105104
payload.event.propertyName,
106105
);
107-
this.updateState(newState);
108106
return newState;
109107
});
110108
this.registerReducer("completeDockerStep", async (state, payload) => {

src/containerDeployment/dockerUtils.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ export const COMMANDS = {
8686
GET_CONTAINERS: `docker ps -a --format "{{.ID}}"`,
8787
GET_CONTAINERS_BY_NAME: `docker ps -a --format "{{.Names}}"`,
8888
INSPECT: (id: string) => `docker inspect ${id}`,
89-
PULL_IMAGE: (version: string) => `docker pull mcr.microsoft.com/mssql/server:${version}-latest`,
89+
PULL_IMAGE: (versionTag: string) => `docker pull mcr.microsoft.com/mssql/server:${versionTag}`,
9090
START_SQL_SERVER: (
9191
name: string,
9292
password: string,
9393
port: number,
94-
version: string,
94+
versionTag: string,
9595
hostname: string,
9696
) =>
97-
`docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${password}" -p ${port}:${defaultPortNumber} --name ${name} ${hostname ? `--hostname ${sanitizeContainerInput(hostname)}` : ""} -d mcr.microsoft.com/mssql/server:${version}-latest`,
97+
`docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${password}" -p ${port}:${defaultPortNumber} --name ${name} ${hostname ? `--hostname ${sanitizeContainerInput(hostname)}` : ""} -d mcr.microsoft.com/mssql/server:${versionTag}`,
9898
CHECK_CONTAINER_RUNNING: (name: string) =>
9999
`docker ps --filter "name=${sanitizeContainerInput(name)}" --filter "status=running" --format "{{.Names}}"`,
100100
VALIDATE_CONTAINER_NAME: 'docker ps -a --format "{{.Names}}"',
@@ -380,12 +380,25 @@ export async function getDockerPath(executable: string): Promise<string> {
380380
return "";
381381
}
382382

383+
/**
384+
* Temp fix for the SQL Server 2025 version issue on Mac.
385+
* Returns the last working version of SQL Server 2025 for Mac.
386+
*/
387+
export function constructVersionTag(version: string): string {
388+
let versionYear = version.substring(0, yearStringLength);
389+
// Hard Coded until this issue is fixed for mac: https://github.com/microsoft/mssql-docker/issues/940#issue
390+
if (platform() === Platform.Mac && arch() !== x64 && versionYear === "2025") {
391+
return "2025-CTP2.0-ubuntu-22.04"; // Last working version of SQL Server 2025 for Mac
392+
}
393+
return `${versionYear}-latest`;
394+
}
395+
383396
/**
384397
* Pulls the SQL Server container image for the specified version.
385398
*/
386399
export async function pullSqlServerContainerImage(version: string): Promise<DockerCommandParams> {
387400
try {
388-
await execCommand(COMMANDS.PULL_IMAGE(version.substring(0, yearStringLength)));
401+
await execCommand(COMMANDS.PULL_IMAGE(constructVersionTag(version)));
389402
return { success: true };
390403
} catch (e) {
391404
return {
@@ -410,7 +423,7 @@ export async function startSqlServerDockerContainer(
410423
containerName,
411424
password,
412425
port,
413-
version.substring(0, yearStringLength),
426+
constructVersionTag(version),
414427
hostname,
415428
);
416429
try {

test/unit/containerDeploymentWebviewController.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ suite("ContainerDeploymentWebviewController", () => {
293293
controller as any,
294294
"validateDockerConnectionProfile",
295295
);
296-
const updateStateSpy = sandbox.spy(controller as any, "updateState");
297296

298297
const callState = controller["state"];
299298

@@ -306,11 +305,6 @@ suite("ContainerDeploymentWebviewController", () => {
306305
});
307306

308307
assert.ok(validateProfileSpy.calledOnce, "profile validation should be called once");
309-
assert.ok(
310-
updateStateSpy.calledTwice,
311-
"updateState should be called once within formAction",
312-
);
313-
314308
assert.equal(newState.isValidContainerName, true);
315309
});
316310

0 commit comments

Comments
 (0)