(tx dataservices.DataStoreTx, endpoint *portainer.Endpoint, snapshotError error, pendingActionsService *pendingactions.PendingActionsService)
| 267 | } |
| 268 | |
| 269 | func updateEndpointStatus(tx dataservices.DataStoreTx, endpoint *portainer.Endpoint, snapshotError error, pendingActionsService *pendingactions.PendingActionsService) { |
| 270 | latestEndpointReference, err := tx.Endpoint().Endpoint(endpoint.ID) |
| 271 | if latestEndpointReference == nil { |
| 272 | log.Debug(). |
| 273 | Str("endpoint", endpoint.Name). |
| 274 | Str("URL", endpoint.URL).Err(err). |
| 275 | Msg("background schedule error (environment snapshot), environment not found inside the database anymore") |
| 276 | |
| 277 | return |
| 278 | } |
| 279 | |
| 280 | latestEndpointReference.Status = portainer.EndpointStatusUp |
| 281 | |
| 282 | if snapshotError != nil { |
| 283 | log.Debug(). |
| 284 | Str("endpoint", endpoint.Name). |
| 285 | Str("URL", endpoint.URL).Err(err). |
| 286 | Msg("background schedule error (environment snapshot), unable to create snapshot") |
| 287 | |
| 288 | latestEndpointReference.Status = portainer.EndpointStatusDown |
| 289 | } |
| 290 | |
| 291 | latestEndpointReference.Agent.Version = endpoint.Agent.Version |
| 292 | |
| 293 | if err := tx.Endpoint().UpdateEndpoint(latestEndpointReference.ID, latestEndpointReference); err != nil { |
| 294 | log.Debug(). |
| 295 | Str("endpoint", endpoint.Name). |
| 296 | Str("URL", endpoint.URL).Err(err). |
| 297 | Msg("background schedule error (environment snapshot), unable to update environment") |
| 298 | } |
| 299 | |
| 300 | // Run the pending actions |
| 301 | if latestEndpointReference.Status == portainer.EndpointStatusUp { |
| 302 | pendingActionsService.Execute(endpoint.ID) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // FetchDockerID fetches info.Swarm.Cluster.ID if environment(endpoint) is swarm and info.ID otherwise |
| 307 | func FetchDockerID(snapshot portainer.DockerSnapshot) (string, error) { |
no test coverage detected