Skip to content

Commit 4727481

Browse files
authored
Allow tolerationSeconds to be empty on Zone tolerations Requests (#238)
Since toleration seconds can be empty, we were forcing it to be an integer defaulting to 0 which was creating a toleration with value 0 when value should have been nil.
1 parent 3b123c6 commit 4727481

File tree

6 files changed

+168
-27
lines changed

6 files changed

+168
-27
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ github.com/minio/cli v1.22.0 h1:VTQm7lmXm3quxO917X3p+el1l0Ca5X3S4PM2ruUYO68=
455455
github.com/minio/cli v1.22.0/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY=
456456
github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2BA=
457457
github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc=
458-
github.com/minio/kes v0.10.1 h1:f+WDJdNHNMf1xE6BbjtCLUyh671weSCQ30uynoCPl78=
459-
github.com/minio/kes v0.10.1/go.mod h1:mTF1Bv8YVEtQqF/B7Felp4tLee44Pp+dgI0rhCvgNg8=
460458
github.com/minio/kes v0.11.0 h1:8ma6OCVSxKT50b1uYXLJro3m7PmZtCLxBaTddQexI5k=
461459
github.com/minio/kes v0.11.0/go.mod h1:mTF1Bv8YVEtQqF/B7Felp4tLee44Pp+dgI0rhCvgNg8=
462460
github.com/minio/mc v0.0.0-20200725183142-90d22b271f60 h1:LevaZ33nx+rUzRsuU7rVvqXUP7VCu2BQanhITw4Z9rA=

models/zone_toleration_seconds.go

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/zone_tolerations.go

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/admin_tenants.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,6 @@ func getTenant(ctx context.Context, operatorClient OperatorClient, namespace, te
214214
}
215215

216216
func getTenantInfo(tenant *operator.Tenant) *models.Tenant {
217-
var instanceCount int64
218-
var volumeCount int64
219-
for _, zone := range tenant.Spec.Zones {
220-
instanceCount = instanceCount + int64(zone.Servers)
221-
volumeCount = volumeCount + int64(zone.Servers*zone.VolumesPerServer)
222-
}
223-
224217
var zones []*models.Zone
225218

226219
var totalSize int64
@@ -1233,12 +1226,18 @@ func parseTenantZoneRequest(zoneParams *models.Zone, annotations map[string]stri
12331226
// parse tolerations
12341227
tolerations := []corev1.Toleration{}
12351228
for _, elem := range zoneParams.Tolerations {
1229+
var tolerationSeconds *int64
1230+
if elem.TolerationSeconds != nil {
1231+
// elem.TolerationSeconds.Seconds is allowed to be nil
1232+
tolerationSeconds = elem.TolerationSeconds.Seconds
1233+
}
1234+
12361235
toleration := corev1.Toleration{
12371236
Key: elem.Key,
12381237
Operator: corev1.TolerationOperator(elem.Operator),
12391238
Value: elem.Value,
12401239
Effect: corev1.TaintEffect(elem.Effect),
1241-
TolerationSeconds: &elem.TolerationSeconds,
1240+
TolerationSeconds: tolerationSeconds,
12421241
}
12431242
tolerations = append(tolerations, toleration)
12441243
}
@@ -1434,12 +1433,18 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
14341433
// parse tolerations
14351434
var tolerations models.ZoneTolerations
14361435
for _, elem := range zone.Tolerations {
1436+
var tolerationSecs *models.ZoneTolerationSeconds
1437+
if elem.TolerationSeconds != nil {
1438+
tolerationSecs = &models.ZoneTolerationSeconds{
1439+
Seconds: elem.TolerationSeconds,
1440+
}
1441+
}
14371442
toleration := &models.ZoneTolerationsItems0{
14381443
Key: elem.Key,
14391444
Operator: string(elem.Operator),
14401445
Value: elem.Value,
14411446
Effect: string(elem.Effect),
1442-
TolerationSeconds: *elem.TolerationSeconds,
1447+
TolerationSeconds: tolerationSecs,
14431448
}
14441449
tolerations = append(tolerations, toleration)
14451450
}

restapi/embedded_spec.go

Lines changed: 28 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swagger.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,21 +2113,29 @@ definitions:
21132113
category.
21142114
type: string
21152115
tolerationSeconds:
2116-
description: TolerationSeconds represents the period of
2117-
time the toleration (which must be of effect NoExecute,
2118-
otherwise this field is ignored) tolerates the taint.
2119-
By default, it is not set, which means tolerate the taint
2120-
forever (do not evict). Zero and negative values will
2121-
be treated as 0 (evict immediately) by the system.
2122-
format: int64
2123-
type: integer
2116+
$ref: "#/definitions/zoneTolerationSeconds"
21242117
value:
21252118
description: Value is the taint value the toleration matches
21262119
to. If the operator is Exists, the value should be empty,
21272120
otherwise just a regular string.
21282121
type: string
21292122
type: object
21302123
type: array
2124+
2125+
zoneTolerationSeconds:
2126+
description: TolerationSeconds represents the period of
2127+
time the toleration (which must be of effect NoExecute,
2128+
otherwise this field is ignored) tolerates the taint.
2129+
By default, it is not set, which means tolerate the taint
2130+
forever (do not evict). Zero and negative values will
2131+
be treated as 0 (evict immediately) by the system.
2132+
type: object
2133+
required:
2134+
- seconds
2135+
properties:
2136+
seconds:
2137+
type: integer
2138+
format: int64
21312139

21322140
zoneResources:
21332141
description: If provided, use these requests and limit for cpu/memory

0 commit comments

Comments
 (0)