Skip to content

Commit

Permalink
Merge pull request #10612 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-10608-to-release-4.9

[release-4.9] Bug 2029378: Fix NodePort RDP bug
  • Loading branch information
openshift-merge-robot committed Dec 8, 2021
2 parents bebd900 + 79cc1bd commit 0f0780c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Expand Up @@ -3,10 +3,11 @@ import { DesktopViewer } from '@patternfly/react-console';
import { Alert, Form, FormGroup } from '@patternfly/react-core';
import { Dropdown } from '@console/internal/components/utils';
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
import { ServiceModel } from '@console/internal/models';
import { PodModel, ServiceModel } from '@console/internal/models';
import { K8sResourceKind, PodKind } from '@console/internal/module/k8s';
import { DEFAULT_RDP_PORT, NetworkType, TEMPLATE_VM_NAME_LABEL } from '../../../constants';
import { ConsoleType } from '../../../constants/vm/console-type';
import { findVMIPod } from '../../../selectors/pod/selectors';
import { getRdpAddressPort } from '../../../selectors/service';
import { getNetworks } from '../../../selectors/vm/selectors';
import { getVMIAvailableStatusInterfaces, isGuestAgentConnected } from '../../../selectors/vmi';
Expand Down Expand Up @@ -97,7 +98,14 @@ const RdpServiceNotConfigured: React.FC<RdpServiceNotConfiguredProps> = ({ vm })
};

const DesktopViewerSelector: React.FC<DesktopViewerSelectorProps> = (props) => {
const { setConsoleType, vm, vmi, vmPod } = props;
const { setConsoleType, vm, vmi } = props;

const [pods] = useK8sWatchResource<PodKind[]>({
kind: PodModel.kind,
isList: true,
});

const vmPod = React.useMemo(() => findVMIPod(vmi, pods), [pods, vmi]);

React.useEffect(() => {
setConsoleType(ConsoleType.DESKTOP_VIEWER);
Expand All @@ -116,7 +124,6 @@ const DesktopViewerSelector: React.FC<DesktopViewerSelectorProps> = (props) => {
);

const rdpServiceAddressPort = getRdpAddressPort(vmi, services, vmPod);

const guestAgent = isGuestAgentConnected(vmi);
const networks = React.useMemo(() => getVmRdpNetworks(vm, vmi), [vm, vmi]);
const networkItems = networks.reduce((result, network) => {
Expand Down Expand Up @@ -191,7 +198,6 @@ DesktopViewerSelector.displayName = 'DesktopViewer';
type DesktopViewerSelectorProps = {
vm: VMKind;
vmi: VMIKind;
vmPod: PodKind;
setConsoleType: (consoleType: ConsoleType) => void;
};

Expand Down
Expand Up @@ -202,12 +202,7 @@ const VMConsoles: React.FC<VMConsolesProps> = ({
{showSerialOption && <SerialConsoleConnector vmi={vmi} setConsoleType={setConsoleType} />}
{showVNCOption && <VncConsoleConnector vmi={vmi} setConsoleType={setConsoleType} />}
{isWindows(vm) && (
<DesktopViewerSelector
vmPod={vmStatusBundle.pod}
vm={vm}
vmi={vmi}
setConsoleType={setConsoleType}
/>
<DesktopViewerSelector vm={vm} vmi={vmi} setConsoleType={setConsoleType} />
)}
</AccessConsoles>
</StackItem>
Expand Down
Expand Up @@ -9,6 +9,7 @@ export const getRdpAddressPort = (
launcherPod: PodKind,
) => {
const [rdpService, rdpPortObj] = findRDPServiceAndPort(vmi, services);

if (!rdpService || !rdpPortObj) {
return null;
}
Expand All @@ -22,12 +23,6 @@ export const getRdpAddressPort = (
console.warn('External IP is not defined for the LoadBalancer RDP Service: ', rdpService);
}
break;
case 'ClusterIP':
address = rdpService.spec.clusterIP;
if (!address) {
console.warn('Cluster IP is not defined for the ClusterIP RDP Service: ', rdpService);
}
break;
case 'NodePort':
port = rdpPortObj.nodePort;
if (launcherPod) {
Expand Down

0 comments on commit 0f0780c

Please sign in to comment.