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

Reserve overhead when validating that a Filesystem has enough space #1319

Merged
merged 8 commits into from Oct 1, 2020
25 changes: 25 additions & 0 deletions api/openapi-spec/swagger.json
Expand Up @@ -3416,6 +3416,10 @@
"type": "string"
}
},
"filesystemOverhead": {
"description": "FilesystemOverhead describes the space reserved for overhead when using Filesystem volumes. A value is between 0 and 1, if not defined it is 0.055 (5.5% overhead)",
"$ref": "#/definitions/v1beta1.FilesystemOverhead"
},
"podResourceRequirements": {
"description": "ResourceRequirements describes the compute resource requirements.",
"$ref": "#/definitions/v1.ResourceRequirements"
Expand All @@ -3439,6 +3443,10 @@
"description": "ResourceRequirements describes the compute resource requirements.",
"$ref": "#/definitions/v1.ResourceRequirements"
},
"filesystemOverhead": {
"description": "FilesystemOverhead describes the space reserved for overhead when using Filesystem volumes. A percentage value is between 0 and 1",
"$ref": "#/definitions/v1beta1.FilesystemOverhead"
},
"scratchSpaceStorageClass": {
"description": "The calculated storage class to be used for scratch space",
"type": "string"
Expand Down Expand Up @@ -3833,6 +3841,23 @@
}
}
},
"v1beta1.FilesystemOverhead": {
"description": "FilesystemOverhead defines the reserved size for PVCs with VolumeMode: Filesystem",
"type": "object",
"properties": {
"global": {
"description": "Global is how much space of a Filesystem volume should be reserved for overhead. This value is used unless overridden by a more specific value (per storageClass)",
"type": "string"
},
"storageClass": {
"description": "StorageClass specifies how much space of a Filesystem volume should be reserved for safety. The keys are the storageClass and the values are the overhead. This value overrides the global value",
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"v1beta1.UploadTokenRequest": {
"description": "UploadTokenRequest is the CR used to initiate a CDI upload",
"type": "object",
Expand Down
3 changes: 2 additions & 1 deletion cmd/cdi-importer/importer.go
Expand Up @@ -57,6 +57,7 @@ func main() {
contentType, _ := util.ParseEnvVar(common.ImporterContentType, false)
imageSize, _ := util.ParseEnvVar(common.ImporterImageSize, false)
certDir, _ := util.ParseEnvVar(common.ImporterCertDirVar, false)
filesystemOverhead, _ := strconv.ParseFloat(os.Getenv(common.FilesystemOverheadVar), 64)
insecureTLS, _ := strconv.ParseBool(os.Getenv(common.InsecureTLSVar))
diskID, _ := util.ParseEnvVar(common.ImporterDiskID, false)
uuid, _ := util.ParseEnvVar(common.ImporterUUID, false)
Expand Down Expand Up @@ -167,7 +168,7 @@ func main() {
os.Exit(1)
}
defer dp.Close()
processor := importer.NewDataProcessor(dp, dest, dataDir, common.ScratchDataDir, imageSize)
processor := importer.NewDataProcessor(dp, dest, dataDir, common.ScratchDataDir, imageSize, filesystemOverhead)
err = processor.ProcessData()
if err != nil {
klog.Errorf("%+v", err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/cdi-uploadserver/uploadserver.go
Expand Up @@ -50,6 +50,8 @@ func main() {

destination := getDestination()

filesystemOverhead, _ := strconv.ParseFloat(os.Getenv(common.FilesystemOverheadVar), 64)

server := uploadserver.NewUploadServer(
listenAddress,
listenPort,
Expand All @@ -59,6 +61,7 @@ func main() {
os.Getenv("CLIENT_CERT"),
os.Getenv("CLIENT_NAME"),
os.Getenv(common.UploadImageSize),
filesystemOverhead,
)

klog.Infof("Upload destination: %s", destination)
Expand Down
8 changes: 8 additions & 0 deletions doc/cdi-config.md
Expand Up @@ -11,10 +11,18 @@ Currently it is used only for holding Upload Proxy URL details.
|-------------------------|-----------------------|-----------------------------------------------------|
| uploadProxyURLOverride | nil | A user defined URL for Upload Proxy service. |
| scratchSpaceStorageClass| nil | The storage class used to create scratch space |
| podResourceRequirements | nil | Resources to request for CDI utility pods, for running on namespaces with quota requirements. Uses the same syntax as a [Pod resource](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) type. |
| featureGates | nil | Enable opt-in features like [Wait For First Consumer handling](waitforfirstconsumer-storage-handling.md) |
| filesystemOverhead | | How much of a Filesystem volume's space should be reserved for overhead related to the Filesystem. |
| global | "0.055" | The amount to reserve for a Filesystem volume unless a per-storageClass value is chosen. |
| storageClass | nil | A value of `local: "0.6"` is understood to mean that the overhead for the local storageClass is 0.6. |

## Configuration Status Fields

| Name | Default value | |
|-------------------------|-----------------------|-----------------------------------------------------|
| uploadProxyURL | nil | updated when a new Ingress or Route (Openshift) is created. If `uploadProxyURLOverride` is set, Ingress/Route URL will be ignored and `uploadProxyURL` will be updated with the user defined URL. |
| filesystemOverhead | | updated when the spec values are updated, to show the per-storageClass calculated result as well as the per-storageClass one. |
| global | "0.055" | The calculated overhead to be used for all storageClasses unless a specific value is chosen for this storageClass |
| storageClass | | The calculated overhead to be used for every storageClass in the system, taking into account both global and per-storageClass values. |

52 changes: 50 additions & 2 deletions pkg/apis/core/v1alpha1/openapi_generated.go

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

17 changes: 17 additions & 0 deletions pkg/apis/core/v1alpha1/types.go
Expand Up @@ -349,6 +349,19 @@ type CDIConfig struct {
Status CDIConfigStatus `json:"status,omitempty"`
}

//Percent is a string that can only be a value between [0,1)
// (Note: we actually rely on reconcile to reject invalid values)
// +kubebuilder:validation:Pattern=`^(0(?:\.\d{1,3})?|1)$`
type Percent string

//FilesystemOverhead defines the reserved size for PVCs with VolumeMode: Filesystem
type FilesystemOverhead struct {
// Global is how much space of a Filesystem volume should be reserved for overhead. This value is used unless overridden by a more specific value (per storageClass)
Global Percent `json:"global,omitempty"`
// StorageClass specifies how much space of a Filesystem volume should be reserved for safety. The keys are the storageClass and the values are the overhead. This value overrides the global value
StorageClass map[string]Percent `json:"storageClass,omitempty"`
}

//CDIConfigSpec defines specification for user configuration
type CDIConfigSpec struct {
// Override the URL used when uploading to a DataVolume
Expand All @@ -357,6 +370,8 @@ type CDIConfigSpec struct {
ScratchSpaceStorageClass *string `json:"scratchSpaceStorageClass,omitempty"`
// ResourceRequirements describes the compute resource requirements.
PodResourceRequirements *corev1.ResourceRequirements `json:"podResourceRequirements,omitempty"`
// FilesystemOverhead describes the space reserved for overhead when using Filesystem volumes. A value is between 0 and 1, if not defined it is 0.055 (5.5% overhead)
FilesystemOverhead *FilesystemOverhead `json:"filesystemOverhead,omitempty"`
}

//CDIConfigStatus provides the most recently observed status of the CDI Config resource
Expand All @@ -367,6 +382,8 @@ type CDIConfigStatus struct {
ScratchSpaceStorageClass string `json:"scratchSpaceStorageClass,omitempty"`
// ResourceRequirements describes the compute resource requirements.
DefaultPodResourceRequirements *corev1.ResourceRequirements `json:"defaultPodResourceRequirements,omitempty"`
// FilesystemOverhead describes the space reserved for overhead when using Filesystem volumes. A percentage value is between 0 and 1
FilesystemOverhead *FilesystemOverhead `json:"filesystemOverhead,omitempty"`
}

//CDIConfigList provides the needed parameters to do request a list of CDIConfigs from the system
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/core/v1alpha1/types_swagger_generated.go

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

33 changes: 33 additions & 0 deletions pkg/apis/core/v1alpha1/zz_generated.deepcopy.go

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

52 changes: 50 additions & 2 deletions pkg/apis/core/v1beta1/openapi_generated.go

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