Added log search & prometheus extra params configuration (#700)

This commit is contained in:
Alex
2021-04-21 01:39:14 -05:00
committed by GitHub
parent c81da22e8a
commit 62745e9ff2
17 changed files with 640 additions and 530 deletions

View File

@@ -893,13 +893,50 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
if tenantReq.ConsoleImage != "" {
minInst.Spec.Console.Image = tenantReq.ConsoleImage
}
//Default class name for Log search
diskSpaceFromAPI := int64(*tenantReq.LogSearchConfiguration.StorageSize) // Default is 5 by API
logSearchDiskSpace := resource.NewQuantity(diskSpaceFromAPI, resource.DecimalExponent)
logSearchStorageClass := tenantReq.LogSearchConfiguration.StorageClass // Default is ""
if tenantReq.LogSearchConfiguration.StorageClass == "" && len(tenantReq.Pools) > 0 {
logSearchStorageClass = tenantReq.Pools[0].VolumeConfiguration.StorageClassName
}
// default activate lgo search and prometheus
minInst.Spec.Log = &miniov2.LogConfig{
Image: "minio/logsearchapi:v4.0.0",
Audit: &miniov2.AuditConfig{DiskCapacityGB: swag.Int(10)},
Db: &miniov2.LogDbConfig{
VolumeClaimTemplate: &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: tenantName + "-log",
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: *logSearchDiskSpace,
},
},
StorageClassName: &logSearchStorageClass,
},
},
},
}
prometheusDiskSpace := int(*tenantReq.PrometheusConfiguration.StorageSize) // Default is 5 by API
prometheusStorageClass := tenantReq.PrometheusConfiguration.StorageClass // Default is ""
// Default class name for prometheus
if tenantReq.PrometheusConfiguration.StorageClass == "" && len(tenantReq.Pools) > 0 {
prometheusStorageClass = tenantReq.Pools[0].VolumeConfiguration.StorageClassName
}
minInst.Spec.Prometheus = &miniov2.PrometheusConfig{
DiskCapacityDB: swag.Int(5),
DiskCapacityDB: swag.Int(prometheusDiskSpace),
StorageClassName: &prometheusStorageClass,
}
// expose services

View File

@@ -3943,6 +3943,9 @@ func init() {
"type": "string"
}
},
"logSearchConfiguration": {
"$ref": "#/definitions/logSearchConfiguration"
},
"mounth_path": {
"type": "string"
},
@@ -3959,6 +3962,9 @@ func init() {
"$ref": "#/definitions/pool"
}
},
"prometheusConfiguration": {
"$ref": "#/definitions/prometheusConfiguration"
},
"secret_key": {
"type": "string"
},
@@ -4553,6 +4559,19 @@ func init() {
}
}
},
"logSearchConfiguration": {
"type": "object",
"properties": {
"storageClass": {
"type": "string",
"default": ""
},
"storageSize": {
"type": "number",
"default": 5
}
}
},
"logSearchResponse": {
"type": "object",
"properties": {
@@ -5379,6 +5398,19 @@ func init() {
}
}
},
"prometheusConfiguration": {
"type": "object",
"properties": {
"storageClass": {
"type": "string",
"default": ""
},
"storageSize": {
"type": "number",
"default": 5
}
}
},
"putBucketRetentionRequest": {
"type": "object",
"required": [
@@ -10603,6 +10635,9 @@ func init() {
"type": "string"
}
},
"logSearchConfiguration": {
"$ref": "#/definitions/logSearchConfiguration"
},
"mounth_path": {
"type": "string"
},
@@ -10619,6 +10654,9 @@ func init() {
"$ref": "#/definitions/pool"
}
},
"prometheusConfiguration": {
"$ref": "#/definitions/prometheusConfiguration"
},
"secret_key": {
"type": "string"
},
@@ -11213,6 +11251,19 @@ func init() {
}
}
},
"logSearchConfiguration": {
"type": "object",
"properties": {
"storageClass": {
"type": "string",
"default": ""
},
"storageSize": {
"type": "number",
"default": 5
}
}
},
"logSearchResponse": {
"type": "object",
"properties": {
@@ -11904,6 +11955,19 @@ func init() {
}
}
},
"prometheusConfiguration": {
"type": "object",
"properties": {
"storageClass": {
"type": "string",
"default": ""
},
"storageSize": {
"type": "number",
"default": 5
}
}
},
"putBucketRetentionRequest": {
"type": "object",
"required": [

View File

@@ -1,90 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// ListUsersWithBucketAccessHandlerFunc turns a function with the right signature into a list users with bucket access handler
type ListUsersWithBucketAccessHandlerFunc func(ListUsersWithBucketAccessParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn ListUsersWithBucketAccessHandlerFunc) Handle(params ListUsersWithBucketAccessParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// ListUsersWithBucketAccessHandler interface for that can handle valid list users with bucket access params
type ListUsersWithBucketAccessHandler interface {
Handle(ListUsersWithBucketAccessParams, *models.Principal) middleware.Responder
}
// NewListUsersWithBucketAccess creates a new http.Handler for the list users with bucket access operation
func NewListUsersWithBucketAccess(ctx *middleware.Context, handler ListUsersWithBucketAccessHandler) *ListUsersWithBucketAccess {
return &ListUsersWithBucketAccess{Context: ctx, Handler: handler}
}
/*ListUsersWithBucketAccess swagger:route GET /bucket-users/{bucket} AdminAPI listUsersWithBucketAccess
List Users With Access to a Given Bucket
*/
type ListUsersWithBucketAccess struct {
Context *middleware.Context
Handler ListUsersWithBucketAccessHandler
}
func (o *ListUsersWithBucketAccess) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
r = rCtx
}
var Params = NewListUsersWithBucketAccessParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
r = aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -1,155 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewListUsersWithBucketAccessParams creates a new ListUsersWithBucketAccessParams object
// no default values defined in spec.
func NewListUsersWithBucketAccessParams() ListUsersWithBucketAccessParams {
return ListUsersWithBucketAccessParams{}
}
// ListUsersWithBucketAccessParams contains all the bound params for the list users with bucket access operation
// typically these are obtained from a http.Request
//
// swagger:parameters ListUsersWithBucketAccess
type ListUsersWithBucketAccessParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: path
*/
Bucket string
/*
In: query
*/
Limit *int32
/*
In: query
*/
Offset *int32
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewListUsersWithBucketAccessParams() beforehand.
func (o *ListUsersWithBucketAccessParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
rBucket, rhkBucket, _ := route.Params.GetOK("bucket")
if err := o.bindBucket(rBucket, rhkBucket, route.Formats); err != nil {
res = append(res, err)
}
qLimit, qhkLimit, _ := qs.GetOK("limit")
if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil {
res = append(res, err)
}
qOffset, qhkOffset, _ := qs.GetOK("offset")
if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindBucket binds and validates parameter Bucket from path.
func (o *ListUsersWithBucketAccessParams) bindBucket(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.Bucket = raw
return nil
}
// bindLimit binds and validates parameter Limit from query.
func (o *ListUsersWithBucketAccessParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertInt32(raw)
if err != nil {
return errors.InvalidType("limit", "query", "int32", raw)
}
o.Limit = &value
return nil
}
// bindOffset binds and validates parameter Offset from query.
func (o *ListUsersWithBucketAccessParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
value, err := swag.ConvertInt32(raw)
if err != nil {
return errors.InvalidType("offset", "query", "int32", raw)
}
o.Offset = &value
return nil
}

View File

@@ -1,133 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// ListUsersWithBucketAccessOKCode is the HTTP code returned for type ListUsersWithBucketAccessOK
const ListUsersWithBucketAccessOKCode int = 200
/*ListUsersWithBucketAccessOK A successful response.
swagger:response listUsersWithBucketAccessOK
*/
type ListUsersWithBucketAccessOK struct {
/*
In: Body
*/
Payload *models.User `json:"body,omitempty"`
}
// NewListUsersWithBucketAccessOK creates ListUsersWithBucketAccessOK with default headers values
func NewListUsersWithBucketAccessOK() *ListUsersWithBucketAccessOK {
return &ListUsersWithBucketAccessOK{}
}
// WithPayload adds the payload to the list users with bucket access o k response
func (o *ListUsersWithBucketAccessOK) WithPayload(payload *models.User) *ListUsersWithBucketAccessOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list users with bucket access o k response
func (o *ListUsersWithBucketAccessOK) SetPayload(payload *models.User) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListUsersWithBucketAccessOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*ListUsersWithBucketAccessDefault Generic error response.
swagger:response listUsersWithBucketAccessDefault
*/
type ListUsersWithBucketAccessDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewListUsersWithBucketAccessDefault creates ListUsersWithBucketAccessDefault with default headers values
func NewListUsersWithBucketAccessDefault(code int) *ListUsersWithBucketAccessDefault {
if code <= 0 {
code = 500
}
return &ListUsersWithBucketAccessDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the list users with bucket access default response
func (o *ListUsersWithBucketAccessDefault) WithStatusCode(code int) *ListUsersWithBucketAccessDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the list users with bucket access default response
func (o *ListUsersWithBucketAccessDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the list users with bucket access default response
func (o *ListUsersWithBucketAccessDefault) WithPayload(payload *models.Error) *ListUsersWithBucketAccessDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the list users with bucket access default response
func (o *ListUsersWithBucketAccessDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ListUsersWithBucketAccessDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -1,141 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
"github.com/go-openapi/swag"
)
// ListUsersWithBucketAccessURL generates an URL for the list users with bucket access operation
type ListUsersWithBucketAccessURL struct {
Bucket string
Limit *int32
Offset *int32
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *ListUsersWithBucketAccessURL) WithBasePath(bp string) *ListUsersWithBucketAccessURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *ListUsersWithBucketAccessURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *ListUsersWithBucketAccessURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/bucket-users/{bucket}"
bucket := o.Bucket
if bucket != "" {
_path = strings.Replace(_path, "{bucket}", bucket, -1)
} else {
return nil, errors.New("bucket is required on ListUsersWithBucketAccessURL")
}
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var limitQ string
if o.Limit != nil {
limitQ = swag.FormatInt32(*o.Limit)
}
if limitQ != "" {
qs.Set("limit", limitQ)
}
var offsetQ string
if o.Offset != nil {
offsetQ = swag.FormatInt32(*o.Offset)
}
if offsetQ != "" {
qs.Set("offset", offsetQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *ListUsersWithBucketAccessURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *ListUsersWithBucketAccessURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *ListUsersWithBucketAccessURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on ListUsersWithBucketAccessURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on ListUsersWithBucketAccessURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *ListUsersWithBucketAccessURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}