-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
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.07% +0.26%
- Complexity 12586 13191 +605
============================================
Files 5627 5664 +37
Lines 492328 497612 +5284
Branches 59692 60216 +524
============================================
+ Hits 77828 79994 +2166
- Misses 405977 408661 +2684
- Partials 8523 8957 +434
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: dahn <[email protected]>
@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)
|
@@ -229,6 +229,10 @@ for full help | |||
"GRANT ALL ON cloud_usage.* to cloud@`%`;", | |||
"GRANT process ON *.* TO cloud@`localhost`;", | |||
"GRANT process ON *.* TO cloud@`%`;", | |||
"IF foo > 0 THEN", |
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.
huh? what's foo
?
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.
@DaanHoogland it's a local variable
cloudstack/setup/db/create-database.sql
Lines 26 to 43 in 864751d
DECLARE foo BIGINT DEFAULT 0 ; | |
SELECT COUNT(*) | |
INTO foo | |
FROM `mysql`.`user` | |
WHERE `User` = 'cloud' and host = 'localhost'; | |
IF foo > 0 THEN | |
DROP USER 'cloud'@'localhost' ; | |
END IF; | |
SELECT COUNT(*) | |
INTO foo | |
FROM `mysql`.`user` | |
WHERE `User` = 'cloud' and host = '%'; | |
IF foo > 0 THEN | |
DROP USER 'cloud'@'%' ; | |
END IF; |
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.
wouw, this is unreadable code (not your fault per sé)
so as I read this, this means that the lines
"IF foo > 0 THEN"
,
"DROP USER 'cloud'@'localhost' ;"
and
"END IF;"
are being skipped.
That does not seem to be the intention of the code. Should it just (conditionally) add the middle line? Or does it somehow do that?
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.
@DaanHoogland I was unable to skip the DROP
without skipping the IF
and END IF
, the command results in an error. Considering that the IF
is used only for the query I want to skip, I tought skipping it too wouldn't be a problem.
My goal when removing these queries is because the new flag was removing users from database when host = % || localhost
, but the idea of this PR is to not create additional users, not to remove existing ones.
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.
I am not sure that works this way. The line IF foo > 0 THEN
occurs 4 times in the file create-database.sql
I think it is safer to add a line with a noop and only remove the DROP line
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.
@DaanHoogland isn't it just 2 times?
Here:
cloudstack/setup/db/create-database.sql
Line 32 in 864751d
IF foo > 0 THEN |
And here:
cloudstack/setup/db/create-database.sql
Line 41 in 864751d
IF foo > 0 THEN |
Am I missing something?
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.
sorry, yes. I grep -r'd in a compiled env so I had two results in the target dir.
even so,
I think it is safer to add a line with a noop and only remove the DROP line
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.