Skip to content

Commit

Permalink
Add option for per location disk space quota
Browse files Browse the repository at this point in the history
Default heuristic does not work when locations share one volume,
or when volume does not have any space limit.
  • Loading branch information
koct9i committed Jun 11, 2024
1 parent 91956c2 commit 72344a2
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 19 deletions.
6 changes: 6 additions & 0 deletions api/v1/ytsaurus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/apimachinery/pkg/api/resource"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down Expand Up @@ -86,6 +88,10 @@ type LocationSpec struct {

//+kubebuilder:default:=default
Medium string `json:"medium,omitempty"`

// Disk space quota, default is size of related volume.
//+optional
Quota *resource.Quantity `json:"quota,omitempty"`
}

// LogLevel string describes possible Ytsaurus logging level.
Expand Down
9 changes: 8 additions & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,13 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down
120 changes: 120 additions & 0 deletions config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -3112,6 +3120,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -5457,6 +5473,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -7953,6 +7977,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -10325,6 +10357,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -12710,6 +12750,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -15091,6 +15139,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -17425,6 +17481,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -19749,6 +19813,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -22080,6 +22152,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -24447,6 +24527,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -26786,6 +26874,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -29189,6 +29285,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -31540,6 +31644,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down Expand Up @@ -34093,6 +34205,14 @@ spec:
path:
minLength: 1
type: string
quota:
anyOf:
- type: integer
- type: string
description: Disk space quota, default is size of related
volume.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: array
loggers:
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ _Appears in:_
| `locationType` _[LocationType](#locationtype)_ | | | |
| `path` _string_ | | | MinLength: 1 <br /> |
| `medium` _string_ | | default | |
| `quota` _[Quantity](#quantity)_ | Disk space quota, default is size of related volume. | | |


#### LocationType
Expand Down
4 changes: 4 additions & 0 deletions pkg/ytconfig/canondata/TestGetDataNodeConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
{
path="/yt/hdd1/chunk-store";
"medium_name"=nvme;
quota=10737418240;
"high_watermark"=536870912;
"low_watermark"=1073741824;
"disable_writes_watermark"=268435456;
};
];
"cache_locations"=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
path="/yt/hdd1/chunk-store";
"medium_name"=nvme;
quota=10737418240;
"high_watermark"=536870912;
"low_watermark"=1073741824;
"disable_writes_watermark"=268435456;
};
];
"cache_locations"=[
Expand Down
3 changes: 2 additions & 1 deletion pkg/ytconfig/canondata/TestGetExecNodeConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
{
path="/yt/hdd2/slots";
"medium_name"="";
"disk_usage_watermark"=0;
"disk_quota"=5368709120;
"disk_usage_watermark"=536870912;
"enable_disk_quota"=%false;
};
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
{
path="/yt/hdd2/slots";
"medium_name"="";
"disk_usage_watermark"=0;
"disk_quota"=5368709120;
"disk_usage_watermark"=536870912;
"enable_disk_quota"=%false;
};
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
{
path="/yt/hdd2/slots";
"medium_name"="";
"disk_usage_watermark"=0;
"disk_quota"=5368709120;
"disk_usage_watermark"=536870912;
"enable_disk_quota"=%false;
};
];
Expand Down
13 changes: 11 additions & 2 deletions pkg/ytconfig/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ var (
LocationType: "ChunkCache",
Path: "/yt/hdd1/chunk-cache",
}
testLocationSlots = ytv1.LocationSpec{
testLocationSlotsQuota = resource.MustParse("5Gi")
testLocationSlots = ytv1.LocationSpec{
LocationType: "Slots",
Path: "/yt/hdd2/slots",
Quota: &testLocationSlotsQuota,
}
testLocationImageCache = ytv1.LocationSpec{
testLocationImageCacheQuota = resource.MustParse("4Gi")
testLocationImageCache = ytv1.LocationSpec{
LocationType: "ImageCache",
Path: "/yt/hdd1/images",
Quota: &testLocationImageCacheQuota,
}
testVolumeMounts = []corev1.VolumeMount{
{
Expand All @@ -76,6 +80,11 @@ var (
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
StorageClassName: &testStorageClassname,
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("10Gi"),
},
},
},
},
}
Expand Down
Loading

0 comments on commit 72344a2

Please sign in to comment.