diff --git a/workspaces/linkerd/plugins/linkerd/src/components/DependenciesCard.tsx b/workspaces/linkerd/plugins/linkerd/src/components/DependenciesCard.tsx index 8e41cd4c4..f2750eed8 100644 --- a/workspaces/linkerd/plugins/linkerd/src/components/DependenciesCard.tsx +++ b/workspaces/linkerd/plugins/linkerd/src/components/DependenciesCard.tsx @@ -7,6 +7,7 @@ import { Card, CardContent, CardHeader, + CircularProgress, Divider, makeStyles, Typography, @@ -32,9 +33,22 @@ const useStyles = makeStyles({ export const DependenciesCard = () => { const styles = useStyles(); const { entity } = useEntity(); - const { stats } = useStatsForEntity(entity); + const { stats, loading } = useStatsForEntity(entity); const content = () => { + if (!stats && loading) { + return ; + } + + if (!stats || !stats.current || !stats.current.pods.meshedPodsPercentage) { + return ( + + This service doesn't look like it's tagged with the right service, or + linkerd is not injected. + + ); + } + if (!stats?.incoming.length && !stats?.outgoing.length) { return ( diff --git a/workspaces/linkerd/plugins/linkerd/src/components/EdgesTable.tsx b/workspaces/linkerd/plugins/linkerd/src/components/EdgesTable.tsx index 4dcb3a357..d922ed614 100644 --- a/workspaces/linkerd/plugins/linkerd/src/components/EdgesTable.tsx +++ b/workspaces/linkerd/plugins/linkerd/src/components/EdgesTable.tsx @@ -15,6 +15,7 @@ import { Chip, makeStyles, Typography, + CircularProgress, } from '@material-ui/core'; import CheckCircle from '@material-ui/icons/CheckCircle'; import RemoveCircle from '@material-ui/icons/RemoveCircle'; @@ -40,121 +41,125 @@ const useStyles = makeStyles({ export const EdgesTable = () => { const { entity } = useEntity(); const styles = useStyles(); - const { stats } = useStatsForEntity(entity); + const { stats, loading } = useStatsForEntity(entity); + + const content = () => { + if (!stats && loading) { + return ; + } + + if (!stats || !stats.current || !stats.current.pods.meshedPodsPercentage) { + return ( + + This service doesn't look like it's tagged with the right service, or + linkerd is not injected. + + ); + } + + const incoming = + stats?.incoming?.map(edge => { + const matchedEdge = stats?.edges.find( + e => + e.dst.namespace === stats.current.namespace && + e.dst.name === stats.current.name && + e.dst.type === stats.current.type && + e.src.type === edge.type && + e.src.name === edge.name && + e.src.namespace === edge.namespace, + ); + + return { + ...edge, + direction: 'incoming', + secure: matchedEdge?.noIdentityMsg === '', + }; + }) ?? []; + + const outgoing = + stats?.outgoing?.map(edge => { + const matchedEdge = stats?.edges.find( + e => + e.src.namespace === stats.current.namespace && + e.src.name === stats.current.name && + e.src.type === stats.current.type && + e.dst.type === edge.type && + e.dst.name === edge.name && + e.dst.namespace === edge.namespace, + ); + + return { + ...edge, + direction: 'outgoing', + secure: matchedEdge?.noIdentityMsg === '', + }; + }) ?? []; + + const edges = [...incoming, ...outgoing] + .filter(f => f.type === 'deployment') + .sort((a, b) => a.name.localeCompare(b.name)); - if (!stats) { return ( - - - - - - This service doesn't look like it's tagged with the right service, - or linkerd is not injected. - - - + + + + + Direction + Name + RPS + S/R + TLS + + + + {edges.map(row => ( + + + + + + + + {`${row.requestRate.toFixed( + 2, + )}`} + + {`${Math.round(row.successRate * 100)}%`} + + + {row.secure ? ( + + ) : ( + + )} + + + ))} + +
+
); - } - - const incoming = - stats?.incoming?.map(edge => { - const matchedEdge = stats?.edges.find( - e => - e.dst.namespace === stats.current.namespace && - e.dst.name === stats.current.name && - e.dst.type === stats.current.type && - e.src.type === edge.type && - e.src.name === edge.name && - e.src.namespace === edge.namespace, - ); - - return { - ...edge, - direction: 'incoming', - secure: matchedEdge?.noIdentityMsg === '', - }; - }) ?? []; - - const outgoing = - stats?.outgoing?.map(edge => { - const matchedEdge = stats?.edges.find( - e => - e.src.namespace === stats.current.namespace && - e.src.name === stats.current.name && - e.src.type === stats.current.type && - e.dst.type === edge.type && - e.dst.name === edge.name && - e.dst.namespace === edge.namespace, - ); - - return { - ...edge, - direction: 'outgoing', - secure: matchedEdge?.noIdentityMsg === '', - }; - }) ?? []; - - const edges = [...incoming, ...outgoing] - .filter(f => f.type === 'deployment') - .sort((a, b) => a.name.localeCompare(b.name)); + }; return ( - - - - - Direction - Name - RPS - S/R - TLS - - - - {edges.map(row => ( - - - - - - - - {`${row.requestRate.toFixed( - 2, - )}`} - - {`${Math.round(row.successRate * 100)}%`} - - - {row.secure ? ( - - ) : ( - - )} - - - ))} - -
-
+ {content()}
); diff --git a/workspaces/linkerd/plugins/linkerd/src/components/IsMeshedBanner.tsx b/workspaces/linkerd/plugins/linkerd/src/components/IsMeshedBanner.tsx index 0c8520e73..fd39f2e7b 100644 --- a/workspaces/linkerd/plugins/linkerd/src/components/IsMeshedBanner.tsx +++ b/workspaces/linkerd/plugins/linkerd/src/components/IsMeshedBanner.tsx @@ -11,7 +11,7 @@ export const IsMeshedBanner = () => { const { entity } = useEntity(); const { stats } = useStatsForEntity(entity); - if (!stats) { + if (!stats || !stats.current.pods.meshedPodsPercentage) { return ( } severity="error">