Skip to content

server: fix lastpinged of hosts - #13030

Open
weizhouapache wants to merge 2 commits into
apache:4.20from
weizhouapache:4.20-fix-host-lastpinged
Open

server: fix lastpinged of hosts#13030
weizhouapache wants to merge 2 commits into
apache:4.20from
weizhouapache:4.20-fix-host-lastpinged

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes the lastpinged in host response.

(note it shows the last time that the agent connected to management server, not the agent heartbeat time)

prior to the change

(localcloud) 🐱 > list hosts filter=lastpinged
{
  "count": 4,
  "host": [
    {
      "lastpinged": "1970-01-21T01:41:28+0000"
    },
    {
      "lastpinged": "1970-01-21T01:41:28+0000"
    },
    {
      "lastpinged": "1970-01-21T01:41:28+0000"
    },
    {
      "lastpinged": "1970-01-21T01:41:39+0000"
    }
  ]
}

with the change (another environment)

(localcloud) 🐱 > list hosts filter=lastpinged
{
  "count": 4,
  "host": [
    {
      "lastpinged": "2026-04-15T06:59:54+0000"
    },
    {
      "lastpinged": "2026-04-09T08:25:45+0000"
    },
    {
      "lastpinged": "2026-04-09T08:50:16+0000"
    },
    {
      "lastpinged": "2026-04-09T08:50:17+0000"
    }
  ]
}

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?

Comment thread server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
@sureshanaparti
sureshanaparti requested a review from Copilot April 15, 2026 07:10
@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (8eb162c) to head (9e9dddb).
⚠️ Report is 24 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../java/com/cloud/api/query/dao/HostJoinDaoImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #13030      +/-   ##
============================================
- Coverage     16.26%   16.26%   -0.01%     
  Complexity    13433    13433              
============================================
  Files          5665     5667       +2     
  Lines        500530   500731     +201     
  Branches      60787    60803      +16     
============================================
+ Hits          81411    81434      +23     
- Misses       410027   410196     +169     
- Partials       9092     9101       +9     
Flag Coverage Δ
uitests 4.14% <ø> (-0.01%) ⬇️
unittests 17.11% <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 Harness.
📢 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.

Copilot AI left a comment

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.

Pull request overview

Fixes the lastpinged field in listHosts API responses by correctly converting the stored last_ping value into an epoch-milliseconds Date, so the returned timestamp reflects the actual last agent connection time instead of a near-1970 value.

Changes:

  • Convert HostJoinVO.lastPinged from the stored compact time unit (System.currentTimeMillis() >> 10) back to epoch milliseconds (<< 10) when populating HostResponse.lastPinged.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@weizhouapache weizhouapache added this to the 4.20.4 milestone May 7, 2026

@DaanHoogland DaanHoogland left a comment

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.

clgtm

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test keepEnv

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16699)

@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

tested ok,

one issue (unrelated to this PR I think)

(localcloud) 🐱 > list hosts filter=name,lastpinged
{
  "count": 4,
  "host": [
    {
      "lastpinged": "2026-08-05T09:15:18+0000",
      "name": "pr13030-t16705-kvm-ol8-kvm1"
    },
    {
      "lastpinged": "2026-08-05T05:01:44+0000",
      "name": "pr13030-t16705-kvm-ol8-kvm2"
    },
    {
      "lastpinged": "2026-08-05T08:55:57+0000",
      "name": "s-333-VM"
    },
    {
      "lastpinged": "2026-08-05T08:55:50+0000",
      "name": "v-334-VM"
    }
  ]
}

while pr13030-t16705-kvm-ol8-kvm2 was pinged much more recently:

2026-08-05 10:05:05,213 DEBUG [c.c.a.m.ClusteredAgentManagerImpl] (AgentManager-Handler-13:[]) (logid:) Ping from Routing host AgentAttache {"_id":2,"_name":"pr13030-t16705-kvm-ol8-kvm2","_uuid":"26b683ce-34d7-
4448-8634-91282c273081”}

and ..kvm1 as well btw;

2026-08-05 10:04:59,091 DEBUG [c.c.a.m.ClusteredAgentManagerImpl] (AgentManager-Handler-10:[]) (logid:) Ping from Routing host AgentAttache {"_id":1,"_name":"pr13030-t16705-kvm-ol8-kvm1","_uuid":"f989b3eb-44dd-
4674-ab83-8814ac2b1ffe”}

I redid the list hosts again after retrieving the logs but the output is still identical. The unix time stamps in the DB seem more accurate:

The Unix timestamp 1744063788 corresponds to May 5, 2025, at 12:29:48 PM UTC.
The Unix timestamp 1744048930 corresponds to May 5, 2025, at 12:15:30 PM UTC.

@weizhouapache

Copy link
Copy Markdown
Member Author

tested ok,

one issue (unrelated to this PR I think)

(localcloud) 🐱 > list hosts filter=name,lastpinged
{
  "count": 4,
  "host": [
    {
      "lastpinged": "2026-08-05T09:15:18+0000",
      "name": "pr13030-t16705-kvm-ol8-kvm1"
    },
    {
      "lastpinged": "2026-08-05T05:01:44+0000",
      "name": "pr13030-t16705-kvm-ol8-kvm2"
    },
    {
      "lastpinged": "2026-08-05T08:55:57+0000",
      "name": "s-333-VM"
    },
    {
      "lastpinged": "2026-08-05T08:55:50+0000",
      "name": "v-334-VM"
    }
  ]
}

while pr13030-t16705-kvm-ol8-kvm2 was pinged much more recently:

2026-08-05 10:05:05,213 DEBUG [c.c.a.m.ClusteredAgentManagerImpl] (AgentManager-Handler-13:[]) (logid:) Ping from Routing host AgentAttache {"_id":2,"_name":"pr13030-t16705-kvm-ol8-kvm2","_uuid":"26b683ce-34d7-
4448-8634-91282c273081”}

and ..kvm1 as well btw;

2026-08-05 10:04:59,091 DEBUG [c.c.a.m.ClusteredAgentManagerImpl] (AgentManager-Handler-10:[]) (logid:) Ping from Routing host AgentAttache {"_id":1,"_name":"pr13030-t16705-kvm-ol8-kvm1","_uuid":"f989b3eb-44dd-
4674-ab83-8814ac2b1ffe”}

I redid the list hosts again after retrieving the logs but the output is still identical. The unix time stamps in the DB seem more accurate:

The Unix timestamp 1744063788 corresponds to May 5, 2025, at 12:29:48 PM UTC.
The Unix timestamp 1744048930 corresponds to May 5, 2025, at 12:15:30 PM UTC.

@DaanHoogland
I think it reflects the time of the last (re)connection of agent, rather than the last ping.

@DaanHoogland

Copy link
Copy Markdown
Contributor

I think it reflects the time of the last (re)connection of agent, rather than the last ping.

ok, so do we make it an issue? not really a bug but a bit unclear and confusing.

@weizhouapache

Copy link
Copy Markdown
Member Author

I think it reflects the time of the last (re)connection of agent, rather than the last ping.

ok, so do we make it an issue? not really a bug but a bit unclear and confusing.

I can add to UI

image

what do you think ?

@DaanHoogland

Copy link
Copy Markdown
Contributor

seems fine to me but I don’t see the last disconnected in the ui created from this version either.

Anyway let’s merge this.

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/13030 (QA-JID-971)

@DaanHoogland

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-05 at 15 59 48

qa shows the wrong timestamp :(

@weizhouapache

Copy link
Copy Markdown
Member Author
Screenshot 2026-08-05 at 15 59 48

qa shows the wrong timestamp :(

right...qa does not have the api fix..
it is good to test ui changes only.

@DaanHoogland

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-05 at 15 59 48 qa shows the wrong timestamp :(

right...qa does not have the api fix.. it is good to test ui changes only.

at least both changes are validated independently. I settle ;)

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.

6 participants