Skip to content

Commit

Permalink
Add route agent healthcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Aswin Suryanarayanan <[email protected]>
  • Loading branch information
aswinsuryan committed Nov 12, 2024
1 parent 58b297e commit 4e2547c
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .idea/console.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const SubmarinerConnectionDegraded: SubmarinerConnectionDegradedType = 'Submarin
type SubmarinerBrokerConfigAppliedType = 'SubmarinerBrokerConfigApplied'
const SubmarinerBrokerConfigApplied: SubmarinerBrokerConfigAppliedType = 'SubmarinerBrokerConfigApplied'

type RouteAgentConnectionDegradedType = 'RouteAgentConnectionDegraded'
const RouteAgentConnectionDegraded: RouteAgentConnectionDegradedType = 'RouteAgentConnectionDegraded'

export enum SubmarinerStatus {
'progressing' = 'progressing',
'healthy' = 'healthy',
Expand All @@ -70,19 +73,25 @@ export const submarinerHealthCheck = (mca: ManagedClusterAddOn) => {
const connectionDegradedCondition = mca.status?.conditions?.find((c) => c.type === SubmarinerConnectionDegraded)
const agentCondition = mca.status?.conditions?.find((c) => c.type === SubmarinerAgentDegraded)
const nodeLabeledCondition = mca.status?.conditions?.find((c) => c.type === SubmarinerGatewayNodesLabeled)
const routeAgentConnectionDegradedCondition = mca.status?.conditions?.find(
(c) => c.type === RouteAgentConnectionDegraded
)

const isConnectionProgressing = connectionDegradedCondition?.status === undefined
const isRouteAgentProgressing = routeAgentConnectionDegradedCondition?.status === undefined
const isAgentProgressing = agentCondition?.status === undefined
const isNodeLabeledProgressing = nodeLabeledCondition?.status === undefined

if (isConnectionProgressing || isAgentProgressing || isNodeLabeledProgressing) {
if (isConnectionProgressing || isRouteAgentProgressing || isAgentProgressing || isNodeLabeledProgressing) {
return SubmarinerStatus.progressing
} else {
const isHealthyConnection = connectionDegradedCondition?.status === 'False'
const isHealthyRouteAgent = routeAgentConnectionDegradedCondition?.status === 'False'
const isHealthyAgent = agentCondition?.status === 'False'
const isNodeLabeled = nodeLabeledCondition?.status === 'True'
const isConnectionHealthy = isHealthyConnection && isHealthyRouteAgent

if (isHealthyConnection && isHealthyAgent && isNodeLabeled) {
if (isHealthyAgent && isNodeLabeled && isConnectionHealthy) {
return SubmarinerStatus.healthy
} else {
return SubmarinerStatus.degraded
Expand Down Expand Up @@ -154,17 +163,34 @@ export function ClusterSetSubmarinerPageContent() {
header: t('table.submariner.connection'),
cell: (mca: ManagedClusterAddOn) => {
const connectionDegradedCondition = mca.status?.conditions?.find((c) => c.type === SubmarinerConnectionDegraded)
const routeAgentConnectionDegradedCondition = mca.status?.conditions?.find(
(c) => c.type === RouteAgentConnectionDegraded
)

let type: StatusType = StatusType.progress
let status: string = t('status.submariner.progressing')
let message: string | undefined = t('status.submariner.progressing.message')
if (connectionDegradedCondition) {
status =
connectionDegradedCondition?.status === 'True'
? t('status.submariner.connection.degraded')
: t('status.submariner.connection.healthy')
type = connectionDegradedCondition?.status === 'True' ? StatusType.danger : StatusType.healthy
message = connectionDegradedCondition.message

const isSubmarinerDegraded = connectionDegradedCondition?.status === 'True'
const isRouteAgentDegraded = routeAgentConnectionDegradedCondition?.status === 'True'

if (isSubmarinerDegraded || isRouteAgentDegraded) {
status = t('status.submariner.connection.degraded')
type = StatusType.danger
if (isSubmarinerDegraded) {
message = connectionDegradedCondition?.message
} else {
message = routeAgentConnectionDegradedCondition?.message
}
} else if (
connectionDegradedCondition?.status === 'False' &&
routeAgentConnectionDegradedCondition?.status === 'False'
) {
type = StatusType.healthy
status = t('status.submariner.connection.healthy')
message = connectionDegradedCondition?.message
}

return <AcmInlineStatus type={type} status={status} popover={message ? { bodyContent: message } : undefined} />
},
},
Expand Down

0 comments on commit 4e2547c

Please sign in to comment.