Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route agent healthcheck #4054

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,38 @@ const mockSubmarinerAddOn: ManagedClusterAddOn = {
spec: {
installNamespace: 'submariner-operator',
},
status: {
conditions: [
{
type: 'SubmarinerConnectionDegraded',
status: 'False',
reason: 'ConnectionStable',
},
{
type: 'SubmarinerAgentDegraded',
status: 'False',
reason: 'AllSystemsOperational',
},
{
type: 'SubmarinerGatewayNodesLabeled',
status: 'True',
reason: 'NodesLabeledSuccessfully',
},
{
type: 'RouteAgentConnectionDegraded',
status: 'False',
reason: 'ConnectionStable',
},
],
addOnMeta: {
displayName: 'Submariner Add-On',
description: 'Manages Submariner deployment for cross-cluster networking.',
},
addOnConfiguration: {
crdName: 'submarinerconfigs.submariner.io',
crName: 'submariner',
},
},
}

export const mockSubmarinerAddon: Record<string, ManagedClusterAddOn[]> = {
Expand Down
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