-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add parameter to not create additional users on cloudstack-setup-databases
#9969
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
Add parameter to not create additional users on cloudstack-setup-databases
#9969
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9969 +/- ##
============================================
+ Coverage 15.80% 16.17% +0.36%
- Complexity 12586 13291 +705
============================================
Files 5627 5668 +41
Lines 492328 498179 +5851
Branches 59692 60290 +598
============================================
+ Hits 77828 80590 +2762
- Misses 405977 408567 +2590
- Partials 8523 9022 +499
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:
|
Co-authored-by: dahn <daan.hoogland@gmail.com>
@blueorangutan package |
@blueorangutan package |
@DaanHoogland 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 11676 |
@blueorangutan package |
@DaanHoogland 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 11728 |
@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-11860)
|
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
@blueorangutan package |
@lucas-a-martins 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 12705 |
@blueorangutan test |
@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-12629)
|
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, manually tested in a local environment
- Verified that when the
--skip-users-auto-creation
flag is omitted, the script creates the default users:
Script execution
root@cloudstack:~# cloudstack-setup-databases scc:scc@192.168.122.200 --deploy-as=a:scc -i 192.168.122.200
Mysql user name:scc [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:192.168.122.200 [ OK ]
Mysql server port:3306 [ OK ]
Mysql root user name:a [ OK ]
Mysql root user password:****** [ OK ]
Using specified cluster management server node IP 192.168.122.200 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/server-setup.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, you can check your database configuration in /etc/cloudstack/management/db.properties
DB users
MariaDB [(none)]> select user,host from mysql.user;
+-------------+---------------+
| User | Host |
+-------------+---------------+
| scc | % |
| a | 192.168.122.% |
| scc | 192.168.122.% |
| mariadb.sys | localhost |
| mysql | localhost |
| root | localhost |
| scc | localhost |
+-------------+---------------+
7 rows in set (0.001 sec)
- Verified that when the flag is specified, the default users are not created:
Script execution
root@cloudstack:~# cloudstack-setup-databases scc:scc@192.168.122.200 --deploy-as=a:scc -i 192.168.122.200 --skip-users-auto-creation
Mysql user name:scc [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:192.168.122.200 [ OK ]
Mysql server port:3306 [ OK ]
Mysql root user name:a [ OK ]
Mysql root user password:****** [ OK ]
Using specified cluster management server node IP 192.168.122.200 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/server-setup.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, you can check your database configuration in /etc/cloudstack/management/db.properties
DB users
MariaDB [(none)]> select user,host from mysql.user;
+-------------+---------------+
| User | Host |
+-------------+---------------+
| a | 192.168.122.% |
| scc | 192.168.122.% |
| mariadb.sys | localhost |
| mysql | localhost |
| root | localhost |
+-------------+---------------+
5 rows in set (0.001 sec)
The CI error does not seem to be related |
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.
Pull Request Overview
This PR adds the --skip-users-auto-creation flag to the cloudstack-setup-databases command to prevent the creation of extra database users with excessive permissions.
- Introduces a new flag and corresponding option in the argument parser.
- Adds logic to bypass execution of queries that create or grant permissions to extra users by replacing them.
- Sets an instance attribute to propagate the flag value for later use.
if self.options.skipUsersAutoCreation: | ||
for t, r in queriesToSkip: text = text.replace(t,r) | ||
for t, r in replacements: text = text.replace(t,r) |
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.
[nitpick] Consider extracting the query replacement logic (lines 244-245) into a separate function or adding more descriptive inline comments to clarify its intent, which could improve readability and maintainability.
if self.options.skipUsersAutoCreation: | |
for t, r in queriesToSkip: text = text.replace(t,r) | |
for t, r in replacements: text = text.replace(t,r) | |
text = self.apply_replacements(text, queriesToSkip, replacements, self.options.skipUsersAutoCreation) |
Copilot uses AI. Check for mistakes.
if self.options.skipUsersAutoCreation: | ||
self.skipUsersAutoCreation = self.options.skipUsersAutoCreation |
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.
[nitpick] The flag is checked in multiple locations; consider consolidating the handling of skipUsersAutoCreation to ensure consistency and reduce potential duplication of logic.
if self.options.skipUsersAutoCreation: | |
self.skipUsersAutoCreation = self.options.skipUsersAutoCreation | |
self.handleSkipUsersAutoCreation() |
Copilot uses AI. Check for mistakes.
@lucas-a-martins , will you consider @CoPilot’s sugestions? |
I don’t think so |
Description
When using the
cloudstack-setup-databases
command during the database setup process, some additional users are created. Since the standard procedure involves creating and configuring database users prior to the ACS setup, these extra users are not used. Moreover, the additional users created bycloudstack-setup-databases
are granted excessive permissions, requiring operators to manually delete them.This PR introduces a new optional parameter,
--skip-users-auto-creation
. By using this parameter, ACS will skip the automatic creation of these additional users.Types of changes
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
After executing the
cloudstack-setup-databases
with the new flag, I checked the database users and, as expected, no new users were created. I then repeated the procedure without the new flag, and the extra users were created as usual.