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

Bug 1883851: Alert users about unsupported guest agent version #6793

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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