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

Change Elyra public API endpoint to ensure a correct URL for redirect #1461

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
17 changes: 13 additions & 4 deletions frontend/src/concepts/pipelines/context/useManageElyraSecret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { createSecret, replaceSecret } from '~/api';
import { DSPipelineKind } from '~/k8sTypes';
import { generateElyraSecret } from '~/concepts/pipelines/elyra/utils';
import useAWSSecret from '~/concepts/secrets/apiHooks/useAWSSecret';
import { ELYRA_SECRET_DATA_KEY, ELYRA_SECRET_DATA_TYPE } from '~/concepts/pipelines/elyra/const';
import {
ELYRA_SECRET_DATA_ENDPOINT,
ELYRA_SECRET_DATA_KEY,
ELYRA_SECRET_DATA_TYPE,
} from '~/concepts/pipelines/elyra/const';

const useManageElyraSecret = (
namespace: string,
Expand Down Expand Up @@ -41,9 +45,14 @@ const useManageElyraSecret = (
return;
}
try {
const secretValue = JSON.parse(atob(elyraSecret.data?.[ELYRA_SECRET_DATA_KEY] || '{}'));
if (secretValue.metadata[ELYRA_SECRET_DATA_TYPE] === 'USER_CREDENTIALS') {
// Secret is invalid -- update it
const secretValue = JSON.parse(
atob(elyraSecret.data?.[ELYRA_SECRET_DATA_KEY] || '{ metadata: {} }'),
);
const usingOldDataType =
secretValue.metadata[ELYRA_SECRET_DATA_TYPE] === 'USER_CREDENTIALS';
const usingOldUrl = !secretValue.metadata[ELYRA_SECRET_DATA_ENDPOINT].endsWith('/view/');
if (usingOldDataType || usingOldUrl) {
// Secret is out of date, update it
replaceSecret(
generateElyraSecret(
dataConnection.data,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/concepts/pipelines/elyra/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { PIPELINE_DEFINITION_NAME } from '~/concepts/pipelines/const';
export const ELYRA_SECRET_NAME = 'ds-pipeline-config';
export const ELYRA_SECRET_DATA_KEY = 'odh_dsp.json';
export const ELYRA_SECRET_DATA_TYPE = 'cos_auth_type';
export const ELYRA_SECRET_DATA_ENDPOINT = 'public_api_endpoint';
export const ELYRA_ROLE_NAME = `ds-pipeline-user-access-${PIPELINE_DEFINITION_NAME}`;
4 changes: 3 additions & 1 deletion frontend/src/concepts/pipelines/elyra/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Patch } from '@openshift/dynamic-plugin-sdk-utils';
import { AWSSecretKind, KnownLabels, NotebookKind, RoleBindingKind, SecretKind } from '~/k8sTypes';
import {
ELYRA_ROLE_NAME,
ELYRA_SECRET_DATA_ENDPOINT,
ELYRA_SECRET_DATA_KEY,
ELYRA_SECRET_DATA_TYPE,
ELYRA_SECRET_NAME,
Expand Down Expand Up @@ -63,7 +64,8 @@ export const generateElyraSecret = (
engine: 'Tekton',
auth_type: 'KUBERNETES_SERVICE_ACCOUNT_TOKEN',
api_endpoint: route,
public_api_endpoint: `${location.origin}/pipelineRuns/${namespace}`,
// Append the id on the end to navigate to the details page for that PipelineRun
[ELYRA_SECRET_DATA_ENDPOINT]: `${location.origin}/pipelineRuns/${namespace}/pipelineRun/view/`,
[ELYRA_SECRET_DATA_TYPE]: 'KUBERNETES_SECRET',
cos_secret: dataConnectionName,
cos_endpoint: atob(dataConnectionData[AWS_KEYS.S3_ENDPOINT]),
Expand Down
Loading