Skip to content

Commit 41944d8

Browse files
committed
#build
1 parent 2da21a9 commit 41944d8

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

src/matches/match-assistant/match-assistant.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ describe("MatchAssistantService", () => {
7373
.spyOn(service, "delayCheckOnDemandServer")
7474
.mockResolvedValue(undefined);
7575

76-
await expect(service.rebootOnDemandServer("match-1")).resolves.toBeUndefined();
76+
await expect(
77+
service.rebootOnDemandServer("match-1"),
78+
).resolves.toBeUndefined();
7779

7880
expect(setServerError).toHaveBeenCalledWith("match-1", null);
7981
expect(assignOnDemandServer).toHaveBeenCalledWith("match-1", {
@@ -147,9 +149,7 @@ describe("MatchAssistantService", () => {
147149
});
148150

149151
jest.spyOn(service as any, "setServerError").mockResolvedValue(undefined);
150-
jest
151-
.spyOn(service as any, "assignOnDemandServer")
152-
.mockResolvedValue(false);
152+
jest.spyOn(service as any, "assignOnDemandServer").mockResolvedValue(false);
153153

154154
await expect(service.rebootOnDemandServer("match-1")).rejects.toThrow(
155155
"no on demand servers are available to reboot this match",

src/matches/match-assistant/match-assistant.service.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,28 @@ export class MatchAssistantService {
10851085
this.logger.verbose(`[${matchId}] remove pod`);
10861086

10871087
if (!remove) {
1088-
await new Exec(kc).exec(
1089-
this.namespace,
1090-
pod.metadata!.name!,
1091-
pod.spec!.containers?.at(0)?.name,
1092-
["kill", "-SIGUSR1", "1"],
1093-
process.stdout,
1094-
process.stderr,
1095-
process.stdin,
1096-
false,
1097-
);
1088+
// Only Running pods accept exec; anything else (Succeeded / Failed /
1089+
// Pending) responds 400 to the upgrade request. Skip those — there's
1090+
// nothing to signal.
1091+
if (pod.status?.phase !== "Running") {
1092+
continue;
1093+
}
1094+
try {
1095+
await new Exec(kc).exec(
1096+
this.namespace,
1097+
pod.metadata!.name!,
1098+
pod.spec!.containers?.at(0)?.name,
1099+
["kill", "-SIGUSR1", "1"],
1100+
process.stdout,
1101+
process.stderr,
1102+
process.stdin,
1103+
false,
1104+
);
1105+
} catch (error) {
1106+
this.logger.warn(
1107+
`[${matchId}] graceful shutdown signal failed: ${error?.message || "exec error"}`,
1108+
);
1109+
}
10981110
continue;
10991111
}
11001112
await core

src/matches/matches.controller.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ export class MatchesController {
452452
/**
453453
* Server was removed from match
454454
*/
455-
if (data.old.server_id && !data.new.server_id || data.old.server_id !== data.new.server_id) {
455+
if (
456+
(data.old.server_id && !data.new.server_id) ||
457+
data.old.server_id !== data.new.server_id
458+
) {
456459
await this.matchAssistant.stopOnDemandServer(matchId);
457460
}
458461

@@ -479,7 +482,8 @@ export class MatchesController {
479482
}
480483

481484
if (
482-
(status === "Live" && data.old.status !== "WaitingForServer") ||
485+
(status === "Live" &&
486+
(!match.server || data.old.status !== "WaitingForServer")) ||
483487
(status === "WaitingForServer" &&
484488
data.old.server_id !== data.new.server_id)
485489
) {
@@ -1539,4 +1543,4 @@ export class MatchesController {
15391543

15401544
await this.matchAssistant.sendServerMatchId(match.id);
15411545
}
1542-
}
1546+
}

0 commit comments

Comments
 (0)