-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add logs to keystore-setup and fix password regex #10723
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
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
DaanHoogland
left a comment
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.
looks generally good, but i'd use a $LOGGER as log command and define it depending on availability as the native tool instead of the function.
|
The potential problem here is that if I tend to use that kind of log function so I always get my logs, regardless of the environment. This would only be a problem of course if @DaanHoogland So, do I switch to logger with a fallback to log() knowing this ? |
|
@deajan , I don’t see the need for I am also only suggesting, I will not -1 without it. |
|
The point is that the log function as for now works like It's just a detail, but I am not sure whether |
|
Update: Dash has builtin |
|
Updated the script. Let me run it on a couple of hosts to make sure everything works as expected. |
|
ok, i see @deajan , sorry to make your life so “exciting” . Nice solution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10723 +/- ##
=========================================
Coverage 16.30% 16.31%
- Complexity 13445 13447 +2
=========================================
Files 5676 5676
Lines 499241 499241
Branches 60377 60377
=========================================
+ Hits 81408 81427 +19
+ Misses 408767 408742 -25
- Partials 9066 9072 +6
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:
|
|
@DaanHoogland No worries, just wanted to make things right :) Tested the script, logging works, registering computers works too (tested on two hosts) |
|
@blueorangutan package |
|
@rosi-shapeblue 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. |
|
@blueorangutan test alma9 kvm-alma9 |
|
@rosi-shapeblue a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests |
|
@blueorangutan test kvm-centos8 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14502 |
rosi-shapeblue
left a comment
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 - tested and verified the fix
Test Cases Covered & Status
-
Issue-#10703-Sudo-Logging-Fix
- Expected: Logs created when running keystore-setup with sudo -u cloudstack
- Status: PASS
-
Logging-Enhancement
- Expected: Comprehensive logging of all keystore setup operations
- Status: PASS
-
Password-Regex-Fix
- Expected: Extract only uncommented keystore.passphrase= lines
- Status: PASS
-
Error-Visibility
- Expected: Clear error messages for troubleshooting failed operations
- Status: PASS
-
SAN-Address-Detection
- Expected: IP address discovery and logging for CSR generation
- Status: PASS
-
Script-Continuation
- Expected: Script completes execution and logs issues instead of silent failure
- Status: PASS
-
Regression-Test
- Expected: No breaking changes to existing keystore setup functionality
- Status: PASS
Evidence
- Original Issue #10703 Fixed - Sudo Logging Works:
# Before PR: sudo -u cloudstack would produce no logs
# After PR: sudo -u cloudstack produces detailed logs in system messages
# Test command:
sudo -u cloudstack /usr/share/cloudstack-common/scripts/util/keystore-setup
# Logging mechanism verification:
type -p logger
/usr/bin/logger
- Successful Logging Implementation (sudo -u cloudstack):
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134492]: Mon Aug 11 10:50:01 UTC 2025 - starting keystore-setup
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134493]: keystore file exists. Deleting current entries
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134495]: keytool error: java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134514]: Generating new key
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134517]: keytool error: java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134538]: Generating CSR
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134550]: Found following SAN addresses to add to CSR: ip:10.0.33.195,ip:192.168.255.254,
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134552]: keytool error: java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134573]: Cannot chmod /tmp/sudo-test/agent.properties
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134575]: Cannot chmod /tmp/sudo-test/cloud.keystore
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134577]: Cannot chmod /tmp/sudo-test/test.csr
- Password Regex Fix Verification: Successfully extracts uncommented password, ignoring commented line
# Test agent.properties file content:
# This is a test agent.properties file
# keystore.passphrase=commented_password_should_be_ignored
keystore.passphrase=real_password_123
host=test
# Regex extraction test:
sed -n '/^keystore.passphrase/p' /tmp/keystore-test/agent.properties | sed 's/^keystore.passphrase=//g'
real_password_123
- Enhanced Error Visibility: Previously silent failures now logged with clear error messages
# Permission errors now visible (were silent before):
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134573]: Cannot chmod /tmp/sudo-test/agent.properties
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134575]: Cannot chmod /tmp/sudo-test/cloud.keystore
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134577]: Cannot chmod /tmp/sudo-test/test.csr
# Keytool errors now visible (were silent before):
Aug 11 10:50:01 ref-trl-9200-k-Mol8-rositsa-kyuchukova-kvm1 cloudstack-keystore-setup[134495]: keytool error: java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
|
@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]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14596 |
|
@blueorangutan test alma9 kvm-alma9 |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-14053) |
|
@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-14055)
|
|
Awesome work, congrats on your first merged pull request! |
Description
This PR adds logging to the
keystore-setupscript, and fixes the regex to check old cloudstack-agent password.When adding KVM hosts, the
keystore-setupscript may fail with530: Failed to setup keystore on the KVM host). On the KVM hostfor various reasons (absence of keystore, malformatted agent.properties file, missing permissions...).This adds logs to almost all actions, and also fixes the regex that gets the password from
agent.propertiesin order to not fetch commented-out passwords.Fixes #10703
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Script has been tested on two AlmaLinux 9.5 KVM hosts with a Cloudstack 4.20 management server.
Script has also been submitted to Shellcheck.
How did you try to break this feature and the system with this change?
Re-ran the tests on multiple hosts to validate that the script works ;)
Log function from the script has been tested on both RHEL and Debian systems.