mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat: improve diagnostics stability - develop (#355)
This commit is contained in:
parent
1b2dc6a133
commit
935c7dd496
4 changed files with 115 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package endpoints
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-version"
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
)
|
||||
|
||||
|
@ -15,6 +16,11 @@ func IsEdgeEndpoint(endpoint *portainer.Endpoint) bool {
|
|||
return endpoint.Type == portainer.EdgeAgentOnDockerEnvironment || endpoint.Type == portainer.EdgeAgentOnKubernetesEnvironment
|
||||
}
|
||||
|
||||
// IsStandardEdgeEndpoint returns true if this is a standard Edge endpoint and not in async mode on either Docker or Kubernetes
|
||||
func IsStandardEdgeEndpoint(endpoint *portainer.Endpoint) bool {
|
||||
return (endpoint.Type == portainer.EdgeAgentOnDockerEnvironment || endpoint.Type == portainer.EdgeAgentOnKubernetesEnvironment) && !endpoint.Edge.AsyncMode
|
||||
}
|
||||
|
||||
// IsAssociatedEdgeEndpoint returns true if the environment is an Edge environment
|
||||
// and has a set EdgeID and UserTrusted is true.
|
||||
func IsAssociatedEdgeEndpoint(endpoint *portainer.Endpoint) bool {
|
||||
|
@ -26,3 +32,11 @@ func IsAssociatedEdgeEndpoint(endpoint *portainer.Endpoint) bool {
|
|||
func HasDirectConnectivity(endpoint *portainer.Endpoint) bool {
|
||||
return !IsEdgeEndpoint(endpoint) || (IsAssociatedEdgeEndpoint(endpoint) && !endpoint.Edge.AsyncMode)
|
||||
}
|
||||
|
||||
// IsNewerThan225 returns true if the agent version is newer than 2.25.0
|
||||
// this is used to check if the agent is compatible with the new diagnostics feature
|
||||
func IsNewerThan225(agentVersion string) bool {
|
||||
v1, _ := version.NewVersion(agentVersion)
|
||||
v2, _ := version.NewVersion("2.25.0")
|
||||
return v1.GreaterThanOrEqual(v2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue