Skip to content

Commit

Permalink
update err output when failed get logs (stolostron#3260)
Browse files Browse the repository at this point in the history
* update err output when failed get logs

Signed-off-by: Zhiwei Yin <[email protected]>

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

Co-authored-by: Oliver Fischer <[email protected]>
Signed-off-by: Zhiwei Yin <[email protected]>

* Use Trans component to translate and format error message

Signed-off-by: Kevin Cormier <[email protected]>

---------

Signed-off-by: Zhiwei Yin <[email protected]>
Signed-off-by: Kevin Cormier <[email protected]>
Co-authored-by: Oliver Fischer <[email protected]>
Co-authored-by: Kevin Cormier <[email protected]>
  • Loading branch information
3 people authored Feb 8, 2024
1 parent 72d8bfa commit 3f7beb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
"access.users": "Users",
"access.usersInGroup": "Users in group",
"access.usersInGroup.view": "View users in group",
"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.",
"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.",
"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.",
"Action": "Action",
Expand Down
20 changes: 6 additions & 14 deletions frontend/src/routes/Home/Search/Details/LogsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {
} from '@patternfly/react-core'
import { CompressIcon, DownloadIcon, ExpandIcon, OutlinedWindowRestoreIcon } from '@patternfly/react-icons'
import { LogViewer } from '@patternfly/react-log-viewer'
import { Dispatch, MutableRefObject, SetStateAction, useEffect, useMemo, useRef, useState } from 'react'
import { Dispatch, MutableRefObject, ReactNode, SetStateAction, useEffect, useMemo, useRef, useState } from 'react'
import screenfull from 'screenfull'
import { useTranslation } from '../../../../lib/acm-i18next'
import { DOC_BASE_PATH } from '../../../../lib/doc-util'
import { fetchRetry, getBackendUrl, ManagedCluster } from '../../../../resources'
import { Trans, useTranslation } from '../../../../lib/acm-i18next'
import { fetchRetry, getBackendUrl } from '../../../../resources'
import { useRecoilValue, useSharedAtoms } from '../../../../shared-recoil'
import { AcmAlert, AcmLoadingPage } from '../../../../ui-components'
import { LogViewerSearch } from './LogsViewerSearch'
Expand Down Expand Up @@ -297,7 +296,7 @@ export default function LogsPage(props: {
const { t } = useTranslation()
const [isLoadingLogs, setIsLoadingLogs] = useState<boolean>(false)
const [logs, setLogs] = useState<string>('')
const [logsError, setLogsError] = useState<string>()
const [logsError, setLogsError] = useState<ReactNode>()
const [container, setContainer] = useState<string>(sessionStorage.getItem(`${name}-${cluster}-container`) || '')

const [showJumpToBottomBtn, setShowJumpToBottomBtn] = useState<boolean>(false)
Expand Down Expand Up @@ -372,15 +371,8 @@ export default function LogsPage(props: {
setIsLoadingLogs(false)
})
.catch((err) => {
const managedCluster = managedClusters.find(
(mc: ManagedCluster) => /* istanbul ignore next */ mc.metadata?.name === cluster
)
const labels = managedCluster?.metadata?.labels ?? {}
const vendor = labels['vendor'] ?? ''
if (err.code === 400 && vendor.toLowerCase() !== 'openshift') {
setLogsError(
`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`
)
if (err.code === 400) {
setLogsError(<Trans i18nKey="acm.logs.error" components={{ code: <code /> }} />)
} else {
setLogsError(err.message)
}
Expand Down

0 comments on commit 3f7beb3

Please sign in to comment.