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 11, 2024
1 parent ab58953 commit fde4082
Show file tree
Hide file tree
Showing 17 changed files with 301 additions and 9 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
2 changes: 2 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ 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-20241206174027-50c23c924fe8
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 fde4082

Please sign in to comment.