Skip to content

add user-agent header to template downloader request#12791

Open
sudo87 wants to merge 5 commits intoapache:4.22from
shapeblue:addUserAgentTemplateDownload
Open

add user-agent header to template downloader request#12791
sudo87 wants to merge 5 commits intoapache:4.22from
shapeblue:addUserAgentTemplateDownload

Conversation

@sudo87
Copy link
Copy Markdown
Contributor

@sudo87 sudo87 commented Mar 11, 2026

Description

This PR adds user-agent header to download request.

Some template providers reject HTTP requests without a User-Agent
header and return HTTP 403 instead of redirecting to the actual
download location. This causes template downloads to fail.

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?

@sudo87 sudo87 requested a review from sureshanaparti March 11, 2026 12:34
@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 11, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.61%. Comparing base (7aa0558) to head (0f31e3e).
⚠️ Report is 14 commits behind head on 4.22.

Files with missing lines Patch % Lines
...torage/template/SimpleHttpMultiFileDownloader.java 0.00% 2 Missing ⚠️
...cloud/utils/net/HttpClientCloudStackUserAgent.java 81.81% 1 Missing and 1 partial ⚠️
...cloud/storage/template/HttpTemplateDownloader.java 0.00% 1 Missing ⚠️
...d/storage/template/MetalinkTemplateDownloader.java 0.00% 1 Missing ⚠️
utils/src/main/java/com/cloud/utils/UriUtils.java 0.00% 1 Missing ⚠️
.../main/java/com/cloud/utils/storage/QCOW2Utils.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12791      +/-   ##
============================================
- Coverage     17.61%   17.61%   -0.01%     
- Complexity    15664    15676      +12     
============================================
  Files          5917     5918       +1     
  Lines        531402   531557     +155     
  Branches      64971    64986      +15     
============================================
+ Hits          93596    93611      +15     
- Misses       427252   427389     +137     
- Partials      10554    10557       +3     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 18.68% <60.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.

@blueorangutan
Copy link
Copy Markdown

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

@weizhouapache
Copy link
Copy Markdown
Member

@sudo87
code looks ok

any linked issue ?

@sureshanaparti
Copy link
Copy Markdown
Contributor

@sudo87 code looks ok

any linked issue ?

@weizhouapache it seems no linked issue for this.

@sureshanaparti
Copy link
Copy Markdown
Contributor

@sudo87 check if the user-agent update is relavent in createRequest() at MetalinkTemplateDownloader, SimpleHttpMultiFileDownloader, HttpDirectTemplateDownloader.

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

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 12, 2026

@sudo87 check if the user-agent update is relavent in createRequest() at MetalinkTemplateDownloader, SimpleHttpMultiFileDownloader, HttpDirectTemplateDownloader.

Thanks @sureshanaparti for your feedback on the pr. I think there is no harm adding user-agent in the GetMethod request, updated the pr accordingly.

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 13, 2026

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Test Result Time (s) Test File
ContextSuite context=TestListIdsParams>:teardown Error 1.14 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 3.90 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.72 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.72 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 27.49 test_snapshots.py
test_01_snapshot_usage Error 32.91 test_usage.py
test_01_vpn_usage Error 1.12 test_usage.py

Copy link
Copy Markdown
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

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

The code looks good. My only concern (not sure about the impact) is the value for the user agent. We should ensure it matches the format as per the RFC. below is the output from quick web search.
Ref:
https://www.rfc-editor.org/rfc/rfc9110.html#section-10.1.5
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 24, 2026

Thank you @vishesh92 for review and suggestion. Changed the user agent to follow RFC format, e.g.:

CloudStack-Agent/4.22.1.0-SNAPSHOT (Apache CloudStack)

Please let me know if this makes sense.

@sudo87 sudo87 force-pushed the addUserAgentTemplateDownload branch from 7a13c88 to 6fd80d6 Compare March 24, 2026 11:05
@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 24, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sudo87 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
Copy Markdown

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

Copy link
Copy Markdown
Member

@vishesh92 vishesh92 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

[LL] Trillian Build Failed (tid-7181)

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@rajujith
Copy link
Copy Markdown
Contributor

@sudo87

There is a URL validity check done by the management server, which still shows up on the webserver as "Java/17.0.18". The SSVM file download shows "CloudStack-Agent/4.22.1.0-SNAPSHOT (Apache CloudStack)" . Do you think the management server also needs to be fixed?

@blueorangutan
Copy link
Copy Markdown

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

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 26, 2026

@sudo87

There is a URL validity check done by the management server, which still shows up on the webserver as "Java/17.0.18". The SSVM file download shows "CloudStack-Agent/4.22.1.0-SNAPSHOT (Apache CloudStack)" . Do you think the management server also needs to be fixed?

Thank you @rajujith for suggestion, it would be wise to add user-agent in HEAD request as well. I have updated the pr accordingly.

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 26, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sudo87 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
Copy Markdown

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

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@sudo87
Copy link
Copy Markdown
Contributor Author

sudo87 commented Mar 27, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sudo87 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
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

@rajujith rajujith 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

10.x.x.x- - [27/Mar/2026:11:28:09 +0000] "HEAD /jithintemplates/alpine-router.qcow2 HTTP/1.1" 200 271 "-" "CloudStack-Agent/4.22.1.0-SNAPSHOT (Apache CloudStack)"
10.x.x.x - - [27/Mar/2026:11:28:09 +0000] "GET /jithintemplates/alpine-router.qcow2 HTTP/1.1" 200 336462039 "-" "CloudStack-Agent/4.22.1.0-SNAPSHOT (Apache CloudStack)"

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

7 participants