|
|
@ -76,6 +76,16 @@ func EndpointSet(endpointIDs []portainer.EndpointID) map[portainer.EndpointID]bo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func InitialIngressClassDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
func InitialIngressClassDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
|
|
|
|
if endpoint.Kubernetes.Flags.IsServerIngressClassDetected {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
|
|
|
endpoint.Kubernetes.Flags.IsServerIngressClassDetected = true
|
|
|
|
|
|
|
|
endpointService.UpdateEndpoint(
|
|
|
|
|
|
|
|
portainer.EndpointID(endpoint.ID),
|
|
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}()
|
|
|
|
cli, err := factory.GetKubeClient(endpoint)
|
|
|
|
cli, err := factory.GetKubeClient(endpoint)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Debug().Err(err).Msg("unable to create kubernetes client for ingress class detection")
|
|
|
|
log.Debug().Err(err).Msg("unable to create kubernetes client for ingress class detection")
|
|
|
@ -107,6 +117,16 @@ func InitialIngressClassDetection(endpoint *portainer.Endpoint, endpointService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func InitialMetricsDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
func InitialMetricsDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
|
|
|
|
if endpoint.Kubernetes.Flags.IsServerMetricsDetected {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
|
|
|
endpoint.Kubernetes.Flags.IsServerMetricsDetected = true
|
|
|
|
|
|
|
|
endpointService.UpdateEndpoint(
|
|
|
|
|
|
|
|
portainer.EndpointID(endpoint.ID),
|
|
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}()
|
|
|
|
cli, err := factory.GetKubeClient(endpoint)
|
|
|
|
cli, err := factory.GetKubeClient(endpoint)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Debug().Err(err).Msg("unable to create kubernetes client for initial metrics detection")
|
|
|
|
log.Debug().Err(err).Msg("unable to create kubernetes client for initial metrics detection")
|
|
|
@ -118,11 +138,6 @@ func InitialMetricsDetection(endpoint *portainer.Endpoint, endpointService datas
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endpoint.Kubernetes.Configuration.UseServerMetrics = true
|
|
|
|
endpoint.Kubernetes.Configuration.UseServerMetrics = true
|
|
|
|
endpoint.Kubernetes.Flags.IsServerMetricsDetected = true
|
|
|
|
|
|
|
|
err = endpointService.UpdateEndpoint(
|
|
|
|
|
|
|
|
portainer.EndpointID(endpoint.ID),
|
|
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Debug().Err(err).Msg("unable to enable UseServerMetrics inside the database")
|
|
|
|
log.Debug().Err(err).Msg("unable to enable UseServerMetrics inside the database")
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -158,6 +173,16 @@ func storageDetect(endpoint *portainer.Endpoint, endpointService dataservices.En
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func InitialStorageDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
func InitialStorageDetection(endpoint *portainer.Endpoint, endpointService dataservices.EndpointService, factory *cli.ClientFactory) {
|
|
|
|
|
|
|
|
if endpoint.Kubernetes.Flags.IsServerStorageDetected {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
|
|
|
endpoint.Kubernetes.Flags.IsServerStorageDetected = true
|
|
|
|
|
|
|
|
endpointService.UpdateEndpoint(
|
|
|
|
|
|
|
|
portainer.EndpointID(endpoint.ID),
|
|
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}()
|
|
|
|
log.Info().Msg("attempting to detect storage classes in the cluster")
|
|
|
|
log.Info().Msg("attempting to detect storage classes in the cluster")
|
|
|
|
err := storageDetect(endpoint, endpointService, factory)
|
|
|
|
err := storageDetect(endpoint, endpointService, factory)
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|