Skip to content

Commit 1c470da

Browse files
Merge pull request #863 from fmount/containerImage
Move ContainerImage field from GlanceAPITemplate to GlanceAPI spec
2 parents 8d5156c + 27adffc commit 1c470da

10 files changed

Lines changed: 15 additions & 41 deletions

api/bases/glance.openstack.org_glanceapis.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ spec:
6666
- edge
6767
type: string
6868
containerImage:
69-
description: Glance Container Image URL (will be set to environmental
70-
default if empty)
69+
description: ContainerImage - GlanceAPI Container Image URL
7170
type: string
7271
customServiceConfig:
7372
description: |-

api/bases/glance.openstack.org_glances.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,6 @@ spec:
12291229
APITimeout
12301230
minimum: 1
12311231
type: integer
1232-
containerImage:
1233-
description: Glance Container Image URL (will be set to environmental
1234-
default if empty)
1235-
type: string
12361232
customServiceConfig:
12371233
description: |-
12381234
CustomServiceConfig - customize the service config using this parameter to change service defaults,
@@ -1578,8 +1574,6 @@ spec:
15781574
- single
15791575
- edge
15801576
type: string
1581-
required:
1582-
- containerImage
15831577
type: object
15841578
default: {}
15851579
description: GlanceAPIs - Spec definition for the API service of this

api/v1beta1/common_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ type GlanceAPITemplate struct {
5454
// Replicas of glance API to run
5555
Replicas *int32 `json:"replicas"`
5656

57-
// +kubebuilder:validation:Required
58-
// Glance Container Image URL (will be set to environmental default if empty)
59-
ContainerImage string `json:"containerImage"`
60-
6157
// +kubebuilder:validation:Optional
6258
// NodeSelector to target subset of worker nodes running this service
6359
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`

api/v1beta1/glance_webhook.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ var _ webhook.Defaulter = &Glance{}
6666
func (r *Glance) Default() {
6767
glancelog.Info("default", "name", r.Name)
6868

69+
// .Spec.ContainerImage is inherited by all the GlanceAPI instances.
70+
// It's not supported to deploy different ContainerImages for different
71+
// instances.
6972
if len(r.Spec.ContainerImage) == 0 {
7073
r.Spec.ContainerImage = glanceDefaults.ContainerImageURL
7174
}
@@ -116,7 +119,7 @@ func (r *GlanceSpecCore) Default() {
116119
// build a "CustomServiceConfig" template that should be
117120
// customized: by doing this we force to provide the
118121
// required parameters
119-
if r.GlanceAPIs == nil || len(r.GlanceAPIs) == 0 {
122+
if len(r.GlanceAPIs) == 0 {
120123
// keystoneEndpoint will match with the only instance
121124
// deployed by default
122125
r.KeystoneEndpoint = "default"
@@ -129,11 +132,6 @@ func (r *GlanceSpecCore) Default() {
129132
}
130133

131134
for key, glanceAPI := range r.GlanceAPIs {
132-
// Check the sub-cr ContainerImage parameter
133-
if glanceAPI.ContainerImage == "" {
134-
glanceAPI.ContainerImage = glanceDefaults.ContainerImageURL
135-
r.GlanceAPIs[key] = glanceAPI
136-
}
137135
if glanceAPI.ImageCache.CleanerScheduler == "" {
138136
glanceAPI.ImageCache.CleanerScheduler = glanceDefaults.CleanerSchedule
139137
r.GlanceAPIs[key] = glanceAPI

api/v1beta1/glanceapi_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ type GlanceAPISpec struct {
3838
// Input parameter coming from glance template
3939
GlanceAPITemplate `json:",inline"`
4040

41+
// +kubebuilder:validation:Required
42+
// ContainerImage - GlanceAPI Container Image URL
43+
ContainerImage string `json:"containerImage"`
44+
4145
// +kubebuilder:validation:Optional
4246
// +kubebuilder:validation:Enum=internal;external;single;edge
4347
// +kubebuilder:default=external

api/v1beta1/glanceapi_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func (r *GlanceAPI) Default() {
5353

5454
// Default - set defaults for this Glance spec
5555
func (spec *GlanceAPISpec) Default() {
56-
if spec.GlanceAPITemplate.ContainerImage == "" {
57-
spec.GlanceAPITemplate.ContainerImage = glanceAPIDefaults.ContainerImageURL
56+
if spec.ContainerImage == "" {
57+
spec.ContainerImage = glanceAPIDefaults.ContainerImageURL
5858
}
5959
}
6060

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ spec:
6666
- edge
6767
type: string
6868
containerImage:
69-
description: Glance Container Image URL (will be set to environmental
70-
default if empty)
69+
description: ContainerImage - GlanceAPI Container Image URL
7170
type: string
7271
customServiceConfig:
7372
description: |-

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,6 @@ spec:
12291229
APITimeout
12301230
minimum: 1
12311231
type: integer
1232-
containerImage:
1233-
description: Glance Container Image URL (will be set to environmental
1234-
default if empty)
1235-
type: string
12361232
customServiceConfig:
12371233
description: |-
12381234
CustomServiceConfig - customize the service config using this parameter to change service defaults,
@@ -1578,8 +1574,6 @@ spec:
15781574
- single
15791575
- edge
15801576
type: string
1581-
required:
1582-
- containerImage
15831577
type: object
15841578
default: {}
15851579
description: GlanceAPIs - Spec definition for the API service of this

internal/controller/glance_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func (r *GlanceReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manage
269269
// TransportURL created and used by Glance CRs.
270270
transportURLSecretFn := func(_ context.Context, o client.Object) []reconcile.Request {
271271
result := []reconcile.Request{}
272-
// get all Manila CRs
272+
// get all Glance CRs
273273
glances := &glancev1.GlanceList{}
274274
listOpts := []client.ListOption{
275275
client.InNamespace(o.GetNamespace()),
@@ -950,6 +950,7 @@ func (r *GlanceReconciler) apiDeploymentCreateOrUpdate(
950950
apiSpec := glancev1.GlanceAPISpec{
951951
GlanceAPITemplate: apiTemplate,
952952
APIType: apiType,
953+
ContainerImage: instance.Spec.ContainerImage,
953954
DatabaseHostname: instance.Status.DatabaseHostname,
954955
DatabaseAccount: instance.Spec.DatabaseAccount,
955956
Secret: instance.Spec.Secret,

test/functional/glance_controller_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,7 @@ var _ = Describe("Glance controller", func() {
127127
// (Updates) We let the Glance webhooks override the top-level CR
128128
// ContainerImage, but we pass an override for each glanceAPI
129129
// instance, so we can manage them independently
130-
Expect(glance.Spec.ContainerImage).To(Equal(glancev1.GlanceAPIContainerImage))
131-
for _, api := range glance.Spec.GlanceAPIs {
132-
// We expect the containerImage enforced in the Spec by GlanceAPI()
133-
// function
134-
Expect(api.ContainerImage).To(Equal(glanceTest.ContainerImage))
135-
}
130+
Expect(glance.Spec.ContainerImage).To(Equal(util.GetEnvVar("RELATED_IMAGE_GLANCE_API_IMAGE_URL_DEFAULT", glancev1.GlanceAPIContainerImage)))
136131
})
137132
It("should not have a pvc yet", func() {
138133
AssertPVCDoesNotExist(glanceTest.Instance)
@@ -254,12 +249,6 @@ var _ = Describe("Glance controller", func() {
254249
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, glanceTest.MemcachedInstance, memcachedSpec))
255250
infra.SimulateMemcachedReady(glanceTest.GlanceMemcached)
256251
})
257-
It("has the expected container image defaults", func() {
258-
glanceDefault := GetGlance(glanceTest.Instance)
259-
for _, api := range glanceDefault.Spec.GlanceAPIs {
260-
Expect(api.ContainerImage).To(Equal(util.GetEnvVar("RELATED_IMAGE_GLANCE_API_IMAGE_URL_DEFAULT", glancev1.GlanceAPIContainerImage)))
261-
}
262-
})
263252
It("has a dummy backend set when and empty spec is passed", func() {
264253
glanceDefault := GetGlance(glanceTest.Instance)
265254
Expect(glanceDefault.Spec.CustomServiceConfig).To((ContainSubstring(GlanceDummyBackend)))

0 commit comments

Comments
 (0)