Skip to content

Commit

Permalink
Merge pull request #1461 from mlassak/fix/incorrect-elyra-redirect
Browse files Browse the repository at this point in the history
Change Elyra public API endpoint to ensure a correct URL for redirect
  • Loading branch information
openshift-merge-robot authored Jul 14, 2023
2 parents 4af4471 + 0ac1dbf commit 672b772
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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

0 comments on commit 672b772

Please sign in to comment.