@@ -1668,12 +1668,12 @@ func (r *VirtualMCPServerReconciler) discoverBackends(
16681668
16691669 for i := range discoveredBackends {
16701670 backend := & discoveredBackends [i ]
1671- if healthStat , found := healthStatus [backend .Name ]; found {
1671+ if healthInfo , found := healthStatus [backend .Name ]; found {
16721672 // Map vmcp health status to CRD backend status
16731673 // vmcp statuses: healthy, unhealthy, degraded, unknown
16741674 // CRD statuses: ready, unavailable, degraded, unknown
16751675 var newStatus string
1676- switch healthStat {
1676+ switch healthInfo . Status {
16771677 case "healthy" :
16781678 newStatus = mcpv1alpha1 .BackendStatusReady
16791679 case "unhealthy" :
@@ -1687,15 +1687,20 @@ func (r *VirtualMCPServerReconciler) discoverBackends(
16871687 continue
16881688 }
16891689
1690- // Only log if status changed
1690+ // Update status if changed
16911691 if newStatus != backend .Status {
16921692 ctxLogger .V (1 ).Info ("Backend health check updated status" ,
16931693 "name" , backend .Name ,
16941694 "old_status" , backend .Status ,
16951695 "new_status" , newStatus ,
1696- "health_status" , healthStat )
1696+ "health_status" , healthInfo . Status )
16971697 backend .Status = newStatus
16981698 }
1699+
1700+ // Update LastHealthCheck with actual health check timestamp from vmcp
1701+ if ! healthInfo .LastCheckTime .IsZero () {
1702+ backend .LastHealthCheck = metav1 .NewTime (healthInfo .LastCheckTime )
1703+ }
16991704 }
17001705 }
17011706 } else {
@@ -2145,6 +2150,12 @@ func (*VirtualMCPServerReconciler) vmcpReferencesCompositeToolDefinition(
21452150 return false
21462151}
21472152
2153+ // BackendHealthInfo contains health information for a single backend
2154+ type BackendHealthInfo struct {
2155+ Status string
2156+ LastCheckTime time.Time
2157+ }
2158+
21482159// BackendHealthStatusResponse represents the health status response from the vmcp health API
21492160type BackendHealthStatusResponse struct {
21502161 Backends []struct {
@@ -2157,12 +2168,12 @@ type BackendHealthStatusResponse struct {
21572168 } `json:"backends"`
21582169}
21592170
2160- // queryVMCPHealthStatus queries the vmcp health endpoint and returns backend health status .
2171+ // queryVMCPHealthStatus queries the vmcp health endpoint and returns backend health information .
21612172// Returns nil if health monitoring is not enabled or if there's an error.
21622173func (* VirtualMCPServerReconciler ) queryVMCPHealthStatus (
21632174 ctx context.Context ,
21642175 vmcpURL string ,
2165- ) map [string ]string {
2176+ ) map [string ]* BackendHealthInfo {
21662177 ctxLogger := log .FromContext (ctx )
21672178
21682179 // Construct health endpoint URL
@@ -2208,10 +2219,13 @@ func (*VirtualMCPServerReconciler) queryVMCPHealthStatus(
22082219 return nil
22092220 }
22102221
2211- // Convert to map of backendID -> status
2212- healthStatus := make (map [string ]string )
2222+ // Convert to map of backendID -> health info
2223+ healthStatus := make (map [string ]* BackendHealthInfo )
22132224 for _ , backend := range healthResp .Backends {
2214- healthStatus [backend .BackendID ] = backend .Status
2225+ healthStatus [backend .BackendID ] = & BackendHealthInfo {
2226+ Status : backend .Status ,
2227+ LastCheckTime : backend .LastCheckTime ,
2228+ }
22152229 }
22162230
22172231 ctxLogger .V (1 ).Info ("Retrieved health status from vmcp server" ,
0 commit comments