-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #5729 We failed retrying WebsocketError during Pod exec operations, because the regex "WebsocketError: Unexpected server response" did not match anymore after we refactored toKubernetesError, because the formatting cahnged. Let's retry if just the name WebsocketError appears in the message.
- Loading branch information
Showing
4 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2018-2023 Garden Technologies, Inc. <info@garden.io> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
import { KubernetesError } from "../../../../../src/plugins/kubernetes/api.js" | ||
import type { ErrorEvent, WebSocket } from "ws" | ||
import { shouldRetry, toKubernetesError } from "../../../../../src/plugins/kubernetes/retry.js" | ||
import { expect } from "chai" | ||
import dedent from "dedent" | ||
|
||
const testKubeOp = "test" | ||
const websocketError: ErrorEvent = { | ||
error: new Error("error message"), | ||
message: "This is a test error message", | ||
type: "error", | ||
target: true as unknown as WebSocket, | ||
} | ||
|
||
describe("toKubernetesError", () => { | ||
it("should handle WebsocketError", () => { | ||
const err = toKubernetesError(websocketError, testKubeOp) | ||
|
||
expect(err).to.be.instanceof(KubernetesError) | ||
expect(err.message).to.equal(dedent` | ||
Error while performing Kubernetes API operation test: WebsocketError | ||
This is a test error message | ||
`) | ||
expect(err.responseStatusCode).to.be.undefined | ||
expect(err.apiMessage).to.be.undefined | ||
expect(err.type).to.equal("kubernetes") | ||
}) | ||
}) | ||
|
||
describe("shouldRetry", () => { | ||
it("should retry WebsocketError", () => { | ||
expect(shouldRetry(websocketError, testKubeOp)).to.be.true | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.