Skip to content

Commit

Permalink
Alert users about unsupported guest agent version
Browse files Browse the repository at this point in the history
Signed-off-by: yaacov <[email protected]>
  • Loading branch information
yaacov committed Sep 30, 2020
1 parent 6a8dfa3 commit bb933e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,35 @@ import { StatusItem } from '@console/shared/src/components/dashboard/status-card
import { BlueInfoCircleIcon } from '@console/shared/src/components/status';
import { VMIKind } from '../../../types';
import { getVMIConditionsByType } from '../../../selectors/vmi';
import { NO_GUEST_AGENT_MESSAGE } from '../../../strings/vm/messages';
import {
NO_GUEST_AGENT_MESSAGE,
GUEST_AGENT_VERSION_NOT_SUPPOETED_MESSAGE,
} from '../../../strings/vm/messages';

// Based on: https://github.com/kubevirt/kubevirt/blob/f71e9c9615a6c36178169d66814586a93ba515b5/staging/src/kubevirt.io/client-go/api/v1/types.go#L337
const VMI_CONDITION_AGENT_CONNECTED = 'AgentConnected';
const VMI_CONDITION_AGENT_VERSION_NOT_SUPPORTED = 'AgentVersionNotSupported';

export const isGuestAgentInstalled = (vmi: VMIKind) => {
// the condition type is unique
const conditions = getVMIConditionsByType(vmi, VMI_CONDITION_AGENT_CONNECTED);
return conditions && conditions.length > 0 && conditions[0].status === 'True';
};

export const isGuestAgentVersionNotSupported = (vmi: VMIKind) => {
// the condition type is unique
const conditions = getVMIConditionsByType(vmi, VMI_CONDITION_AGENT_VERSION_NOT_SUPPORTED);
return conditions && conditions.length > 0 && conditions[0].status === 'True';
};

export const VMAlerts: React.FC<VMAlertsProps> = ({ vmi }) => (
<AlertsBody>
{vmi && vmi.status && !isGuestAgentInstalled(vmi) && (
{vmi && vmi.status && !isGuestAgentInstalled(vmi) && !isGuestAgentVersionNotSupported(vmi) && (
<StatusItem Icon={BlueInfoCircleIcon} message={NO_GUEST_AGENT_MESSAGE} />
)}
{vmi && vmi.status && isGuestAgentVersionNotSupported(vmi) && (
<StatusItem Icon={BlueInfoCircleIcon} message={GUEST_AGENT_VERSION_NOT_SUPPOETED_MESSAGE} />
)}
</AlertsBody>
);

Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/kubevirt-plugin/src/strings/vm/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export const PAUSED_VM_MODAL_MESSAGE =
export const VIRTUAL_MACHINE_IS_NOT_RUNNING = 'Virtual Machine is not running';
export const NO_GUEST_AGENT_MESSAGE =
'A guest agent was not found for this VM. Either the guest agent was not installed or the VM has not finished booting. When a guest agent is not installed, some management features are unavailable and the metrics might be inaccurate.';
export const GUEST_AGENT_VERSION_NOT_SUPPOETED_MESSAGE =
'This VM has an unsupported version of the guest agent. When an unsupported version of a guest agent is installed, some management features are unavailable and the metrics might be inaccurate. Check with your system adminstartor for supported guest agent versions.';
export const GUEST_AGENT_REQUIRED_MESSAGE = 'Guest agent required';
export const NOT_AVAILABLE_MESSAGE = 'Not available';
export const VM_NOT_RUNNING_MESSAGE = 'VM not running';
Expand Down

0 comments on commit bb933e2

Please sign in to comment.