mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(namespace): migrate create ns to react [EE-2226] (#10377)
This commit is contained in:
parent
31bcba96c6
commit
7218eb0892
83 changed files with 1869 additions and 358 deletions
|
@ -51,3 +51,38 @@ func (handler *Handler) getKubernetesNodesLimits(w http.ResponseWriter, r *http.
|
|||
|
||||
return response.JSON(w, nodesLimits)
|
||||
}
|
||||
|
||||
func (handler *Handler) getKubernetesMaxResourceLimits(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
||||
endpointID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
||||
if err != nil {
|
||||
return httperror.BadRequest(
|
||||
"Invalid environment identifier route variable",
|
||||
err,
|
||||
)
|
||||
}
|
||||
endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID))
|
||||
if handler.DataStore.IsErrObjectNotFound(err) {
|
||||
return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", err)
|
||||
} else if err != nil {
|
||||
return httperror.InternalServerError("Unable to find an environment with the specified identifier inside the database", err)
|
||||
}
|
||||
|
||||
cli, err := handler.KubernetesClientFactory.GetKubeClient(endpoint)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError(
|
||||
"Failed to lookup KubeClient",
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
overCommit := endpoint.Kubernetes.Configuration.EnableResourceOverCommit
|
||||
overCommitPercent := endpoint.Kubernetes.Configuration.ResourceOverCommitPercentage
|
||||
|
||||
// name is set to "" so all namespaces resources are considered when calculating max resource limits
|
||||
resourceLimit, err := cli.GetMaxResourceLimits("", overCommit, overCommitPercent)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to retrieve max resource limit", err)
|
||||
}
|
||||
|
||||
return response.JSON(w, resourceLimit)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue