Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No retry option should disable retry policy #1064

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/common/models/cluster/cluster.mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { expect, use } from "chai";
import equivalent from "../../../client/utils/test-utils/equivalent";
import { RequestDecorator } from "../../../server/utils/request-decorator/request-decorator";
import { RetryOptions } from "../../../server/utils/retry-options/retry-options";
import { RetryOptions, RetryOptionsJS } from "../../../server/utils/retry-options/retry-options";
import { NOOP_LOGGER } from "../../logger/logger";
import { ClusterAuthJS } from "../cluster-auth/cluster-auth";
import { Cluster, ClusterJS, fromConfig } from "./cluster";
Expand Down Expand Up @@ -48,7 +48,7 @@ describe("Cluster", () => {
healthCheckTimeout: 1000,
introspectionStrategy: "segment-metadata-fallback",
requestDecorator: null,
retry: new RetryOptions(),
retry: undefined,
sourceListRefreshInterval: 0,
sourceListRefreshOnLoad: false,
sourceListScan: "auto",
Expand Down Expand Up @@ -119,6 +119,16 @@ describe("Cluster", () => {
expect(cluster.retry).to.be.equivalent(new RetryOptions({ maxAttempts: 1, delay: 42 }));
});

it("should read partial retry options", () => {
const cluster = buildCluster({
retry: {
delay: 42
} as RetryOptionsJS
});

expect(cluster.retry).to.be.equivalent(new RetryOptions({ maxAttempts: 5, delay: 42 }));
});

it("should read request decorator", () => {
const cluster = buildCluster({
name: "foobar",
Expand Down Expand Up @@ -185,7 +195,7 @@ describe("Cluster", () => {
version: "new-version",
type: "druid",
requestDecorator: null,
retry: new RetryOptions(),
retry: undefined,
auth: undefined
});
});
Expand Down
7 changes: 6 additions & 1 deletion src/common/models/cluster/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ function readRequestDecorator(cluster: any, logger: Logger): RequestDecorator |
return null;
}

function readRetryOptions(options: RetryOptionsJS | undefined): RetryOptions | undefined {
if (isNil(options)) return undefined;
return new RetryOptions(options);
}

const DEFAULT_HEALTH_CHECK_TIMEOUT = 1000;
export const DEFAULT_SOURCE_LIST_SCAN: SourceListScan = "auto";
const SOURCE_LIST_SCAN_VALUES: SourceListScan[] = ["disable", "auto"];
Expand Down Expand Up @@ -167,7 +172,7 @@ export function fromConfig(params: ClusterJS, logger: Logger): Cluster {
const sourceReintrospectInterval = readInterval(params.sourceReintrospectInterval, DEFAULT_SOURCE_REINTROSPECT_INTERVAL);
const sourceListRefreshInterval = readInterval(params.sourceListRefreshInterval, DEFAULT_SOURCE_LIST_REFRESH_INTERVAL);
const sourceTimeBoundaryRefreshInterval = readInterval(params.sourceTimeBoundaryRefreshInterval, DEFAULT_SOURCE_TIME_BOUNDARY_REFRESH_INTERVAL);
const retry = RetryOptions.fromJS(params.retry);
const retry = readRetryOptions(params.retry);
const requestDecorator = readRequestDecorator(params, logger);
const auth = readClusterAuth(params.auth);

Expand Down
3 changes: 2 additions & 1 deletion src/server/utils/requester/requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ function setRetryOptions({ maxAttempts, delay }: RetryOptions) {
requester,
retry: maxAttempts,
delay,
retryOnTimeout: true });
retryOnTimeout: true
});
}

function setVerbose(requester: PlywoodRequester<any>) {
Expand Down