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

open the VNC console in a new window #5593

Merged
merged 1 commit into from Jul 2, 2020

Conversation

glekner
Copy link
Contributor

@glekner glekner commented May 27, 2020

design: openshift/openshift-origin-design#425
JIRA: https://issues.redhat.com/browse/CNV-5111

This enables opening an independent new window for a VM/VMI console.

  • Opening a new window disables the main window's console as they can cause disconnects between each other. closing the new window returns the console to the main window.
    closing the main window doesn't affect the new window :)

  • If the new window fails to open due to some Adblocker, an alert is shown.

  • We're introducing a new route /vm-console with 3 URL Parameters:
    name, namespace, console

  • if console=SerialConsole it will open the serial console, for every other string or missing parameter it will open VncConsole

  • If name or namespace or both are missing or misspelled, an error is shown

Screen Shot 2020-05-26 at 23 08 24

  • If Kubevirt is not installed the following error is shown:

Screen Shot 2020-05-26 at 23 14 18

Video showing the new feature:
cloud-console (1)

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label May 27, 2020
@openshift-ci-robot
Copy link
Contributor

@glekner: This pull request references Bugzilla bug 1837677, which is invalid:

  • expected the bug to target the "4.5.0" release, but it targets "2.5.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1837677: open the VNC console in a new window

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. component/core Related to console core functionality labels May 27, 2020
@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label May 27, 2020
@openshift-ci-robot
Copy link
Contributor

@glekner: This pull request references Bugzilla bug 1837677, which is invalid:

  • expected the bug to target the "4.5.0" release, but it targets "2.5.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1837677: open the VNC console in a new window

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@glekner
Copy link
Contributor Author

glekner commented May 27, 2020

@suomiy @rawagner @yaacov can you review

@@ -229,6 +230,7 @@ render(
<Provider store={store}>
<Router history={history} basename={window.SERVER_FLAGS.basePath}>
<Switch>
<Route path="/vm-console" component={CloudVMConsole} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO our route table is a better place for a route we use, see for example:
https://github.com/openshift/console/blob/master/frontend/packages/kubevirt-plugin/src/plugin.tsx#L158

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mounting the route here will mount the layout aswell, we want to render the console alone

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vojtechszocs @spadgett

Are we okay with rendering a kubevirt component here? Are we going to add an extension point for this in the future?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mounting the route here will mount the layout aswell, we want to render the console alone

With #5645 a plugin can add new page & route that is rendered outside the standard Console <App> layout.

I think the CloudVMConsole page fits this use case, so we shouldn't need to modify the core app.jsx.


const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({ location, flags }) => {
const params = new URLSearchParams(location.search);
const consoleType = params.get('console');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make the constants a bit simpler? like vnc | serial | rdp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and maybe name it just type ?

return (
<ConnectedVMConsole
isKubevirt={flags.KUBEVIRT}
consoleType={consoleType === 'SerialConsole' ? 'SerialConsole' : 'VncConsole'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create an enum for this?

'',
`width=1024,height=768,left=200,top=200`,
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we shouldn't create an additional logic for this. We should have the same behaviour when somebody opens the console in the new tab by themselves.

Can we just create a simple link with href="/vm-console" target="_blank" rel="noopener noreferrer" ?

Current console will get Disconnected by default in the current window

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my experience they interfere each other.
also having a variable for the window helps us know if it got blocked by an Adblocker or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by interfering? You can still open a new tab with /vm-console.

You don't have to care about adblock when you have link for a new tab

@@ -63,7 +65,13 @@ const VMConsoles: React.FC<VMConsolesProps> = ({
serial,
rdp,
LoadingComponent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also add the url console type param for /k8s/ns/default/virtualmachines/vm-example/consoles

optional: true,
},
{
kind: DataVolumeModel.kind,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tagging resources are becoming quite a big pain. We should refactor how we use them.

@glekner glekner force-pushed the cloud-vm-console branch 2 times, most recently from ee498d0 to 6b41f7d Compare May 27, 2020 14:33
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 31, 2020
@@ -229,6 +230,7 @@ render(
<Provider store={store}>
<Router history={history} basename={window.SERVER_FLAGS.basePath}>
<Switch>
<Route path="/vm-console" component={CloudVMConsole} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mounting the route here will mount the layout aswell, we want to render the console alone

With #5645 a plugin can add new page & route that is rendered outside the standard Console <App> layout.

I think the CloudVMConsole page fits this use case, so we shouldn't need to modify the core app.jsx.

@@ -0,0 +1,27 @@
import * as React from 'react';
import { connectToFlags, FlagsObject } from '@console/internal/reducers/features';
import ConnectedVMConsole from '@console/kubevirt-plugin/src/components/connected-vm-console/connected-vm-console';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glekner Let's leverage #5645 and move all VM-related console code to kubevirt-plugin.

return (
<ConnectedVMConsole
isKubevirt={flags.KUBEVIRT}
type={type === ConsoleType.SERIAL ? ConsoleType.SERIAL : ConsoleType.VNC}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply use value pass-through?

Suggested change
type={type === ConsoleType.SERIAL ? ConsoleType.SERIAL : ConsoleType.VNC}
type={type}

The value should be already coerced via ConsoleType.fromString logic.

location: Location;
};

export default connectToFlags('KUBEVIRT')(CloudVMConsole);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we import & use the KubeVirt flag name as a constant?

});

return (
<VmConsolesWrapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<VmConsolesWrapper
<VMConsolesWrapper

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why "consoles" (plural) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patternfly's AccessConsoles is plural, so I guess someone thought its in place. ( I didnt name the components)

<>
<TextListItem component={TextListItemVariants.dt}>name</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
Missing name of the VM/VMI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd omit the "Missing" prefix since it's already mentioned above ("Missing Required URL Parameters").

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Missing name of the VM/VMI
Name of the VM/VMI

<>
<TextListItem component={TextListItemVariants.dt}>namespace</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
Missing namespace of the VM/VMI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Missing namespace of the VM/VMI
Namespace of the VM/VMI

.vm-console-actions {
padding: 0 30px;
}
.vm-console-bottom-gutter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please separate CSS declarations with newline.

>
<SerialConsoleConnector {...serial} />
<VncConsole {...vnc} />
{desktopViewverSelector}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{desktopViewverSelector}
{desktopViewerSelector}

);
};

const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => {
const { vm: vmProp, vmi, pods, vmStatusBundle } = props;
export const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => {
export const VMConsoleWrapper: React.FC<VmConsolesWrapperProps> = (props) => {

@glekner glekner changed the title Bug 1837677: open the VNC console in a new window open the VNC console in a new window Jun 5, 2020
@openshift-ci-robot openshift-ci-robot removed bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jun 5, 2020
@openshift-ci-robot
Copy link
Contributor

@glekner: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

open the VNC console in a new window

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@glekner glekner force-pushed the cloud-vm-console branch 2 times, most recently from c09e6b6 to 111b73a Compare June 9, 2020 17:58

export class ConsoleType extends ObjectEnum<string> {
static readonly VNC = new ConsoleType('VncConsole');
static readonly SERIAL = new ConsoleType('SerialConsole');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should allow navigating to DesktopViewer as well. And default to VNC when not available.

We also might select the vnc or serial if we detect one of them is not available.

thoughts?

cc @mareklibra

</Button>
)}
<AccessConsoles
preselectedType={type?.toString() || VNC_CONSOLE_TYPE}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here select the right type if the desired one is not available

<Button
className="vm-console-bottom-gutter"
variant="secondary"
onClick={() => window.open(`/vm-console?namespace=${namespace}&name=${vmName}`)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this here?

    href={href}
    target="_blank"
    rel="noopener noreferrer"


const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({ location, flags }) => {
const params = new URLSearchParams(location.search);
const type = ConsoleType.fromString(params.get('console'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a shorter name without uppercases for the URL?

console=vnc instead of console=VncConsole
and console=serial

We could define both in ConsoleType to have them together in one enum instance and use the second one for pf react-console

import { ConsoleEmptyState } from './vm-console-empty-state';
import { ConsoleType } from '../../constants/vm/console-type';

const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for calling this Cloud? ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took inspiration from the CloudTerminal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is better not to overuse words like this, because people will try to find meaning in them after they try to touch this code in one year

@glekner glekner force-pushed the cloud-vm-console branch 2 times, most recently from b927585 to 9f54dec Compare June 10, 2020 14:50
component="a"
target="_blank"
variant="secondary"
href={`/k8s/ns/${namespace}/virtualmachineinstances/${vmName}/standaloneconsole?type=${consoleType.toString()}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NPE: consoleType could be null if no console is supported by VM

return null;
};

const consoleType = typeNotSupported || type === undefined ? getAvailableType() : type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IMO it is always better to use type == null unless we have a special use case that has different behaviour for null vs undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@glekner glekner force-pushed the cloud-vm-console branch 2 times, most recently from d225b96 to 84579bc Compare July 1, 2020 17:30
@yaacov
Copy link
Member

yaacov commented Jul 2, 2020

/test e2e-gcp-console
/test analyze

@rawagner
Copy link
Contributor

rawagner commented Jul 2, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 2, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@yaacov
Copy link
Member

yaacov commented Jul 2, 2020

/test analyze
/test e2e-gcp-console

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@rawagner
Copy link
Contributor

rawagner commented Jul 2, 2020

/lgtm cancel

Analyze is failing, probably because VMConsolePage is not loaded lazily which brings a lot of stuff from kubevirt plugin. So either lazy load the component or wait for route extension.

@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 2, 2020
@glekner
Copy link
Contributor Author

glekner commented Jul 2, 2020

/retest

@rawagner
Copy link
Contributor

rawagner commented Jul 2, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: glekner, rawagner, suomiy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 2, 2020
@openshift-merge-robot openshift-merge-robot merged commit 4f21818 into openshift:master Jul 2, 2020
@spadgett spadgett added this to the v4.6 milestone Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants