Skip to content

Commit 9430a5d

Browse files
committed
Allow to define per api Image Cache size
We are able to deploy an arbitrary number of glanceAPI. Each api/replicas, however, should have its own image-cache pvc as they are separate entities. This patch improves the API to allow to either inherit the imageCacheSize or define it on a per instance basis. Signed-off-by: Francesco Pantano <[email protected]>
1 parent 7c87bfa commit 9430a5d

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

api/bases/glance.openstack.org_glances.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,9 @@ spec:
832832
items:
833833
type: string
834834
type: array
835+
imageCacheSize:
836+
default: ""
837+
type: string
835838
networkAttachments:
836839
items:
837840
type: string
@@ -961,6 +964,7 @@ spec:
961964
type: string
962965
required:
963966
- containerImage
967+
- imageCacheSize
964968
- storageRequest
965969
type: object
966970
type: object

api/v1beta1/common_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ type GlanceAPITemplate struct {
107107
// +operator-sdk:csv:customresourcedefinitions:type=spec
108108
// TLS - Parameters related to the TLS
109109
TLS tls.API `json:"tls,omitempty"`
110+
111+
// ImageCacheSize, provides the size of the cache that will be reflected in the image_cache_max_size parameter
112+
// +kubebuilder:default=""
113+
ImageCacheSize string `json:"imageCacheSize"`
110114
}
111115

112116
// APIOverrideSpec to override the generated manifest of several child resources.

api/v1beta1/glanceapi_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ type GlanceAPISpec struct {
7777
// QuotaEnforce if true, per-tenant quotas are enforced according to the
7878
// registered keystone limits
7979
Quota bool `json:"quota"`
80-
81-
// ImageCacheSize, provides the size of the cache that will be reflected in the image_cache_max_size parameter
82-
// +kubebuilder:default=""
83-
ImageCacheSize string `json:"imageCacheSize"`
8480
}
8581

8682
// GlanceAPIStatus defines the observed state of GlanceAPI

config/crd/bases/glance.openstack.org_glances.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,9 @@ spec:
832832
items:
833833
type: string
834834
type: array
835+
imageCacheSize:
836+
default: ""
837+
type: string
835838
networkAttachments:
836839
items:
837840
type: string
@@ -961,6 +964,7 @@ spec:
961964
type: string
962965
required:
963966
- containerImage
967+
- imageCacheSize
964968
- storageRequest
965969
type: object
966970
type: object

controllers/glance_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,13 +813,17 @@ func (r *GlanceReconciler) apiDeploymentCreateOrUpdate(
813813
ServiceUser: instance.Spec.ServiceUser,
814814
ServiceAccount: instance.RbacResourceName(),
815815
Quota: instance.IsQuotaEnabled(),
816-
ImageCacheSize: instance.Spec.ImageCacheSize,
817816
}
818817

819818
if apiSpec.GlanceAPITemplate.NodeSelector == nil {
820819
apiSpec.GlanceAPITemplate.NodeSelector = instance.Spec.NodeSelector
821820
}
822821

822+
// Inherit the ImageCacheSize from the top level if not specified
823+
if apiSpec.GlanceAPITemplate.ImageCacheSize == "" {
824+
apiSpec.GlanceAPITemplate.ImageCacheSize = instance.Spec.ImageCacheSize
825+
}
826+
823827
// Inherit the values required for PVC creation from the top-level CR
824828
apiSpec.GlanceAPITemplate.StorageRequest = instance.Spec.StorageRequest
825829
apiSpec.GlanceAPITemplate.StorageClass = instance.Spec.StorageClass

pkg/glance/volumes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func GetHttpdVolumeMount() []corev1.VolumeMount {
283283
func GetCacheVolume(pvcName string) []corev1.Volume {
284284
return []corev1.Volume{
285285
{
286-
Name: "image-cache",
286+
Name: "glance-cache",
287287
VolumeSource: corev1.VolumeSource{
288288
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
289289
ClaimName: pvcName,
@@ -297,7 +297,7 @@ func GetCacheVolume(pvcName string) []corev1.Volume {
297297
func GetCacheVolumeMount() []corev1.VolumeMount {
298298
return []corev1.VolumeMount{
299299
{
300-
Name: "image-cache",
300+
Name: "glance-cache",
301301
MountPath: ImageCacheDir,
302302
ReadOnly: false,
303303
},

pkg/glanceapi/statefulset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func StatefulSet(
131131
// If cache is provided, we expect the main glance_controller to request a
132132
// PVC that should be used for that purpose (according to ImageCacheSize)
133133
if len(instance.Spec.ImageCacheSize) > 0 {
134-
apiVolumes = append(apiVolumes, glance.GetCacheVolume(glance.ServiceName+"-cache")...)
135134
apiVolumeMounts = append(apiVolumeMounts, glance.GetCacheVolumeMount()...)
136135
}
137136

0 commit comments

Comments
 (0)