fix(polling): clean up the logic for correctness and performance EE-5700 (#9169)

pull/9171/head^2
andres-portainer 2023-07-07 18:00:20 -03:00 committed by GitHub
parent 29c1862754
commit eefb4c4287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -27,6 +27,8 @@ func (service ServiceTx) Endpoint(ID portainer.EndpointID) (*portainer.Endpoint,
return nil, err
}
endpoint.LastCheckInDate, _ = service.service.Heartbeat(ID)
return &endpoint, nil
}

View File

@ -98,6 +98,13 @@ func (handler *Handler) endpointEdgeStatusInspect(w http.ResponseWriter, r *http
return httperror.Forbidden("Permission denied to access environment", err)
}
handler.DataStore.Endpoint().UpdateHeartbeat(endpoint.ID)
err = handler.requestBouncer.TrustedEdgeEnvironmentAccess(handler.DataStore, endpoint)
if err != nil {
return httperror.Forbidden("Permission denied to access environment", err)
}
var statusResponse *endpointEdgeStatusInspectResponse
if featureflags.IsEnabled(portainer.FeatureNoTx) {
statusResponse, err = handler.inspectStatus(handler.DataStore, r, portainer.EndpointID(endpointID))
@ -126,11 +133,6 @@ func (handler *Handler) inspectStatus(tx dataservices.DataStoreTx, r *http.Reque
return nil, err
}
err = handler.requestBouncer.TrustedEdgeEnvironmentAccess(tx, endpoint)
if err != nil {
return nil, httperror.Forbidden("Permission denied to access environment", err)
}
if endpoint.EdgeID == "" {
edgeIdentifier := r.Header.Get(portainer.PortainerAgentEdgeIDHeader)
endpoint.EdgeID = edgeIdentifier