Skip to content

Commit

Permalink
chore: retryCondition now handles AlreadyExists.
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed Jun 21, 2024
1 parent f85e2df commit 8b84e65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/kubekit-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kubekit/client",
"version": "0.2.21",
"version": "0.2.23",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "kahirokunn",
Expand Down
4 changes: 2 additions & 2 deletions packages/kubekit-client/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Agent } from 'undici';
import { ReadableStream, TransformStream } from 'node:stream/web';
import { type ObjectReference } from '../lib/types';
import { KubeConfig } from '../lib/config';
import { KubernetesError, isKubernetesError, isTooLargeResourceVersion } from '../lib/error';
import { KubernetesError, isAlreadyExists, isKubernetesError, isTooLargeResourceVersion } from '../lib/error';
import { sleep } from '../lib/sleep';
export { sleep } from '../lib/sleep';
export { TaskManager } from '../lib/task_manager';
Expand Down Expand Up @@ -153,7 +153,7 @@ export const defaultRetryCondition: RetryConditionFunction = ({ ...object }) =>
return false;
}

if (isKubernetesError(error) && isTooLargeResourceVersion(error)) {
if (isKubernetesError(error) && (isTooLargeResourceVersion(error) || isAlreadyExists(error))) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/kubekit-client/src/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ export function isKubernetesError(obj: unknown): obj is KubernetesError {
export function isTooLargeResourceVersion(err: KubernetesError) {
return err.message.includes('Too large resource version');
}

export function isAlreadyExists(err: KubernetesError) {
return err.reason === 'AlreadyExists';
}

0 comments on commit 8b84e65

Please sign in to comment.