Skip to content

Commit

Permalink
server: saving quota in GiB instead GB
Browse files Browse the repository at this point in the history
Signed-off-by: rchikatw <[email protected]>
  • Loading branch information
rchikatw committed Nov 14, 2024
1 parent 99fdb66 commit b3369f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
ramenDRStorageIDKey = "ramendr.openshift.io/storageID"
ramenDRReplicationIDKey = "ramendr.openshift.io/replicationid"
ramenDRFlattenModeKey = "replication.storage.openshift.io/flatten-mode"
oneGibiBytes = 1024 * 1024 * 1024
)

const (
Expand Down Expand Up @@ -407,9 +408,9 @@ func (s *OCSProviderServer) getExternalResources(ctx context.Context, consumerRe
},
},
Quota: corev1.ResourceQuotaSpec{
Hard: corev1.ResourceList{"requests.storage": *resource.NewScaledQuantity(
int64(consumerResource.Spec.StorageQuotaInGiB),
resource.Giga,
Hard: corev1.ResourceList{"requests.storage": *resource.NewQuantity(
int64(consumerResource.Spec.StorageQuotaInGiB)*oneGibiBytes,
resource.BinarySI,
)},
},
}
Expand Down
11 changes: 6 additions & 5 deletions services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ var clusterResourceQuotaSpec = &quotav1.ClusterResourceQuotaSpec{
},
},
Quota: corev1.ResourceQuotaSpec{
Hard: corev1.ResourceList{"requests.storage": *resource.NewScaledQuantity(
int64(consumerResource.Spec.StorageQuotaInGiB),
resource.Giga,
Hard: corev1.ResourceList{"requests.storage": *resource.NewQuantity(
int64(consumerResource.Spec.StorageQuotaInGiB)*oneGibiBytes,
resource.BinarySI,
)},
},
}
Expand Down Expand Up @@ -337,8 +337,9 @@ func TestGetExternalResources(t *testing.T) {
var clusterResourceQuotaSpec quotav1.ClusterResourceQuotaSpec
err = json.Unmarshal([]byte(extResource.Data), &clusterResourceQuotaSpec)
assert.NoError(t, err)
quantity, _ := resource.ParseQuantity("10240G")
assert.Equal(t, clusterResourceQuotaSpec.Quota.Hard["requests.storage"], quantity)
expected := resource.NewQuantity(int64(10240)*oneGibiBytes, resource.BinarySI)
actual := clusterResourceQuotaSpec.Quota.Hard["requests.storage"]
assert.Equal(t, actual.Value(), expected.Value())
} else if extResource.Kind == "Noobaa" {
var extNoobaaSpec, mockNoobaaSpec nbv1.NooBaaSpec
err = json.Unmarshal(extResource.Data, &extNoobaaSpec)
Expand Down

0 comments on commit b3369f6

Please sign in to comment.