diff --git a/frontend/src/concepts/pipelines/context/useManageElyraSecret.ts b/frontend/src/concepts/pipelines/context/useManageElyraSecret.ts index c703e519df..8bed1d5b77 100644 --- a/frontend/src/concepts/pipelines/context/useManageElyraSecret.ts +++ b/frontend/src/concepts/pipelines/context/useManageElyraSecret.ts @@ -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, @@ -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, diff --git a/frontend/src/concepts/pipelines/elyra/const.ts b/frontend/src/concepts/pipelines/elyra/const.ts index 24c250aad9..7db530787f 100644 --- a/frontend/src/concepts/pipelines/elyra/const.ts +++ b/frontend/src/concepts/pipelines/elyra/const.ts @@ -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}`; diff --git a/frontend/src/concepts/pipelines/elyra/utils.ts b/frontend/src/concepts/pipelines/elyra/utils.ts index 2888c5253e..66f761dcd6 100644 --- a/frontend/src/concepts/pipelines/elyra/utils.ts +++ b/frontend/src/concepts/pipelines/elyra/utils.ts @@ -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, @@ -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]),