User data content size validation, and related code improvements#8418
Conversation
|
@blueorangutan package |
|
@sureshanaparti 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. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #8418 +/- ##
============================================
- Coverage 30.85% 30.80% -0.05%
+ Complexity 34048 33979 -69
============================================
Files 5341 5341
Lines 374861 374888 +27
Branches 54518 54520 +2
============================================
- Hits 115659 115491 -168
- Misses 243973 244127 +154
- Partials 15229 15270 +41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm, just one functional question
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8164 |
harikrishna-patnala
left a comment
There was a problem hiding this comment.
@sureshanaparti, along with these changes is it better to call the registerUserData API using POST from UI ?
|
@sureshanaparti can you review the outstanding comments? |
|
@rohityadavcloud 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8189 |
changes done |
|
@blueorangutan package |
|
@sureshanaparti 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8199 |
|
@blueorangutan test |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@blueorangutan package |
|
@sureshanaparti 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8224 |
|
@blueorangutan test |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@sureshanaparti can you rebase with 4.18.2? As the related issue is also aimed at 4.18.2 |
JoaoJandre
left a comment
There was a problem hiding this comment.
Overall looks good, just a few remarks
|
[SF] Trillian test result (tid-8750)
|
@JoaoJandre pls check your remarks. thanks. |
|
@blueorangutan package |
|
@sureshanaparti 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9915 |
JoaoJandre
left a comment
There was a problem hiding this comment.
CLGTM, did not test it.
kiranchavala
left a comment
There was a problem hiding this comment.
@sureshanaparti as discussed, the userdata registration from the browser is not working
Regsiter a userdata of size 686kb
Error
|
@blueorangutan package |
|
@sureshanaparti 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9930 |
kiranchavala
left a comment
There was a problem hiding this comment.
As discussed, the registerUserdata api call Is failing with 400 error , if the userdata size is of 916kb
|
@blueorangutan package |
|
@sureshanaparti 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. |
@kiranchavala Allowed size is for the userdata after base64 encoding. Updated descriptions for the cmd param and config |
|
Packaging result [SF]: ✔️ el7 ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 9951 |
|
@blueorangutan package |
|
@kiranchavala 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9953 |
|
@blueorangutan test |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-10455)
|
|
@kiranchavala all good now? |
There was a problem hiding this comment.
LGTM, Followed these steps
- Global setting (vm.userdata.max.length) change it to 1048576
- Compute > userdata > register userdata
registering a user data
A Post request will be sent
and the logs will contain the userdata size
Configured base64 encoded user data size: 914652 bytes, actual user data size: 685987 bytes
LOGS
[root@ref-trl-6845-k-Mr8-kiran-chavala-mgmt1 ~]# cat /var/log/cloudstack/management/management-server.log |grep -i "logid:c0d4d084"
2024-06-14 09:26:08,934 DEBUG [c.c.a.ApiServlet] (qtp931675031-19:ctx-56f46fc4) (logid:c0d4d084) ===START=== 10.0.3.251 -- POST command=registerUserData&response=json
2024-06-14 09:26:08,935 DEBUG [c.c.a.ApiServlet] (qtp931675031-19:ctx-56f46fc4) (logid:c0d4d084) Two factor authentication is already verified for the user 2, so skipping
2024-06-14 09:26:08,943 DEBUG [c.c.a.ApiServer] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) CIDRs from which account 'Account [{"accountName":"admin","id":2,"uuid":"7669013f-2a0a-11ef-9a70-1e00da00037e"}]' is allowed to perform API calls: 0.0.0.0/0,::/0
2024-06-14 09:26:08,946 INFO [o.a.c.a.DynamicRoleBasedAPIAccessChecker] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) Account [Account [{"accountName":"admin","id":2,"uuid":"7669013f-2a0a-11ef-9a70-1e00da00037e"}]] is Root Admin or Domain Admin, all APIs are allowed.
2024-06-14 09:26:08,947 WARN [o.a.c.a.ProjectRoleBasedApiAccessChecker] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) Project is null, ProjectRoleBasedApiAccessChecker only applies to projects, returning API [registerUserData] for user [User {"username":"admin","uuid":"766a609c-2a0a-11ef-9a70-1e00da00037e"}.] as allowed.
2024-06-14 09:26:08,948 DEBUG [o.a.c.a.StaticRoleBasedAPIAccessChecker] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker.
2024-06-14 09:26:08,949 DEBUG [o.a.c.r.ApiRateLimitServiceImpl] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) API rate limiting is disabled. We will not use ApiRateLimitService.
2024-06-14 09:26:09,102 INFO [o.a.c.u.UserDataManagerImpl] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) Configured base64 encoded user data size: 914652 bytes, actual user data size: 685987 bytes
2024-06-14 09:26:09,421 DEBUG [c.c.a.ApiServlet] (qtp931675031-19:ctx-56f46fc4 ctx-bdb563ce) (logid:c0d4d084) ===END=== 10.0.3.251 -- POST command=registerUserData&response=json
Sent a userdata of higher size > 1048576 , and a 400 exception will be thrown
…che#8418) Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>

Description
This PR validates the user data with actual length only, and has some code improvements.
Fixes #8415
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Manually tested managed user data registration, and instance creation from UI.
How did you try to break this feature and the system with this change?