Skip to content

Commit

Permalink
[CRD]Move container images to top level
Browse files Browse the repository at this point in the history
To simplify service container image defaulting and upgrade this patch
removes the container image fields from the service templates and the
cell template. Instead it adds container image URL fields to the
NovaSpec and the NovaCellSpec. The former is expected to be set by the
openstack-operator the latter is set by the nova reconciler. We keep the
service Spec container image fields and they are now populated from the
NovaSpec or NovaCellSpec respectively.

This limits the ability to define different container image for the same
service type in different cells. If such capability is needed, e.g.: for
debugging, then oc debug can be used. More permanent hotfix on an
individual cell level will not be possible, the fix needs to be deployed
to every cell in the controlplane.
  • Loading branch information
gibizer authored and openshift-merge-bot[bot] committed Mar 12, 2024
1 parent d9341ba commit 7f619ee
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 209 deletions.
52 changes: 24 additions & 28 deletions api/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ spec:
spec:
description: NovaSpec defines the desired state of Nova
properties:
apiContainerImageURL:
description: APIContainerImageURL
type: string
apiDatabaseAccount:
default: nova-api
description: APIDatabaseAccount - MariaDBAccount to use when accessing
Expand All @@ -56,10 +59,6 @@ spec:
replicas: 1
description: APIServiceTemplate - define the nova-api service
properties:
containerImage:
description: ContainerImage - The service specific Container Image
URL (will be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -382,10 +381,6 @@ spec:
description: ConductorServiceTemplate - defines the cell conductor
deployment for the cell.
properties:
containerImage:
description: The service specific Container Image URL (will
be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service
config using this parameter to change service defaults,
Expand Down Expand Up @@ -506,10 +501,6 @@ spec:
time. By default Nova CR deploys the metadata service at the
top level and disables it on the cell level.
properties:
containerImage:
description: The service specific Container Image URL (will
be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service
config using this parameter to change service defaults,
Expand Down Expand Up @@ -812,10 +803,6 @@ spec:
is defaulted to false in cell0 but defaulted to true in other
cells.
properties:
containerImage:
description: The service specific Container Image URL (will
be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service
config using this parameter to change service defaults,
Expand Down Expand Up @@ -1123,10 +1110,6 @@ spec:
- ironic.IronicDriver
- fake.FakeDriver
type: string
containerImage:
description: ContainerImage - The service specific Container
Image URL (will be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service
config using this parameter to change service defaults,
Expand Down Expand Up @@ -1241,6 +1224,12 @@ spec:
needs at least one additional normal cell as "cell0" cannot have
any computes.
type: object
computeContainerImageURL:
description: NovaComputeContainerImageURL
type: string
conductorContainerImageURL:
description: ConductorContainerImageURL
type: string
keystoneInstance:
default: keystone
description: KeystoneInstance to name of the KeystoneAPI CR to select
Expand All @@ -1251,6 +1240,9 @@ spec:
description: MemcachedInstance is the name of the Memcached CR that
all nova service will use.
type: string
metadataContainerImageURL:
description: MetadataContainerImageURL
type: string
metadataServiceTemplate:
default:
enabled: true
Expand All @@ -1259,10 +1251,6 @@ spec:
if you want to deploy metadata per cell then the metadata service
should be disabled here and enabled in the cellTemplates instead.
properties:
containerImage:
description: The service specific Container Image URL (will be
set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -1546,6 +1534,9 @@ spec:
this service. Setting NodeSelector here acts as a default value
and can be overridden by service specific NodeSelector Settings.
type: object
novncproxyContainerImageURL:
description: NoVNCContainerImageURL
type: string
passwordSelectors:
default:
service: NovaPassword
Expand All @@ -1568,15 +1559,14 @@ spec:
description: PreserveJobs - do not delete jobs after they finished
e.g. to check logs
type: boolean
schedulerContainerImageURL:
description: SchedulerContainerImageURL
type: string
schedulerServiceTemplate:
default:
replicas: 1
description: SchedulerServiceTemplate- define the nova-scheduler service
properties:
containerImage:
description: The service specific Container Image URL (will be
set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -1666,6 +1656,12 @@ spec:
to register in keystone
type: string
required:
- apiContainerImageURL
- computeContainerImageURL
- conductorContainerImageURL
- metadataContainerImageURL
- novncproxyContainerImageURL
- schedulerContainerImageURL
- secret
type: object
status:
Expand Down
32 changes: 16 additions & 16 deletions api/bases/nova.openstack.org_novacells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ spec:
associated and the conductor in this cell acts as the super conductor
for all the cells in the deployment.
type: string
computeContainerImageURL:
description: NovaComputeContainerImageURL
type: string
conductorContainerImageURL:
description: ConductorContainerImageURL
type: string
conductorServiceTemplate:
description: ConductorServiceTemplate - defines the cell conductor
deployment for the cell
properties:
containerImage:
description: The service specific Container Image URL (will be
set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -177,14 +179,13 @@ spec:
description: MemcachedInstance is the name of the Memcached CR that
all nova service will use.
type: string
metadataContainerImageURL:
description: MetadataContainerImageURL
type: string
metadataServiceTemplate:
description: MetadataServiceTemplate - defines the metadata service
dedicated for the cell.
properties:
containerImage:
description: The service specific Container Image URL (will be
set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -465,10 +466,6 @@ spec:
description: NoVNCProxyServiceTemplate - defines the novvncproxy service
dedicated for the cell.
properties:
containerImage:
description: The service specific Container Image URL (will be
set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -757,10 +754,6 @@ spec:
- ironic.IronicDriver
- fake.FakeDriver
type: string
containerImage:
description: ContainerImage - The service specific Container
Image URL (will be set to environmental default if empty)
type: string
customServiceConfig:
description: CustomServiceConfig - customize the service config
using this parameter to change service defaults, or overwrite
Expand Down Expand Up @@ -853,6 +846,9 @@ spec:
Key from map is arbitrary name for the compute. because of that
there is a 20 character limit on the compute name.'
type: object
novncproxyContainerImageURL:
description: NoVNCContainerImageURL
type: string
preserveJobs:
default: false
description: PreserveJobs - do not delete jobs after they finished
Expand Down Expand Up @@ -884,10 +880,14 @@ spec:
required:
- cellDatabaseHostname
- cellName
- computeContainerImageURL
- conductorContainerImageURL
- conductorServiceTemplate
- keystoneAuthURL
- memcachedInstance
- metadataContainerImageURL
- noVNCProxyServiceTemplate
- novncproxyContainerImageURL
- secret
- serviceAccount
type: object
Expand Down
82 changes: 68 additions & 14 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,82 @@ type PasswordSelector struct {
MetadataSecret string `json:"metadataSecret"`
}

type NovaImages struct {
// +kubebuilder:validation:Required
// APIContainerImageURL
APIContainerImageURL string `json:"apiContainerImageURL"`

// +kubebuilder:validation:Required
// SchedulerContainerImageURL
SchedulerContainerImageURL string `json:"schedulerContainerImageURL"`

// +kubebuilder:validation:Required
NovaCellImages `json:",inline"`
}

func (r *NovaImages) Default(defaults NovaDefaults) {
r.NovaCellImages.Default(defaults.NovaCellDefaults)
if r.APIContainerImageURL == "" {
r.APIContainerImageURL = defaults.APIContainerImageURL
}
if r.SchedulerContainerImageURL == "" {
r.SchedulerContainerImageURL = defaults.SchedulerContainerImageURL
}
}

type NovaCellImages struct {

// +kubebuilder:validation:Required
// ConductorContainerImageURL
ConductorContainerImageURL string `json:"conductorContainerImageURL"`

// +kubebuilder:validation:Required
// MetadataContainerImageURL
MetadataContainerImageURL string `json:"metadataContainerImageURL"`

// +kubebuilder:validation:Required
// NoVNCContainerImageURL
NoVNCContainerImageURL string `json:"novncproxyContainerImageURL"`

// +kubebuilder:validation:Required
// NovaComputeContainerImageURL
NovaComputeContainerImageURL string `json:"computeContainerImageURL"`
}

func (r *NovaCellImages) Default(defaults NovaCellDefaults) {
if r.ConductorContainerImageURL == "" {
r.ConductorContainerImageURL = defaults.ConductorContainerImageURL
}
if r.MetadataContainerImageURL == "" {
r.MetadataContainerImageURL = defaults.MetadataContainerImageURL
}
if r.NoVNCContainerImageURL == "" {
r.NoVNCContainerImageURL = defaults.NoVNCContainerImageURL
}
if r.NovaComputeContainerImageURL == "" {
r.NovaComputeContainerImageURL = defaults.NovaComputeContainerImageURL
}
}

// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
func SetupDefaults() {
// Acquire environmental defaults and initialize Nova defaults with them
novaDefaults := NovaDefaults{
APIContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT", NovaAPIContainerImage),
// Acquire environmental defaults and initialize NovaCell defaults with them
novaCellDefaults := NovaCellDefaults{
ConductorContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_CONDUCTOR_IMAGE_URL_DEFAULT", NovaConductorContainerImage),
MetadataContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT", NovaMetadataContainerImage),
NoVNCContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_NOVNC_IMAGE_URL_DEFAULT", NovaNoVNCContainerImage),
SchedulerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_SCHEDULER_IMAGE_URL_DEFAULT", NovaSchedulerContainerImage),
NovaComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_COMPUTE_IMAGE_URL_DEFAULT", NovaComputeContainerImage),
}

SetupNovaCellDefaults(novaCellDefaults)

// Acquire environmental defaults and initialize Nova defaults with them
novaDefaults := NovaDefaults{
APIContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT", NovaAPIContainerImage),
SchedulerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_SCHEDULER_IMAGE_URL_DEFAULT", NovaSchedulerContainerImage),
NovaCellDefaults: novaCellDefaults,
}

SetupNovaDefaults(novaDefaults)

// Acquire environmental defaults and initialize NovaAPI defaults with them
Expand All @@ -110,16 +174,6 @@ func SetupDefaults() {

SetupNovaAPIDefaults(novaAPIDefaults)

// Acquire environmental defaults and initialize NovaCell defaults with them
novaCellDefaults := NovaCellDefaults{
ConductorContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_CONDUCTOR_IMAGE_URL_DEFAULT", NovaConductorContainerImage),
MetadataContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT", NovaMetadataContainerImage),
NoVNCContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_NOVNC_IMAGE_URL_DEFAULT", NovaNoVNCContainerImage),
NovaComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_COMPUTE_IMAGE_URL_DEFAULT", NovaComputeContainerImage),
}

SetupNovaCellDefaults(novaCellDefaults)

// Acquire environmental defaults and initialize NovaConductor defaults with them
novaConductorDefaults := NovaConductorDefaults{
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_NOVA_CONDUCTOR_IMAGE_URL_DEFAULT", NovaConductorContainerImage),
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/nova_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ type NovaSpec struct {
// +kubebuilder:default=memcached
// MemcachedInstance is the name of the Memcached CR that all nova service will use.
MemcachedInstance string `json:"memcachedInstance"`

// +kubebuilder:validation:Required
NovaImages `json:",inline"`
}

// NovaStatus defines the observed state of Nova
Expand Down
Loading

0 comments on commit 7f619ee

Please sign in to comment.