@@ -293,12 +293,6 @@ func getTenantInfo(tenant *operator.Tenant) *models.Tenant {
293
293
consoleImage = tenant .Spec .Console .Image
294
294
}
295
295
296
- if tenant .Spec .Metadata == nil {
297
- tenant .Spec .Metadata = & metav1.ObjectMeta {
298
- Annotations : map [string ]string {},
299
- }
300
- }
301
-
302
296
return & models.Tenant {
303
297
CreationDate : tenant .ObjectMeta .CreationTimestamp .String (),
304
298
DeletionDate : deletion ,
@@ -309,7 +303,7 @@ func getTenantInfo(tenant *operator.Tenant) *models.Tenant {
309
303
Namespace : tenant .ObjectMeta .Namespace ,
310
304
Image : tenant .Spec .Image ,
311
305
ConsoleImage : consoleImage ,
312
- EnablePrometheus : isPrometheusEnabled (tenant .Spec . Metadata . Annotations ),
306
+ EnablePrometheus : isPrometheusEnabled (tenant .Annotations ),
313
307
}
314
308
}
315
309
@@ -507,7 +501,8 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
507
501
//Construct a MinIO Instance with everything we are getting from parameters
508
502
minInst := operator.Tenant {
509
503
ObjectMeta : metav1.ObjectMeta {
510
- Name : tenantName ,
504
+ Name : tenantName ,
505
+ Labels : tenantReq .Labels ,
511
506
},
512
507
Spec : operator.TenantSpec {
513
508
Image : minioImage ,
@@ -698,18 +693,14 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
698
693
}
699
694
// add annotations
700
695
var annotations map [string ]string
701
- if minInst .Spec .Metadata == nil {
702
- minInst .Spec .Metadata = & metav1.ObjectMeta {
703
- Annotations : map [string ]string {},
704
- }
705
- }
696
+
706
697
if len (tenantReq .Annotations ) > 0 {
707
698
annotations = tenantReq .Annotations
708
- minInst .Spec . Metadata . Annotations = annotations
699
+ minInst .Annotations = annotations
709
700
}
710
701
// set the zones if they are provided
711
702
for _ , zone := range tenantReq .Zones {
712
- zone , err := parseTenantZoneRequest (zone , annotations )
703
+ zone , err := parseTenantZoneRequest (zone )
713
704
if err != nil {
714
705
return nil , prepareError (err )
715
706
}
@@ -737,10 +728,10 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
737
728
}
738
729
739
730
// prometheus annotations support
740
- if tenantReq .EnablePrometheus != nil && * tenantReq .EnablePrometheus && minInst .Spec . Metadata != nil && minInst . Spec . Metadata . Annotations != nil {
741
- minInst .Spec . Metadata . Annotations [prometheusPath ] = "/minio/prometheus/metrics"
742
- minInst .Spec . Metadata . Annotations [prometheusPort ] = fmt .Sprint (operator .MinIOPort )
743
- minInst .Spec . Metadata . Annotations [prometheusScrape ] = "true"
731
+ if tenantReq .EnablePrometheus != nil && * tenantReq .EnablePrometheus && minInst .Annotations != nil {
732
+ minInst .Annotations [prometheusPath ] = "/minio/prometheus/metrics"
733
+ minInst .Annotations [prometheusPort ] = fmt .Sprint (operator .MinIOPort )
734
+ minInst .Annotations [prometheusScrape ] = "true"
744
735
}
745
736
746
737
// set console image if provided
@@ -875,20 +866,15 @@ func updateTenantAction(ctx context.Context, operatorClient OperatorClientI, cli
875
866
}
876
867
877
868
// Prometheus Annotations
878
- if minInst .Spec .Metadata == nil {
879
- minInst .Spec .Metadata = & metav1.ObjectMeta {
880
- Annotations : map [string ]string {},
881
- }
882
- }
883
- currentAnnotations := minInst .Spec .Metadata .Annotations
869
+ currentAnnotations := minInst .Annotations
884
870
prometheusAnnotations := map [string ]string {
885
871
prometheusPath : "/minio/prometheus/metrics" ,
886
872
prometheusPort : fmt .Sprint (operator .MinIOPort ),
887
873
prometheusScrape : "true" ,
888
874
}
889
875
if params .Body .EnablePrometheus && minInst .Spec .Metadata != nil && currentAnnotations != nil {
890
876
// add prometheus annotations to the tenant
891
- minInst .Spec . Metadata . Annotations = addAnnotations (currentAnnotations , prometheusAnnotations )
877
+ minInst .Annotations = addAnnotations (currentAnnotations , prometheusAnnotations )
892
878
// add prometheus annotations to the each zone
893
879
if minInst .Spec .Zones != nil {
894
880
for _ , zone := range minInst .Spec .Zones {
@@ -898,7 +884,7 @@ func updateTenantAction(ctx context.Context, operatorClient OperatorClientI, cli
898
884
}
899
885
} else {
900
886
// remove prometheus annotations to the tenant
901
- minInst .Spec . Metadata . Annotations = removeAnnotations (currentAnnotations , prometheusAnnotations )
887
+ minInst .Annotations = removeAnnotations (currentAnnotations , prometheusAnnotations )
902
888
// add prometheus annotations from each zone
903
889
if minInst .Spec .Zones != nil {
904
890
for _ , zone := range minInst .Spec .Zones {
@@ -974,7 +960,7 @@ func addTenantZone(ctx context.Context, operatorClient OperatorClientI, params a
974
960
}
975
961
976
962
zoneParams := params .Body
977
- zone , err := parseTenantZoneRequest (zoneParams , tenant . ObjectMeta . Annotations )
963
+ zone , err := parseTenantZoneRequest (zoneParams )
978
964
if err != nil {
979
965
return err
980
966
}
@@ -1062,7 +1048,7 @@ func getTenantUsageResponse(session *models.Principal, params admin_api.GetTenan
1062
1048
1063
1049
// parseTenantZoneRequest parse zone request and returns the equivalent
1064
1050
// operator.Zone object
1065
- func parseTenantZoneRequest (zoneParams * models.Zone , annotations map [ string ] string ) (* operator.Zone , error ) {
1051
+ func parseTenantZoneRequest (zoneParams * models.Zone ) (* operator.Zone , error ) {
1066
1052
if zoneParams .VolumeConfiguration == nil {
1067
1053
return nil , errors .New ("a volume configuration must be specified" )
1068
1054
}
@@ -1211,14 +1197,12 @@ func parseTenantZoneRequest(zoneParams *models.Zone, annotations map[string]stri
1211
1197
// Pass annotations to the volume
1212
1198
vct := & corev1.PersistentVolumeClaim {
1213
1199
ObjectMeta : metav1.ObjectMeta {
1214
- Name : "data" ,
1215
- Labels : zoneParams .VolumeConfiguration .Labels ,
1200
+ Name : "data" ,
1201
+ Labels : zoneParams .VolumeConfiguration .Labels ,
1202
+ Annotations : zoneParams .VolumeConfiguration .Annotations ,
1216
1203
},
1217
1204
Spec : volTemp ,
1218
1205
}
1219
- if len (annotations ) > 0 {
1220
- vct .ObjectMeta .Annotations = annotations
1221
- }
1222
1206
1223
1207
zone := & operator.Zone {
1224
1208
Name : zoneParams .Name ,
@@ -1512,16 +1496,10 @@ func updateTenantZones(
1512
1496
return nil , err
1513
1497
}
1514
1498
1515
- if minInst .Spec .Metadata == nil {
1516
- minInst .Spec .Metadata = & metav1.ObjectMeta {
1517
- Annotations : map [string ]string {},
1518
- }
1519
- }
1520
-
1521
1499
// set the zones if they are provided
1522
1500
var newZoneArray []operator.Zone
1523
1501
for _ , zone := range zonesReq {
1524
- zone , err := parseTenantZoneRequest (zone , minInst . Spec . Metadata . Annotations )
1502
+ zone , err := parseTenantZoneRequest (zone )
1525
1503
if err != nil {
1526
1504
return nil , err
1527
1505
}
0 commit comments