-
Notifications
You must be signed in to change notification settings - Fork 1.2k
API to list console sessions #11016
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
base: main
Are you sure you want to change the base?
API to list console sessions #11016
Conversation
@blueorangutan package |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11016 +/- ##
============================================
+ Coverage 16.57% 16.60% +0.03%
- Complexity 13968 14020 +52
============================================
Files 5743 5745 +2
Lines 510470 511012 +542
Branches 62074 62138 +64
============================================
+ Hits 84615 84868 +253
- Misses 416393 416668 +275
- Partials 9462 9476 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@blueorangutan package |
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13755 |
79f6d2d
to
ad7af57
Compare
@blueorangutan package |
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm, only doubt, is the active parameter needed? would we ever want to list no longer available sessions?
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13766 |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13771 |
@DaanHoogland, thanks for the review!
Yes, listing removed sessions is useful for audit and analysis purposes, as it allows users to track who generated a console endpoint, who accessed it, and when it was generated, acquired, and removed. Listing only active sessions, on the other hand, is helpful for verifying whether someone is currently using a VM. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13777 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13527)
|
@blueorangutan test ol8 vmware-70u3 keepEnv |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13630)
|
engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManagerImpl.java
Show resolved
Hide resolved
@blueorangutan package |
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
@nvazquez, I've just created the apache/cloudstack-cloudmonkey#162 PR to add autocomplete support for the |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13986 |
@blueorangutan test keepEnv |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13663)
|
engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java
Outdated
Show resolved
Hide resolved
@JoaoJandre, thanks for testing! I have just applied these suggestions #11016 (comment). Now, the Therefore:
|
@blueorangutan package |
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14041 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13691)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Did some basic tests mixing and matching the fields of the API and all seemed ok.
@nvazquez do you have any concerns regarding this PR? Or may we merge it? |
@bernardodemarco @JoaoJandre sorry I was on vacation last week, I'll post my review soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bernardodemarco I have updated my env to the latest packages and used your cmk PR with a slight modification of the instanceid
parameter for the autocompletion listing console sessions for a Domain admin. Overall looks good!
I noticed after upgrading my env to the latest packages there was a session still being listed which was not active but still part of the response in the API. I managed to reproduce it by opening a new session for a VM, leaving the session open on an inactive browser tab until the tab title switches from the VM name to 'noVNC'. After that, the session for that VM keeps being listed even with activeonly=true
despite closing the tab. Have you faced this case before? I don't think it is an issue with this PR but perhaps there could be a mechanism to remove this kind of 'incorrect' console sessions from the API response
@@ -252,6 +255,7 @@ public class ApiConstants { | |||
public static final String HYPERVISOR = "hypervisor"; | |||
public static final String INLINE = "inline"; | |||
public static final String INSTANCE = "instance"; | |||
public static final String INSTANCE_ID = "instance_id"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bernardodemarco there is a mismatch between this parameter value and the autocompletion cmk PR name (instance_id
vs instanceid
). For simplicity, can this value be changed to instanceid
?
Description
Currently, details about console sessions are stored in the
cloud.console_session
table in the database. Operators can only access this information by querying the database directly, while end users have no way to view console session data at all.To address this, this PR proposes to create the
listConsoleSessions
API. It allows listing the console sessions, with optional filters by domain, account, user, host, instance, IP address, and date. The API is accessible to all account types and, thus, performs proper access validation on the queried resources.The API supports the following parameters:
id
activeonly
true
. Active sessions are the ones that have been acquired and have not been removed.acquired
false
. Acquired sessions are the ones that have been accessed. Theactiveonly
parameter has precedence over theacquired
parameter, i.e., when theactiveonly
parameter istrue
, theacquired
parameter value will be ignored.isrecursive
false
.clientaddress
consoleendpointcreatoraddress
hostid
instanceid
startdate
enddate
domainid
accountid
userid
page
pagesize
.pagesize
page
.This PR only encompasses the creation of the API
listConsoleSessions
API. UI support will be implemented in a future PR.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
Tests Setup
listConsoleSessions
testsadmin
account, verified that the API lists console sessions correctly according to the specified parametersu1
account, verified that it is only possible to access the account's console sessionsd2-admin
account, verified that it is only possible to list the console sessions of thed2
domaind1-admin
account, verified that it is only possible to list the console sessions of thed1
andd1/d1-d1
domainsd1-user
account, verified that it is only possible to list thed1-user
console sessionsd1-d1-admin
account, verified that it is only possible to list the console sessions of thed1/d1-d1
domaind1-d1-user
account, verified that it is only possible to list thed1-d1-user
console sessionsUser
type, verified that thehostid
parameter is not considered in the API workflowUser
type, verified that thehostid
andhostname
response attributes are not included in the API's return