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

Revert fec931 #1535

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
3 changes: 3 additions & 0 deletions backend/src/routes/api/prometheus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { callPrometheusThanos } from '../../../utils/prometheusUtils';
import { createCustomError } from '../../../utils/requestUtils';
import { logRequestDetails } from '../../../utils/fileUtils';
import { THANOS_DEFAULT_ADMIN_PORT } from '../../../utils/constants';

const handleError = (e: createError.HttpError) => {
if (e?.code) {
Expand Down Expand Up @@ -56,6 +57,7 @@ module.exports = async (fastify: KubeFastifyInstance) => {
request,
query,
QueryType.QUERY_RANGE,
THANOS_DEFAULT_ADMIN_PORT,
).catch(handleError);
},
);
Expand All @@ -75,6 +77,7 @@ module.exports = async (fastify: KubeFastifyInstance) => {
request,
query,
QueryType.QUERY_RANGE,
THANOS_DEFAULT_ADMIN_PORT,
).catch(handleError);
},
);
Expand Down
5 changes: 5 additions & 0 deletions backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ export const DEFAULT_NOTEBOOK_SIZES: NotebookSize[] = [

export const imageUrlRegex =
/^([\w.\-_]+((?::\d+|)(?=\/[a-z0-9._-]+\/[a-z0-9._-]+))|)(?:\/|)([a-z0-9.\-_]+(?:\/[a-z0-9.\-_]+|))(?::([\w.\-_]{1,127})|)/;

export const THANOS_DEFAULT_RBAC_PORT = '9092';

// NOTE: This port only works for cluster-admins, it won't work for basic users - regardless of namespace privs.
export const THANOS_DEFAULT_ADMIN_PORT = '9091';
5 changes: 3 additions & 2 deletions backend/src/utils/prometheusUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PrometheusQueryRangeResponse,
QueryType,
} from '../types';
import { DEV_MODE } from './constants';
import { DEV_MODE, THANOS_DEFAULT_RBAC_PORT } from './constants';
import { getNamespaces } from './notebookUtils';
import { getDashboardConfig } from './resourceUtils';
import { createCustomError } from './requestUtils';
Expand Down Expand Up @@ -88,12 +88,13 @@ export const callPrometheusThanos = <T>(
request: OauthFastifyRequest,
query: string,
queryType: QueryType = QueryType.QUERY,
port = THANOS_DEFAULT_RBAC_PORT,
): Promise<{ code: number; response: T }> =>
callPrometheus<T>(
fastify,
request,
query,
generatePrometheusHostURL(fastify, 'thanos-querier', 'openshift-monitoring', '9092'),
generatePrometheusHostURL(fastify, 'thanos-querier', 'openshift-monitoring', port),
queryType,
);

Expand Down
Loading