Skip to content

Commit a23e87b

Browse files
committed
Convert types according to CRD fields
1 parent f727ba9 commit a23e87b

File tree

6 files changed

+23
-34
lines changed

6 files changed

+23
-34
lines changed

config/crd/bases/mcad.ibm.com_appwrappers.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,18 @@ spec:
787787
totalcpu:
788788
description: The number of CPU consumed by all pods belonging to the
789789
AppWrapper.
790-
type: number
790+
format: int32
791+
type: integer
791792
totalgpu:
792793
description: The total number of GPUs consumed by all pods belonging
793794
to the AppWrapper.
794-
format: int64
795+
format: int32
795796
type: integer
796797
totalmemory:
797798
description: The amount of memory consumed by all pods belonging to
798799
the AppWrapper.
799-
type: number
800+
format: int32
801+
type: integer
800802
type: object
801803
required:
802804
- spec

deployment/mcad-controller/crds/mcad.ibm.com_appwrappers.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,18 @@ spec:
787787
totalcpu:
788788
description: The number of CPU consumed by all pods belonging to the
789789
AppWrapper.
790-
type: number
790+
format: int32
791+
type: integer
791792
totalgpu:
792793
description: The total number of GPUs consumed by all pods belonging
793794
to the AppWrapper.
794-
format: int64
795+
format: int32
795796
type: integer
796797
totalmemory:
797798
description: The amount of memory consumed by all pods belonging to
798799
the AppWrapper.
799-
type: number
800+
format: int32
801+
type: integer
800802
type: object
801803
required:
802804
- spec

pkg/apis/controller/v1beta1/appwrapper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ type AppWrapperStatus struct {
212212
// Resources consumed
213213

214214
// The number of CPU consumed by all pods belonging to the AppWrapper.
215-
TotalCPU float64 `json:"totalcpu,omitempty"`
215+
TotalCPU int32 `json:"totalcpu,omitempty"`
216216

217217
// The amount of memory consumed by all pods belonging to the AppWrapper.
218-
TotalMemory float64 `json:"totalmemory,omitempty"`
218+
TotalMemory int32 `json:"totalmemory,omitempty"`
219219

220220
// The total number of GPUs consumed by all pods belonging to the AppWrapper.
221-
TotalGPU int64 `json:"totalgpu,omitempty"`
221+
TotalGPU int32 `json:"totalgpu,omitempty"`
222222

223223
// Field to keep track of total number of seconds spent in requeueing
224224
RequeueingTimeInSeconds int `json:"requeueingTimeInSeconds,omitempty"`

pkg/controller/clusterstate/api/resource_info.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
/*
2-
Copyright 2017 The Kubernetes Authors.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
16-
/*
172
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
183
194
Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2813
See the License for the specific language governing permissions and
2914
limitations under the License.
3015
*/
16+
3117
package api
3218

3319
import (
@@ -116,12 +102,12 @@ func (r *Resource) Replace(rr *Resource) *Resource {
116102
return r
117103
}
118104

119-
//Sub subtracts two Resource objects.
105+
// Sub subtracts two Resource objects.
120106
func (r *Resource) Sub(rr *Resource) (*Resource, error) {
121107
return r.NonNegSub(rr)
122108
}
123109

124-
//Sub subtracts two Resource objects and return zero for negative subtractions.
110+
// Sub subtracts two Resource objects and return zero for negative subtractions.
125111
func (r *Resource) NonNegSub(rr *Resource) (*Resource, error) {
126112
// Check for negative calculation
127113
var isNegative bool

pkg/controller/queuejob/queuejob_controller_ex.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,11 @@ func (qjm *XController) getDispatchedAppWrappers() (map[string]*clusterstateapi.
702702
return awrRetVal, awsRetVal
703703
}
704704

705-
func (qjm *XController) addTotalSnapshotResourcesConsumedByAw(totalgpu int64, totalcpu float64, totalmemory float64) *clusterstateapi.Resource {
706-
705+
func (qjm *XController) addTotalSnapshotResourcesConsumedByAw(totalgpu int32, totalcpu int32, totalmemory int32) *clusterstateapi.Resource {
707706
totalResource := clusterstateapi.EmptyResource()
708-
totalResource.GPU = totalgpu
709-
totalResource.MilliCPU = totalcpu
710-
totalResource.Memory = totalmemory
707+
totalResource.GPU = int64(totalgpu)
708+
totalResource.MilliCPU = float64(totalcpu)
709+
totalResource.Memory = float64(totalmemory)
711710

712711
return totalResource
713712

pkg/controller/queuejobresources/pod/pod.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ func (qjrPod *QueueJobResPod) UpdateQueueJobStatus(queuejob *arbv1.AppWrapper) e
214214
queuejob.Status.Succeeded = succeeded
215215
queuejob.Status.Failed = failed
216216
// Total resources by all running pods
217-
queuejob.Status.TotalGPU = totalResourcesConsumedForPodPhases.GPU
218-
queuejob.Status.TotalCPU = totalResourcesConsumedForPodPhases.MilliCPU
219-
queuejob.Status.TotalMemory = totalResourcesConsumedForPodPhases.Memory
217+
queuejob.Status.TotalGPU = int32(totalResourcesConsumedForPodPhases.GPU)
218+
queuejob.Status.TotalCPU = int32(totalResourcesConsumedForPodPhases.MilliCPU)
219+
queuejob.Status.TotalMemory = int32(totalResourcesConsumedForPodPhases.Memory)
220220

221221
queuejob.Status.PendingPodConditions = nil
222222
for podName, cond := range podsConditionMap {

0 commit comments

Comments
 (0)