Skip to content
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.
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 @@ -401,9 +401,10 @@ public ConsoleProxyVO doAssignProxy(long dataCenterId, long vmId) {
return null;
}

if (vm != null && vm.getState() != State.Starting && vm.getState() != State.Running) {
if (vm != null && vm.getState() != State.Starting && vm.getState() != State.Running
&& vm.getState() != State.Stopping && vm.getState() != State.Migrating) {
Comment on lines +404 to +405

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:) a lot of getState()s there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DaanHoogland not very much , only 4 :-)
will pay attention in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NP, code can be such a joy.

if (s_logger.isInfoEnabled()) {
s_logger.info("Detected that vm : " + vmId + " is not currently in starting or running state, we will fail the proxy assignment for it");
s_logger.info("Detected that vm : " + vmId + " is not currently in starting or running or stopping or migrating state, we will fail the proxy assignment for it");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,12 @@ public Pair<String, Integer> getVncPort(final VirtualMachine vm) {
s_logger.trace("Trying to retrieve VNC port from agent about VM " + vm.getHostName());
}

final GetVncPortAnswer answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
GetVncPortAnswer answer = null;
if (vm.getState() == State.Migrating && vm.getLastHostId() != null) {
answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getLastHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
} else {
Comment on lines +2396 to +2398

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So we are making the decision we are opening a console to the old VM. looks good but may have some problems. I suspect you tested @ustcweizhou .
problems I see are:

  • this is a second migrate and the old host is no longer valid.
  • the migration is already successful but not administered yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DaanHoogland indeed there are some problems with vm console, for example
(1) vm is Starting state, but is not running on any server (eg applying dhcp/dns entries in virtual routers)
(2) vm is Stopping state, but is stopped on server
(3) vm is Migrating state, when we open the console of vm (on source host), and migration is done, the console is invalid.
However, I think all these problems are not real issues. When vm state is updated, refresh the web page and a new console will work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree, @weizhouapache these are not big issues. I just wanted to have mentioned them and am not 👎ing this!

answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
}
if (answer != null && answer.getResult()) {
return new Pair<String, Integer>(answer.getAddress(), answer.getPort());
}
Expand Down
8 changes: 5 additions & 3 deletions ui/scripts/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -3711,16 +3711,18 @@
allowedActions.push("resetSSHKeyForVirtualMachine");
} else if (jsonObj.state == 'Starting') {
// allowedActions.push("stop");
if (isAdmin()) {
allowedActions.push("viewConsole");
}
} else if (jsonObj.state == 'Error') {
allowedActions.push("destroy");
} else if (jsonObj.state == 'Expunging') {
if (g_allowUserExpungeRecoverVm) {
allowedActions.push("expunge");
}
}

if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' || jsonObj.state == 'Migrating') {
allowedActions.push("viewConsole");
}

return allowedActions;
}

Expand Down
21 changes: 9 additions & 12 deletions ui/scripts/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -22071,10 +22071,6 @@
allowedActions.push("migrate");
allowedActions.push("diagnostics");
}
} else if (jsonObj.state == 'Starting') {
if (isAdmin()) {
allowedActions.push("viewConsole");
}
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");

Expand All @@ -22083,6 +22079,9 @@

allowedActions.push("remove");
}
if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' || jsonObj.state == 'Migrating') {
allowedActions.push("viewConsole");
}
return allowedActions;
}

Expand All @@ -22095,13 +22094,12 @@
allowedActions.push("viewConsole");
if (isAdmin())
allowedActions.push("migrate");
} else if (jsonObj.state == 'Starting') {
if (isAdmin()) {
allowedActions.push("viewConsole");
}
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");
}
if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' || jsonObj.state == 'Migrating') {
allowedActions.push("viewConsole");
}
return allowedActions;
}

Expand All @@ -22124,10 +22122,6 @@
allowedActions.push("migrate");
allowedActions.push("diagnostics");
}
} else if (jsonObj.state == 'Starting') {
if (isAdmin()) {
allowedActions.push("viewConsole");
}
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");

Expand All @@ -22138,6 +22132,9 @@
} else if (jsonObj.state == 'Error') {
allowedActions.push("remove");
}
if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' || jsonObj.state == 'Migrating') {
allowedActions.push("viewConsole");
}
return allowedActions;
}

Expand Down