Skip to content

Conversation

weizhouapache
Copy link
Member

@weizhouapache weizhouapache commented Sep 15, 2025

Description

This PR fixes the password CKS user in project

UuidUtils.first returns only the first part of UUID , which contains 8 letters/digits in total.
If the min length is set to a value more than 8, the CKS cluster cannot be created in project

To be consistent with CKS user in non-project, use UUID instead of first 8 chars of UUID as password of CKS user in project

This fixes #11626

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@weizhouapache
Copy link
Member Author

@blueorangutan package

@weizhouapache weizhouapache changed the title CKS: generate a UUID for CKS user in project CKS: generate a random UUID as password of CKS user in project Sep 15, 2025
@weizhouapache weizhouapache added this to the 4.20.2 milestone Sep 15, 2025
Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@blueorangutan
Copy link

@weizhouapache 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.

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but how about when the min pw length is set beyond a UUID length?

Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.17%. Comparing base (1948f90) to head (0727b7b).
⚠️ Report is 17 commits behind head on 4.20.

Files with missing lines Patch % Lines
...c/main/java/com/cloud/user/AccountManagerImpl.java 0.00% 3 Missing ⚠️
...bernetes/cluster/KubernetesClusterManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #11639      +/-   ##
============================================
- Coverage     16.17%   16.17%   -0.01%     
+ Complexity    13298    13297       -1     
============================================
  Files          5656     5656              
  Lines        498151   498221      +70     
  Branches      60441    60452      +11     
============================================
- Hits          80589    80581       -8     
- Misses       408591   408671      +80     
+ Partials       8971     8969       -2     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 17.02% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weizhouapache
Copy link
Member Author

lgtm, but how about when the min pw length is set beyond a UUID length?

then #11626 appears 😆

this is just a quick workaround.
If user enables password policy, update the number of uppercase letters and number of special chars to a non-zero value, CKS will not work. so we need to find a ideal solution later.

generate a more strong password matching the policy, or ignore the password policy for CKS users
refer to #11637 (comment)

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm ( but a real solution should be created in a call that generates a password from a password policy in the end )

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15014

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks good but maybe for a complete solution we can bypass PasswordPolicy here. Kubernetes project account is created with System account call context so maybe we can bypass policy validations when System is creating accounts

@weizhouapache
Copy link
Member Author

change looks good but maybe for a complete solution we can bypass PasswordPolicy here. Kubernetes project account is created with System account call context so maybe we can bypass policy validations when System is creating accounts

thanks @shwstppr
if I understand correctly, you prefer to the PR #11637 ?

@shwstppr
Copy link
Contributor

@weizhouapache best case would have been creating a password compliant to the password policy. But because of regex config it would be difficult and error-prone. Next best is bypassing policy and creating a stronger password (which would never be used though). So I think maybe we keep this usage of complete UUID and then bypass the policy for system created account (which I feel would be more generic than adding a User.Source.CKS)

@weizhouapache
Copy link
Member Author

@weizhouapache best case would have been creating a password compliant to the password policy. But because of regex config it would be difficult and error-prone. Next best is bypassing policy and creating a stronger password (which would never be used though). So I think maybe we keep this usage of complete UUID and then bypass the policy for system created account (which I feel would be more generic than adding a User.Source.CKS)

thanks @shwstppr
agree that complete UUID should be secure enough.
User.Source.CKS in #11637 is used to bypass the policy. but you are right, we could just bypass the password policy of all users created by system account. let me see if it is possible

@weizhouapache
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache 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
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15179

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weizhouapache I've not tested but I guess we didn't need all the changes to pass the caller.
We could use CallContext.getCallingAccount(). KubernetesClusterManager was already using the system callcontext at line 1550

@weizhouapache
Copy link
Member Author

@weizhouapache I've not tested but I guess we didn't need all the changes to pass the caller. We could use CallContext.getCallingAccount(). KubernetesClusterManager was already using the system callcontext at line 1550

thanks @shwstppr , good point
let me double check and test it

@weizhouapache
Copy link
Member Author

@weizhouapache I've not tested but I guess we didn't need all the changes to pass the caller. We could use CallContext.getCallingAccount(). KubernetesClusterManager was already using the system callcontext at line 1550

reverted the last commit, added a simple check on the caller

tested ok

  • updated password.policy lengths from 0 to 1
  • without this PR, when created a CKS cluster in a new project, got an error "User password should contain at least [1] special characters."
  • with this PR, CKS cluster in project has been created successfully

thanks @shwstppr , good advise

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested before and after changes.

Before changes

Changed values for password configs
Image

k8s cluster creation failed

Image

After changes

Account created successfully
Image

k8s cluster created

Image

Tested password restrictions still applied when creating as admin

Image

@weizhouapache
Copy link
Member Author

cool, thanks for the testing @shwstppr

@weizhouapache
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache 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
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15234

@weizhouapache
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14487)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 56881 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11639-t14487-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_deployVMInSharedNetwork Failure 426.81 test_network.py

@weizhouapache
Copy link
Member Author

merging based on approvals and manua test, thanks @shwstppr

@weizhouapache weizhouapache merged commit c631d6a into apache:4.20 Oct 1, 2025
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the 4.20-cks-project-account-password branch October 1, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating CKS Cluster on 4.20 fails when using strong password settings
5 participants