Skip to content

server: fix lastpinged of hosts#13030

Open
weizhouapache wants to merge 1 commit intoapache:4.20from
weizhouapache:4.20-fix-host-lastpinged
Open

server: fix lastpinged of hosts#13030
weizhouapache wants to merge 1 commit intoapache: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?

}
hostResponse.setHostType(host.getType());
hostResponse.setLastPinged(new Date(host.getLastPinged()));
hostResponse.setLastPinged(new Date(host.getLastPinged() << 10));
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.

Suggested change
hostResponse.setLastPinged(new Date(host.getLastPinged() << 10));
hostResponse.setLastPinged(new Date(host.getLastPinged() * 1000));

@sureshanaparti sureshanaparti requested a review from Copilot April 15, 2026 07:10
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

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 (60fe960).

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    13434       +1     
============================================
  Files          5665     5665              
  Lines        500530   500530              
  Branches      60787    60787              
============================================
- Hits          81411    81410       -1     
- Misses       410027   410028       +1     
  Partials       9092     9092              
Flag Coverage Δ
uitests 4.15% <ø> (ø)
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 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

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.

3 participants