Skip to content

Fixes script that perform change password on hosts#6783

Merged
DaanHoogland merged 4 commits intoapache:mainfrom
RodrigoDLopez:fix-updateHostPassword-API
Dec 16, 2022
Merged

Fixes script that perform change password on hosts#6783
DaanHoogland merged 4 commits intoapache:mainfrom
RodrigoDLopez:fix-updateHostPassword-API

Conversation

@RodrigoDLopez
Copy link
Copy Markdown
Contributor

Description

When adding a KVM host via ACS UI, it is necessary to provide a username and password for ACS to connect via SSH to the host. When using the updateHostPassword API, ACS updates the password in the metadata. When the update_passwd_on_host parameter is specified as true, ACS sends a command to the host that causes it to run a script to change the user's password on the host.

During some internal tests, it was observed that the script was not changing the password and returned an error. Adjustments were made to this script to make it work again.

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

After executing the updateHostPassword API, an attempt was made to access the host via ssh using the user and the new password as a parameter. The expected result is that the password for that user has been updated, and this was the result observed during the tests.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 29, 2022

Codecov Report

Merging #6783 (ed3a083) into main (67024b0) will increase coverage by 0.34%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##               main    #6783      +/-   ##
============================================
+ Coverage     10.52%   10.87%   +0.34%     
- Complexity     6784     7115     +331     
============================================
  Files          2464     2485      +21     
  Lines        243988   245507    +1519     
  Branches      38185    38334     +149     
============================================
+ Hits          25690    26695    +1005     
- Misses       215065   215543     +478     
- Partials       3233     3269      +36     
Impacted Files Coverage Δ
...org/apache/cloudstack/quota/vo/QuotaBalanceVO.java 28.20% <0.00%> (-17.95%) ⬇️
...e/cloudstack/api/command/QuotaTariffUpdateCmd.java 44.00% <0.00%> (-8.39%) ⬇️
...dstack/network/contrail/model/ModelObjectBase.java 21.15% <0.00%> (-7.70%) ⬇️
.../schema/src/main/java/com/cloud/usage/UsageVO.java 28.97% <0.00%> (-5.88%) ⬇️
.../org/apache/cloudstack/quota/QuotaManagerImpl.java 44.92% <0.00%> (-5.51%) ⬇️
...che/cloudstack/api/command/QuotaTariffListCmd.java 66.66% <0.00%> (-4.77%) ⬇️
...e/cloudstack/api/response/QuotaTariffResponse.java 69.38% <0.00%> (-1.58%) ⬇️
...schema/src/main/java/com/cloud/user/AccountVO.java 78.68% <0.00%> (-1.32%) ⬇️
.../src/main/java/com/cloud/storage/VMTemplateVO.java 37.70% <0.00%> (-1.28%) ⬇️
...in/java/com/cloud/api/query/vo/TemplateJoinVO.java 38.09% <0.00%> (-1.15%) ⬇️
... and 98 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@RodrigoDLopez RodrigoDLopez changed the title fixes script that perform change password on hosts Fixes script that perform change password on hosts Sep 29, 2022
@yadvr yadvr added this to the 4.18.0.0 milestone Oct 8, 2022
@yadvr
Copy link
Copy Markdown
Member

yadvr commented Oct 8, 2022

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@rohityadavcloud a 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
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

LGTM, needs testing

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖️ el7 ✖️ el8 ✖️ debian ✖️ suse15. SL-JID 4380

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan package

Copy link
Copy Markdown
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

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a 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
Copy Markdown

Packaging result: ✖️ el7 ✖️ el8 ✖️ debian ✖️ suse15. SL-JID 4421

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖️ el7 ✖️ el8 ✖️ debian ✔️ suse15. SL-JID 4433

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖️ el7 ✔️ el8 ✖️ debian ✖️ suse15. SL-JID 4445

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖️ el7 ✔️ el8 ✖️ debian ✖️ suse15. SL-JID 4451

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4455

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test matrix

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware65, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5122)
Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36605 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5122-xenserver-71.zip
Smoke tests completed. 104 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5124)
Environment: vmware-65u2 (x2), Advanced Networking with Mgmt server 7
Total time taken: 40954 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5124-vmware-65u2.zip
Smoke tests completed. 104 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5123)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 51288 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5123-kvm-centos7.zip
Smoke tests completed. 102 look OK, 2 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 3625.43 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 325.91 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 609.77 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 3604.99 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 3661.26 test_kubernetes_clusters.py
test_hostha_enable_ha_when_host_in_maintenance Error 303.86 test_hostha_kvm.py

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5144)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 39971 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5144-kvm-centos7.zip
Smoke tests completed. 103 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 599.87 test_kubernetes_clusters.py

@weizhouapache
Copy link
Copy Markdown
Member

I run this script on a ubuntu 22.04 host, the password has been changed successfully, but the exit code is 1

# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password
New password: Retype new password: passwd: password updated successfully
# echo $?
1

still needs some changes
@RodrigoDLopez

@RodrigoDLopez
Copy link
Copy Markdown
Contributor Author

I run this script on a ubuntu 22.04 host, the password has been changed successfully, but the exit code is 1

# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password
New password: Retype new password: passwd: password updated successfully
# echo $?
1

still needs some changes @RodrigoDLopez

I ran the same test with Ubuntu versions 20.04 and 22.04. However, the result in my environment was different from what was reported.

On ubuntu 20.04:

:~# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password
New password: Retype new password: passwd: password updated successfully
:~# 

On ubuntu 22.04:

:~# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password123
New password: Retype new password: passwd: password updated successfully
:~# 

can you recheck?

@weizhouapache
Copy link
Copy Markdown
Member

I run this script on a ubuntu 22.04 host, the password has been changed successfully, but the exit code is 1

# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password
New password: Retype new password: passwd: password updated successfully
# echo $?
1

still needs some changes @RodrigoDLopez

I ran the same test with Ubuntu versions 20.04 and 22.04. However, the result in my environment was different from what was reported.

On ubuntu 20.04:

:~# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password
New password: Retype new password: passwd: password updated successfully
:~# 

On ubuntu 22.04:

:~# /usr/share/cloudstack-common/scripts/vm/hypervisor/update_host_passwd.sh root password123
New password: Retype new password: passwd: password updated successfully
:~# 

can you recheck?

@RodrigoDLopez
have you checked the exit code of the script ?

remove unused variable
Comment on lines +25 to +30
if [[ $(echo $?) -eq 0 ]]; then
exit 0
else
exit 1
fi No newline at end of file
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don´t mind this part, but just letting the script exit will have all but the same effect; $? will be the exit code.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a 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
Copy Markdown

Packaging result: ✖️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4739

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖️ el7 ✔️ el8 ✔️ debian ✖️ suse15. SL-JID 4751

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✖️ debian ✔️ suse15. SL-JID 4753

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4755

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian Build Failed (tid-5397)

@blueorangutan
Copy link
Copy Markdown

Trillian Build Failed (tid-5406)

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4796

@weizhouapache
Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm

better to manually test this on EL7/EL8 (and similar)/ubuntu20/ubuntu22

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5419)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 45401 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5419-kvm-centos7.zip
Smoke tests completed. 104 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 570.05 test_kubernetes_clusters.py

@DaanHoogland
Copy link
Copy Markdown
Contributor

good point @weizhouapache
@blueorangutan test matrix

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware65, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5472)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 40496 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5472-kvm-centos7.zip
Smoke tests completed. 105 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5471)
Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7
Total time taken: 41805 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5471-xenserver-71.zip
Smoke tests completed. 105 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-5473)
Environment: vmware-65u2 (x2), Advanced Networking with Mgmt server 7
Total time taken: 46895 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6783-t5473-vmware-65u2.zip
Smoke tests completed. 104 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 676.30 test_kubernetes_clusters.py

@DaanHoogland
Copy link
Copy Markdown
Contributor

DaanHoogland commented Dec 13, 2022

doing some extra manual tests on assorted environments, @RodrigoDLopez . otherwise ready to merge

  • rocky8 / kvm
  • ubuntu22 / kvm
  • alma9 / vmware
  • ubuntu20 / xcpng82

@DaanHoogland
Copy link
Copy Markdown
Contributor

doing some extra manual tests on assorted environments, @RodrigoDLopez . otherwise ready to merge

* [x]  rocky8 / kvm

* [x]  ubuntu22 / kvm

* [ ]  alma9 / vmware

* [x]  ubuntu20 / xcpng82

@weizhouapache @RodrigoDLopez , only the vmware version failed. I am now trying a centos7 with vmware to eliminate the alma8 factor.

@DaanHoogland
Copy link
Copy Markdown
Contributor

ok, the failures have nothing to do with this code. I also had not understood the functionality completely. redoing some tests.

@DaanHoogland
Copy link
Copy Markdown
Contributor

tested good on xen and kvm, not supported on vmware: merging

@DaanHoogland DaanHoogland merged commit 96aaeac into apache:main Dec 16, 2022
@RodrigoDLopez RodrigoDLopez deleted the fix-updateHostPassword-API branch January 9, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants