Skip to content

Commit 3f7beb3

Browse files
zhiweiyin318oafischerKevinFCormier
authored
update err output when failed get logs (stolostron#3260)
* update err output when failed get logs Signed-off-by: Zhiwei Yin <zyin@redhat.com> * Update frontend/src/routes/Home/Search/Details/LogsPage.tsx Co-authored-by: Oliver Fischer <ofischer@redhat.com> Signed-off-by: Zhiwei Yin <zyin@redhat.com> * Use Trans component to translate and format error message Signed-off-by: Kevin Cormier <kcormier@redhat.com> --------- Signed-off-by: Zhiwei Yin <zyin@redhat.com> Signed-off-by: Kevin Cormier <kcormier@redhat.com> Co-authored-by: Oliver Fischer <ofischer@redhat.com> Co-authored-by: Kevin Cormier <kcormier@redhat.com>
1 parent 72d8bfa commit 3f7beb3

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

frontend/public/locales/en/translation.json

+1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@
371371
"access.users": "Users",
372372
"access.usersInGroup": "Users in group",
373373
"access.usersInGroup.view": "View users in group",
374+
"acm.logs.error": "Red Hat Advanced Cluster Management version 2.10 and newer requires the <code>cluster-proxy</code> and <code>managed-serviceaccount</code> add-ons to retrieve logs. Make sure that these add-ons are enabled on the hub cluster.",
374375
"acm.plugin.not.ready": "The <bold>Red Hat Advanced Cluster Management for Kubernetes</bold> operator is installed, but the console plugin is not available. If you just completed the installation procedure within the last few minutes, wait a few moments for a web console update alert to appear. Click the link in the alert to refresh the web console to the latest version.",
375376
"acm.plugin.not.ready.tips": "If the alert does not appear, confirm that a <code>MultiClusterHub</code> resource has been created and is available, and that the <code>acm</code> console plugin is enabled.",
376377
"Action": "Action",

frontend/src/routes/Home/Search/Details/LogsPage.tsx

+6-14
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ import {
1414
} from '@patternfly/react-core'
1515
import { CompressIcon, DownloadIcon, ExpandIcon, OutlinedWindowRestoreIcon } from '@patternfly/react-icons'
1616
import { LogViewer } from '@patternfly/react-log-viewer'
17-
import { Dispatch, MutableRefObject, SetStateAction, useEffect, useMemo, useRef, useState } from 'react'
17+
import { Dispatch, MutableRefObject, ReactNode, SetStateAction, useEffect, useMemo, useRef, useState } from 'react'
1818
import screenfull from 'screenfull'
19-
import { useTranslation } from '../../../../lib/acm-i18next'
20-
import { DOC_BASE_PATH } from '../../../../lib/doc-util'
21-
import { fetchRetry, getBackendUrl, ManagedCluster } from '../../../../resources'
19+
import { Trans, useTranslation } from '../../../../lib/acm-i18next'
20+
import { fetchRetry, getBackendUrl } from '../../../../resources'
2221
import { useRecoilValue, useSharedAtoms } from '../../../../shared-recoil'
2322
import { AcmAlert, AcmLoadingPage } from '../../../../ui-components'
2423
import { LogViewerSearch } from './LogsViewerSearch'
@@ -297,7 +296,7 @@ export default function LogsPage(props: {
297296
const { t } = useTranslation()
298297
const [isLoadingLogs, setIsLoadingLogs] = useState<boolean>(false)
299298
const [logs, setLogs] = useState<string>('')
300-
const [logsError, setLogsError] = useState<string>()
299+
const [logsError, setLogsError] = useState<ReactNode>()
301300
const [container, setContainer] = useState<string>(sessionStorage.getItem(`${name}-${cluster}-container`) || '')
302301

303302
const [showJumpToBottomBtn, setShowJumpToBottomBtn] = useState<boolean>(false)
@@ -372,15 +371,8 @@ export default function LogsPage(props: {
372371
setIsLoadingLogs(false)
373372
})
374373
.catch((err) => {
375-
const managedCluster = managedClusters.find(
376-
(mc: ManagedCluster) => /* istanbul ignore next */ mc.metadata?.name === cluster
377-
)
378-
const labels = managedCluster?.metadata?.labels ?? {}
379-
const vendor = labels['vendor'] ?? ''
380-
if (err.code === 400 && vendor.toLowerCase() !== 'openshift') {
381-
setLogsError(
382-
`Non-OpenShift Container Platform clusters require LoadBalancer to be enabled to retrieve logs. Follow the steps here to complete LoadBalancer setup: ${DOC_BASE_PATH}/release_notes/red-hat-advanced-cluster-management-for-kubernetes-release-notes#non-ocp-logs`
383-
)
374+
if (err.code === 400) {
375+
setLogsError(<Trans i18nKey="acm.logs.error" components={{ code: <code /> }} />)
384376
} else {
385377
setLogsError(err.message)
386378
}

0 commit comments

Comments
 (0)