Skip to content

Commit

Permalink
Add new glanceAPI struct
Browse files Browse the repository at this point in the history
This change is the first of a series where the purpose is to move away
from the harcoded internal/external glanceAPI instance in favor of an
arbitrary number of GlanceAPI instances.
The current change doesn't introduce the ability to deploy >1 GlanceAPI
instance, but introduces the intermediate struct that will serve this
purpose.
The split behavior is still preserved, but it happens behind the scenes
in Glance.

Depends-On: openstack-k8s-operators/glance-operator#329

Note: Still WIP and under review.

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
  • Loading branch information
fmount committed Oct 13, 2023
1 parent f35f8a5 commit 0c51edb
Show file tree
Hide file tree
Showing 20 changed files with 323 additions and 509 deletions.
329 changes: 110 additions & 219 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ replace (
// mschuppert: map to latest commit from release-4.13 tag
// must consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 //allow-merging

replace github.com/openstack-k8s-operators/glance-operator/api => github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4
4 changes: 2 additions & 2 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0=
github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4 h1:AUXeXJq4kUdTgsTALFLziGz9uVOGRhyelpiMu1Tr/q0=
github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4/go.mod h1:dJRUMrLRFt3weBS/FDcb+eZvoOGANr1XslmM5RnY8vw=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down Expand Up @@ -130,8 +132,6 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2 h1:sPQWPiTBSyNf1vdImemK4vAjavwmf/cKXkIrIMOVWTs=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2/go.mod h1:8NFIyjXZeC+T2UBcmTDTfSatRdhi2eaZlaAuzcT2rNk=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1 h1:4lq+opoHznCsw80yXEntIl+R9FT1C0ssmgQn1Qt7zlw=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1/go.mod h1:dJRUMrLRFt3weBS/FDcb+eZvoOGANr1XslmM5RnY8vw=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b h1:TgJRyviHEMquRTEczKKgsGdl6tzA0PIdt7PmtqFlTYk=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b/go.mod h1:WPQCwaFKWwIEgqXjZRvJ7+bRUXF5Y/eAqKpBiCEe/Q4=
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b h1:nA/cI+2fPqcBvM0jCo/WsrngfQQEd8RSGBY7xdFMC+o=
Expand Down
329 changes: 110 additions & 219 deletions config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions config/samples/core_v1beta1_openstackcontrolplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ spec:
secret: osp-secret
glance:
template:
secret: osp-secret
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ spec:
secret: osp-secret
glance:
template:
secret: osp-secret
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
4 changes: 4 additions & 0 deletions config/samples/core_v1beta1_openstackcontrolplane_galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ spec:
secret: osp-secret
glance:
template:
secret: osp-secret
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ spec:
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ spec:
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceAPIInternal:
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
glanceAPIExternal:
networkAttachments:
- storage
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
keystone:
apiOverride:
route: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ spec:
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceAPIInternal:
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
glanceAPIExternal:
networkAttachments:
- storage
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
keystone:
apiOverride:
route: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ spec:
databaseInstance: openstack
storageClass: ""
storageRequest: 10G
glanceAPIInternal:
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
glanceAPIExternal:
networkAttachments:
- storage
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
keystone:
apiOverride:
route: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ spec:
rbd_store_user = openstack
storageClass: ""
storageRequest: 10G
glanceAPIInternal:
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
glanceAPIExternal:
networkAttachments:
- storage
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.80
spec:
type: LoadBalancer
networkAttachments:
- storage
keystone:
apiOverride:
route: {}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ replace github.com/openstack-k8s-operators/openstack-operator/apis => ./apis
// mschuppert: map to latest commit from release-4.13 tag
// must consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 //allow-merging

replace github.com/openstack-k8s-operators/glance-operator/api => github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0=
github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4 h1:AUXeXJq4kUdTgsTALFLziGz9uVOGRhyelpiMu1Tr/q0=
github.com/fmount/glance-operator/api v0.1.2-0.20231012113347-012e0477eda4/go.mod h1:dJRUMrLRFt3weBS/FDcb+eZvoOGANr1XslmM5RnY8vw=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
Expand Down Expand Up @@ -139,8 +141,6 @@ github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-c
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2/go.mod h1:8NFIyjXZeC+T2UBcmTDTfSatRdhi2eaZlaAuzcT2rNk=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20231012070625-9e18aa48308d h1:wo3S8vV4RP89GsWJHjUuwKU68Qhykihc7PPH70Ei5Vo=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20231012070625-9e18aa48308d/go.mod h1:YGDRqO0aZklaLWB95HIdx95zm6bX9mSO6PL3azFcUZk=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1 h1:4lq+opoHznCsw80yXEntIl+R9FT1C0ssmgQn1Qt7zlw=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1/go.mod h1:dJRUMrLRFt3weBS/FDcb+eZvoOGANr1XslmM5RnY8vw=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b h1:TgJRyviHEMquRTEczKKgsGdl6tzA0PIdt7PmtqFlTYk=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b/go.mod h1:WPQCwaFKWwIEgqXjZRvJ7+bRUXF5Y/eAqKpBiCEe/Q4=
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b h1:nA/cI+2fPqcBvM0jCo/WsrngfQQEd8RSGBY7xdFMC+o=
Expand Down
3 changes: 3 additions & 0 deletions hack/pin-bundle-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ for MOD_PATH in $(go list -mod=readonly -m -json all | jq -r '. | select(.Path |
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
fi
else
# Current hack to point to a diff glance-operator-bundle built on top
# of https://github.com/openstack-k8s-operators/glance-operator/pull/329
GITHUB_USER="fpantano"
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
fi
Expand Down
10 changes: 3 additions & 7 deletions pkg/openstack/glance.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
}

serviceOverrides := map[service.Endpoint]service.RoutedOverrideSpec{}
if instance.Spec.Glance.Template.GlanceAPIExternal.Override.Service != nil {
serviceOverrides[service.EndpointPublic] = *instance.Spec.Glance.Template.GlanceAPIExternal.Override.Service
}
if instance.Spec.Glance.Template.GlanceAPIInternal.Override.Service != nil {
serviceOverrides[service.EndpointInternal] = *instance.Spec.Glance.Template.GlanceAPIInternal.Override.Service
if instance.Spec.Glance.Template.GlanceAPIs.GlanceAPI.Override.Service != nil {
serviceOverrides[service.EndpointInternal] = *instance.Spec.Glance.Template.GlanceAPIs.GlanceAPI.Override.Service
}

// add selector to service overrides
Expand Down Expand Up @@ -92,8 +89,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
helper.GetLogger().Info("Reconciling Glance", "Glance.Namespace", instance.Namespace, "Glance.Name", "glance")
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), glance, func() error {
instance.Spec.Glance.Template.DeepCopyInto(&glance.Spec)
glance.Spec.GlanceAPIExternal.Override.Service = ptr.To(serviceOverrides[service.EndpointPublic])
glance.Spec.GlanceAPIInternal.Override.Service = ptr.To(serviceOverrides[service.EndpointInternal])
glance.Spec.GlanceAPIs.GlanceAPI.Override.Service = ptr.To(serviceOverrides[service.EndpointInternal])

if glance.Spec.Secret == "" {
glance.Spec.Secret = instance.Spec.Secret
Expand Down
4 changes: 4 additions & 0 deletions tests/kuttl/common/assert-sample-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ spec:
template:
databaseInstance: openstack
storageRequest: 10G
secret: osp-secret
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
3 changes: 3 additions & 0 deletions tests/kuttl/tests/collapsed/01-assert-collapsed-cell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
template:
databaseInstance: openstack
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
template:
databaseInstance: openstack
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down
3 changes: 3 additions & 0 deletions tests/kuttl/tests/galera-basic/01-assert-galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
template:
databaseInstance: openstack
storageRequest: 10G
glanceapis:
glanceAPI:
replicas: 1
cinder:
template:
databaseInstance: openstack
Expand Down

0 comments on commit 0c51edb

Please sign in to comment.