Skip to content

Commit

Permalink
Merge pull request #2895 from rchikatw/sendhashin
Browse files Browse the repository at this point in the history
saving quota in GiB instead GB
  • Loading branch information
openshift-merge-bot[bot] authored Nov 18, 2024
2 parents 07cbcfa + ae834a2 commit 4f34f9e
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"
oneGibInBytes = 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)*oneGibInBytes,
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)*oneGibInBytes,
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)*oneGibInBytes, 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 4f34f9e

Please sign in to comment.