mirror of https://github.com/portainer/portainer
correctly detect unreachable
parent
24e0318280
commit
7813ac87cf
|
@ -0,0 +1,7 @@
|
|||
package cli
|
||||
|
||||
import "k8s.io/apimachinery/pkg/version"
|
||||
|
||||
func (kcl *KubeClient) ServerVersion() (*version.Info, error) {
|
||||
return kcl.cli.Discovery().ServerVersion()
|
||||
}
|
|
@ -76,10 +76,11 @@ func (service *PendingActionsService) Execute(id portainer.EndpointID) error {
|
|||
|
||||
// For Kubernetes endpoints, we need to check if the endpoint is up by creating a kube client
|
||||
if isKubernetesEndpoint {
|
||||
_, err := service.kubeFactory.GetKubeClient(endpoint)
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msgf("Environment %q (id: %d) is not up", endpoint.Name, id)
|
||||
return fmt.Errorf("environment %q (id: %d) is not up", endpoint.Name, id)
|
||||
if client, _ := service.kubeFactory.GetKubeClient(endpoint); client != nil {
|
||||
if _, err = client.ServerVersion(); err != nil {
|
||||
log.Debug().Err(err).Msgf("Environment %q (id: %d) is not up", endpoint.Name, id)
|
||||
return fmt.Errorf("environment %q (id: %d) is not up", endpoint.Name, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/portainer/portainer/pkg/featureflags"
|
||||
"golang.org/x/oauth2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -1496,6 +1497,8 @@ type (
|
|||
|
||||
// KubeClient represents a service used to query a Kubernetes environment(endpoint)
|
||||
KubeClient interface {
|
||||
ServerVersion() (*version.Info, error)
|
||||
|
||||
SetupUserServiceAccount(userID int, teamIDs []int, restrictDefaultNamespace bool) error
|
||||
IsRBACEnabled() (bool, error)
|
||||
GetServiceAccount(tokendata *TokenData) (*v1.ServiceAccount, error)
|
||||
|
|
Loading…
Reference in New Issue