Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saving quota in GiB instead GB #2895

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading