diff --git a/go.sum b/go.sum index 10790bcc9..b337d8581 100644 --- a/go.sum +++ b/go.sum @@ -455,8 +455,6 @@ github.com/minio/cli v1.22.0 h1:VTQm7lmXm3quxO917X3p+el1l0Ca5X3S4PM2ruUYO68= github.com/minio/cli v1.22.0/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY= github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2BA= github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= -github.com/minio/kes v0.10.1 h1:f+WDJdNHNMf1xE6BbjtCLUyh671weSCQ30uynoCPl78= -github.com/minio/kes v0.10.1/go.mod h1:mTF1Bv8YVEtQqF/B7Felp4tLee44Pp+dgI0rhCvgNg8= github.com/minio/kes v0.11.0 h1:8ma6OCVSxKT50b1uYXLJro3m7PmZtCLxBaTddQexI5k= github.com/minio/kes v0.11.0/go.mod h1:mTF1Bv8YVEtQqF/B7Felp4tLee44Pp+dgI0rhCvgNg8= github.com/minio/mc v0.0.0-20200725183142-90d22b271f60 h1:LevaZ33nx+rUzRsuU7rVvqXUP7VCu2BQanhITw4Z9rA= diff --git a/models/zone_toleration_seconds.go b/models/zone_toleration_seconds.go new file mode 100644 index 000000000..9c89b194e --- /dev/null +++ b/models/zone_toleration_seconds.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2020 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 . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ZoneTolerationSeconds TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. +// +// swagger:model zoneTolerationSeconds +type ZoneTolerationSeconds struct { + + // seconds + // Required: true + Seconds *int64 `json:"seconds"` +} + +// Validate validates this zone toleration seconds +func (m *ZoneTolerationSeconds) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSeconds(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ZoneTolerationSeconds) validateSeconds(formats strfmt.Registry) error { + + if err := validate.Required("seconds", "body", m.Seconds); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ZoneTolerationSeconds) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ZoneTolerationSeconds) UnmarshalBinary(b []byte) error { + var res ZoneTolerationSeconds + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/zone_tolerations.go b/models/zone_tolerations.go index 9e8ef62a9..f893ee22f 100644 --- a/models/zone_tolerations.go +++ b/models/zone_tolerations.go @@ -75,8 +75,8 @@ type ZoneTolerationsItems0 struct { // Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. Operator string `json:"operator,omitempty"` - // TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. - TolerationSeconds int64 `json:"tolerationSeconds,omitempty"` + // toleration seconds + TolerationSeconds *ZoneTolerationSeconds `json:"tolerationSeconds,omitempty"` // Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. Value string `json:"value,omitempty"` @@ -84,6 +84,33 @@ type ZoneTolerationsItems0 struct { // Validate validates this zone tolerations items0 func (m *ZoneTolerationsItems0) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateTolerationSeconds(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ZoneTolerationsItems0) validateTolerationSeconds(formats strfmt.Registry) error { + + if swag.IsZero(m.TolerationSeconds) { // not required + return nil + } + + if m.TolerationSeconds != nil { + if err := m.TolerationSeconds.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tolerationSeconds") + } + return err + } + } + return nil } diff --git a/restapi/admin_tenants.go b/restapi/admin_tenants.go index 919974e0e..05c5bca23 100644 --- a/restapi/admin_tenants.go +++ b/restapi/admin_tenants.go @@ -214,13 +214,6 @@ func getTenant(ctx context.Context, operatorClient OperatorClient, namespace, te } func getTenantInfo(tenant *operator.Tenant) *models.Tenant { - var instanceCount int64 - var volumeCount int64 - for _, zone := range tenant.Spec.Zones { - instanceCount = instanceCount + int64(zone.Servers) - volumeCount = volumeCount + int64(zone.Servers*zone.VolumesPerServer) - } - var zones []*models.Zone var totalSize int64 @@ -1233,12 +1226,18 @@ func parseTenantZoneRequest(zoneParams *models.Zone, annotations map[string]stri // parse tolerations tolerations := []corev1.Toleration{} for _, elem := range zoneParams.Tolerations { + var tolerationSeconds *int64 + if elem.TolerationSeconds != nil { + // elem.TolerationSeconds.Seconds is allowed to be nil + tolerationSeconds = elem.TolerationSeconds.Seconds + } + toleration := corev1.Toleration{ Key: elem.Key, Operator: corev1.TolerationOperator(elem.Operator), Value: elem.Value, Effect: corev1.TaintEffect(elem.Effect), - TolerationSeconds: &elem.TolerationSeconds, + TolerationSeconds: tolerationSeconds, } tolerations = append(tolerations, toleration) } @@ -1434,12 +1433,18 @@ func parseTenantZone(zone *operator.Zone) *models.Zone { // parse tolerations var tolerations models.ZoneTolerations for _, elem := range zone.Tolerations { + var tolerationSecs *models.ZoneTolerationSeconds + if elem.TolerationSeconds != nil { + tolerationSecs = &models.ZoneTolerationSeconds{ + Seconds: elem.TolerationSeconds, + } + } toleration := &models.ZoneTolerationsItems0{ Key: elem.Key, Operator: string(elem.Operator), Value: elem.Value, Effect: string(elem.Effect), - TolerationSeconds: *elem.TolerationSeconds, + TolerationSeconds: tolerationSecs, } tolerations = append(tolerations, toleration) } diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index c4cd4a3bd..1b5780967 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -3378,6 +3378,19 @@ func init() { } } }, + "zoneTolerationSeconds": { + "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", + "type": "object", + "required": [ + "seconds" + ], + "properties": { + "seconds": { + "type": "integer", + "format": "int64" + } + } + }, "zoneTolerations": { "description": "Tolerations allows users to set entries like effect, key, operator, value.", "type": "array", @@ -3398,9 +3411,7 @@ func init() { "type": "string" }, "tolerationSeconds": { - "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", - "type": "integer", - "format": "int64" + "$ref": "#/definitions/zoneTolerationSeconds" }, "value": { "description": "Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.", @@ -5675,9 +5686,7 @@ func init() { "type": "string" }, "tolerationSeconds": { - "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", - "type": "integer", - "format": "int64" + "$ref": "#/definitions/zoneTolerationSeconds" }, "value": { "description": "Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.", @@ -7184,6 +7193,19 @@ func init() { } } }, + "zoneTolerationSeconds": { + "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", + "type": "object", + "required": [ + "seconds" + ], + "properties": { + "seconds": { + "type": "integer", + "format": "int64" + } + } + }, "zoneTolerations": { "description": "Tolerations allows users to set entries like effect, key, operator, value.", "type": "array", diff --git a/swagger.yml b/swagger.yml index 8c02cec10..5d64bf21b 100644 --- a/swagger.yml +++ b/swagger.yml @@ -2113,14 +2113,7 @@ definitions: category. type: string tolerationSeconds: - description: TolerationSeconds represents the period of - time the toleration (which must be of effect NoExecute, - otherwise this field is ignored) tolerates the taint. - By default, it is not set, which means tolerate the taint - forever (do not evict). Zero and negative values will - be treated as 0 (evict immediately) by the system. - format: int64 - type: integer + $ref: "#/definitions/zoneTolerationSeconds" value: description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, @@ -2128,6 +2121,21 @@ definitions: type: string type: object type: array + + zoneTolerationSeconds: + description: TolerationSeconds represents the period of + time the toleration (which must be of effect NoExecute, + otherwise this field is ignored) tolerates the taint. + By default, it is not set, which means tolerate the taint + forever (do not evict). Zero and negative values will + be treated as 0 (evict immediately) by the system. + type: object + required: + - seconds + properties: + seconds: + type: integer + format: int64 zoneResources: description: If provided, use these requests and limit for cpu/memory