-
Notifications
You must be signed in to change notification settings - Fork 110
Handle glance minor updates #1429
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import ( | |
| "k8s.io/apimachinery/pkg/types" | ||
| ctrl "sigs.k8s.io/controller-runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
| "strconv" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -23,17 +24,32 @@ const ( | |
| // label set by the service operator as in case of split glanceAPI type the | ||
| // the label on public svc gets set to -external and internal instance svc | ||
| // to -internal instead of the glance top level glanceType split | ||
| svcSelector = "tlGlanceAPI" | ||
| svcSelector = "tlGlanceAPI" | ||
| targetVersion = "v18.0.9" | ||
| ) | ||
|
|
||
| // ReconcileGlance - | ||
| func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (ctrl.Result, error) { | ||
| glanceName, altGlanceName := instance.GetServiceName(corev1beta1.GlanceName, instance.Spec.Glance.UniquePodNames) | ||
| // Ensure the alternate cinder CR doesn't exist, as the ramdomPodNames flag may have been toggled | ||
| apiAnnotations := map[string]string{} | ||
|
|
||
| // Set WSGI annotation to either deploy GlanceAPI in wsgi mode or httpd + | ||
| // ProxyPass | ||
| // | ||
| // - wsgi=true for both greenfield deployments and when a minor update is | ||
| // performed from a version greater than v18.0.9 | ||
| // | ||
| // - wsgi=false keeps the httpd + proxypass deployment method. | ||
| // This is required when a minor update from a version < FR3 is performed | ||
| apiAnnotations["wsgi"] = GlanceWSGIAnnotation(version, targetVersion) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned on the glance pr, lets use a const on the glance api module to not have to hard code something here. |
||
|
|
||
| // Ensure the alternate glance CR doesn't exist, as the ramdomPodNames flag may have | ||
| // been toggled | ||
| glance := &glancev1.Glance{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: altGlanceName, | ||
| Namespace: instance.Namespace, | ||
| Name: altGlanceName, | ||
| Namespace: instance.Namespace, | ||
| Annotations: apiAnnotations, | ||
| }, | ||
| } | ||
| if res, err := EnsureDeleted(ctx, helper, glance); err != nil { | ||
|
|
@@ -42,8 +58,9 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl | |
|
|
||
| glance = &glancev1.Glance{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: glanceName, | ||
| Namespace: instance.Namespace, | ||
| Name: glanceName, | ||
| Namespace: instance.Namespace, | ||
| Annotations: apiAnnotations, | ||
| }, | ||
| } | ||
| Log := GetLogger(ctx) | ||
|
|
@@ -171,6 +188,9 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl | |
| op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), glance, func() error { | ||
| instance.Spec.Glance.Template.DeepCopyInto(&glance.Spec.GlanceSpecCore) | ||
| glance.Spec.ContainerImage = *version.Status.ContainerImages.GlanceAPIImage | ||
| // Set apiAnnotations in the Glance CR: this is currently used to | ||
| // influence | ||
| glance.SetAnnotations(apiAnnotations) | ||
| if glance.Spec.Secret == "" { | ||
| glance.Spec.Secret = instance.Spec.Secret | ||
| } | ||
|
|
@@ -243,3 +263,20 @@ func GlanceImageMatch(ctx context.Context, controlPlane *corev1beta1.OpenStackCo | |
|
|
||
| return true | ||
| } | ||
|
|
||
| // GlanceWSGIAnnotation - | ||
| func GlanceWSGIAnnotation(version *corev1beta1.OpenStackVersion, targetVersion string) string { | ||
| wsgi := true | ||
| // if there is no deployed version, it is a greenfield scenario and we can | ||
| // deploy in wsgi mode (which is the default) | ||
| if version.Status.DeployedVersion == nil { | ||
| return strconv.FormatBool(wsgi) | ||
| } | ||
| // Do not deploy Glance in wsgi mode, but keep http+ProxyPass model when the | ||
| // version is lower than FR3 (18.0.9). This is required because the previous | ||
| // Glance ContainerImage is incompatitble with WSGI. | ||
| if version.IsLowerSemVer(targetVersion) { | ||
| wsgi = false | ||
| } | ||
| return strconv.FormatBool(wsgi) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about
targetVersion: it might work for a downstream release but not for an upstream one!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add const https://github.com/openstack-k8s-operators/openstack-operator/blob/main/apis/core/v1beta1/openstackversion_types.go which reflects the mapping of FR releases to version (not sure if MR release would also be required)? with this we could just say here targetVersion < FR3? for upstream we also have those OPENSTACK_RELEASE_VERSION 0.2.0 (fr2 - https://github.com/openstack-k8s-operators/openstack-operator/blob/18.0-fr2/Makefile#L6) 0.3.0 (fr3 - https://github.com/openstack-k8s-operators/openstack-operator/blob/main/Makefile#L6). we'd only have to verify if this is properly handled in the update ci job.