Skip to content

Commit

Permalink
Consume Topology CR
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Dec 13, 2024
1 parent ab58953 commit 2c2d3f8
Show file tree
Hide file tree
Showing 18 changed files with 310 additions and 13 deletions.
7 changes: 7 additions & 0 deletions api/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,13 @@ spec:
caBundleSecretName:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
type:
default: split
enum:
Expand Down
14 changes: 14 additions & 0 deletions api/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ spec:
caBundleSecretName:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
type:
default: split
enum:
Expand Down Expand Up @@ -777,6 +784,13 @@ spec:
storageRequest:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
required:
- containerImage
- databaseInstance
Expand Down
4 changes: 4 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ require (
// mschuppert: map to latest commit from release-4.16 tag
// must consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 //allow-merging

replace github.com/openstack-k8s-operators/infra-operator/apis => github.com/fmount/infra-operator/apis v0.0.0-20241213142815-43a307456212

replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/fmount/lib-common/modules/common v0.0.0-20241212101345-0fcf769ab15c
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ
github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/fmount/lib-common/modules/common v0.0.0-20241212101345-0fcf769ab15c h1:+ribyrmMYARx5t1o2LXhigFGj18NKK5uRn9fbquUGvE=
github.com/fmount/lib-common/modules/common v0.0.0-20241212101345-0fcf769ab15c/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
Expand Down Expand Up @@ -75,8 +77,6 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc h1:Ufa/q/nC9wmKblvsc0kJppsXHOJoY4fbUamb3ItWCOk=
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc h1:J5Kr0/ST3KqMzSRhcubr0fF9/vWzma+U63P9kfmgIA8=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ type GlanceAPITemplate struct {
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// Topology to apply the Policy defined by the associated CR referenced by
// name
Topology *TopologyRef `json:"topologyRef,omitempty"`

// +kubebuilder:validation:Optional
// CustomServiceConfig - customize the service config using this parameter to change service defaults,
// or overwrite rendered information using raw OpenStack config format. The content gets added to
Expand Down Expand Up @@ -108,6 +113,15 @@ type GlanceAPITemplate struct {
APITimeout int `json:"apiTimeout,omitempty"`
}

// TopologyRef -
type TopologyRef struct {
// +kubebuilder:validation:Optional
// Name -
Name string `json:"name"`
// Namespace -
Namespace string `json:"namespace,omitempty"`
}

// Storage -
type Storage struct {
// +kubebuilder:validation:Optional
Expand Down
9 changes: 9 additions & 0 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ const (
InvalidBackendErrorMessageSplit = "The GlanceAPI layout type: split cannot be used in combination with File and NFS backend"
// InvalidBackendErrorMessageSingle
InvalidBackendErrorMessageSingle = "The GlanceAPI layout type: single can only be used in combination with File and NFS backend"

// TopologyConfigReadyInitMessage
TopologyConfigReadyInitMessage = "Topology config create not started"
// TopologyConfigReadyMessage
TopologyConfigReadyMessage = "Topology config create completed"
// TopologyConfigReadyErrorMessage
TopologyConfigReadyErrorMessage = "Topology config create error occurred %s"
// TopologyConfigReadyCondition Status=True condition which indicates a CR exists and is referenced by the Glance
TopologyConfigReadyCondition condition.Type = "TopologyConfigReady"
)
5 changes: 5 additions & 0 deletions api/v1beta1/glance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ type GlanceSpecCore struct {
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// Topology to apply the Policy defined by the associated CR referenced by
// name
Topology *TopologyRef `json:"topologyRef,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// PreserveJobs - do not delete jobs after they finished e.g. to check logs
Expand Down
25 changes: 25 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions config/crd/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,13 @@ spec:
caBundleSecretName:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
type:
default: split
enum:
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ spec:
caBundleSecretName:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
type:
default: split
enum:
Expand Down Expand Up @@ -777,6 +784,13 @@ spec:
storageRequest:
type: string
type: object
topologyRef:
properties:
name:
type: string
namespace:
type: string
type: object
required:
- containerImage
- databaseInstance
Expand Down
10 changes: 10 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,13 @@ rules:
- securitycontextconstraints
verbs:
- use
- apiGroups:
- topology.openstack.org
resources:
- topologies
verbs:
- get
- list
- patch
- update
- watch
7 changes: 7 additions & 0 deletions controllers/glance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,13 @@ func (r *GlanceReconciler) apiDeploymentCreateOrUpdate(
if instance.Spec.KeystoneEndpoint == apiName {
apiAnnotations[glance.KeystoneEndpoint] = "true"
}

// If topology is not present in the underlying GlanceAPI,
// inherit from the top-level CR
if apiSpec.GlanceAPITemplate.Topology == nil {
apiSpec.GlanceAPITemplate.Topology = instance.Spec.Topology
}

// Add the API name to the GlanceAPI instance as a label
serviceLabels[glancev1.APINameLabel] = apiName
glanceStatefulset := &glancev1.GlanceAPI{
Expand Down
Loading

0 comments on commit 2c2d3f8

Please sign in to comment.