Skip to content

Commit

Permalink
Merge "Add manila sts backends support"
Browse files Browse the repository at this point in the history
  • Loading branch information
MOS CI authored and Gerrit Code Review committed Nov 8, 2024
2 parents b917968 + 9d9cc39 commit 5ee198b
Show file tree
Hide file tree
Showing 21 changed files with 1,245 additions and 2 deletions.
2 changes: 2 additions & 0 deletions openstack_controller/admission/validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from openstack_controller.admission.validators import openstack
from openstack_controller.admission.validators import nodes
from openstack_controller.admission.validators import cinder
from openstack_controller.admission.validators import manila

__all__ = [
barbican.BarbicanValidator,
Expand All @@ -20,4 +21,5 @@
glance.GlanceValidator,
ironic.IronicValidator,
cinder.CinderValidator,
manila.ManilaValidator,
]
57 changes: 57 additions & 0 deletions openstack_controller/admission/validators/manila.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from openstack_controller.admission.validators import base
from openstack_controller import exception


class ManilaValidator(base.BaseValidator):
service = "shared-file-system"

def validate(self, review_request):
spec = review_request.get("object", {}).get("spec", {})
manila_section = spec.get("features", {}).get("manila", {})

self._check_share_backend(manila_section)

def _check_share_backend(self, manila_section):
backend_section = manila_section.get("share", {}).get("backends", {})
for name, opts in backend_section.items():
if opts.get("enabled", True):
enabled_backends = [
x
for x in (
opts["values"]["conf"]
.get("manila", {})
.get("DEFAULT", {})
.get("enabled_share_backends", "")
.split(",")
)
if x
]
if not enabled_backends:
raise exception.OsDplValidationFailed(
f"Param 'enabled_share_backends' should be specified in DEFAULT section for Manila backend {name}."
)
for backend in enabled_backends:
backend_conf = opts["values"]["conf"]["manila"].get(
backend, {}
)
if backend_conf.get("share_backend_name") is None:
raise exception.OsDplValidationFailed(
f"Param 'share_backend_name' should be specified in {backend} section for Manila backend {name}."
)
if backend_conf.get("share_driver") is None:
raise exception.OsDplValidationFailed(
f"Param 'share_driver' should be specified in {backend} section for Manila backend {name}."
)
50 changes: 50 additions & 0 deletions openstack_controller/admission/validators/schemas/osdpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,56 @@ properties:
then:
required:
- backup_share
manila:
type: object
additionalProperties: false
properties:
share:
type: object
additionalProperties: false
properties:
backends:
type: object
description: |
Manila backends configuration
additionalProperties: False
patternProperties:
".*":
description: |
Backend name
additionalProperties: False
type: object
required:
- type
- values
properties:
enabled:
type: boolean
description: |
Enable Manila backend to deploy
default: True
type:
type: string
enum:
- statefulset
values:
type: object
additionalProperties: False
required:
- conf
properties:
conf:
type: object
additionalProperties: True
images:
type: object
additionalProperties: True
labels:
type: object
additionalProperties: True
pod:
type: object
additionalProperties: True
logging:
type: object
additionalProperties: false
Expand Down
2 changes: 2 additions & 0 deletions openstack_controller/ceph_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"cinder": ["volumes", "backup"],
"nova": ["ephemeral", "vms"],
"glance": ["images"],
"manila": [],
}


class OSUser(Enum):
nova = auto()
cinder = auto()
glance = auto()
manila = auto()


class PoolRole(Enum):
Expand Down
27 changes: 26 additions & 1 deletion openstack_controller/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,13 +2204,38 @@ class Masakari(OpenStackService):
available_releases = ["openstack-masakari-rabbitmq", "openstack-masakari"]


class Manila(OpenStackService):
class Manila(OpenStackServiceWithCeph):
service = "shared-file-system"
openstack_chart = "manila"
available_releases = [
"openstack-manila",
]

@property
def is_ceph_enabled(self):
manila_backends = utils.get_in(
self.mspec, ["features", "manila", "share", "backends"], {}
)
for opts in manila_backends.values():
if opts.get("enabled", True):
enabled_backends = utils.get_in(
opts["values"],
["conf", "manila", "DEFAULT", "enabled_share_backends"],
"",
).split(",")
for backend in enabled_backends:
driver = utils.get_in(
opts["values"],
["conf", "manila", backend, "share_driver"],
"",
)
if (
driver
== "manila.share.drivers.cephfs.driver.CephFSDriver"
):
return True
return False

def template_args(self):
template_args = super().template_args()
ssh_secret = secrets.SSHSecret(self.namespace, self.service)
Expand Down
51 changes: 50 additions & 1 deletion openstack_controller/templates/services/shared-file-system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
{%- from 'macros/etcd3.j2' import get_etcd3_endpoint %}
{%- set cadf_audit = spec.get('features', {}).get('logging', {}).get('cadf', {'enabled': false}) %}
{%- set cadf_audit_driver = spec.get('features', {}).get('logging', {}).get('cadf', {}).get('driver', 'messagingv2') %}
{%- set share_sts = {} %}
{%- set share_backends = spec.get('features', {}).get('manila', {}).get('share', {}).get('backends', {}) %}

{%- for sts_name, sts_opts in share_backends.items() %}
{%- if sts_opts.get('enabled', True) %}
{%- for backend in sts_opts['values']['conf']['manila']['DEFAULT']['enabled_share_backends'].split(',') %}
{%- set sts_backend_opts = sts_opts['values']['conf']['manila'][backend] %}
{%- set share_driver = sts_backend_opts['share_driver'] %}
{%- set opts = {} %}
{%- if share_driver == 'manila.share.drivers.cephfs.driver.CephFSDriver' %}
{%- do opts.update({'cephfs_auth_id': ceph.manila.username,
'cephfs_protocol_helper_type': 'CEPHFS',
'driver_handles_share_servers': false
}) %}
{%- endif %}
{# merge default options and user provided options #}
{%- do opts.update(sts_backend_opts) %}
{# put result back into the values #}
{%- do sts_backend_opts.update(opts) %}
{%- endfor %}
{# overwrite default options by user defined #}
{%- do share_sts.update({sts_name: {'values': sts_opts['values']}}) %}
{%- endif %}
{%- endfor %}

spec:
releases:
Expand Down Expand Up @@ -45,6 +69,10 @@ spec:
{{ image }}: {{ images[image] }}
{%- endif %}
{%- endfor %}
bootstrap:
share_types:
default:
driver_handles_share_servers: {{ not is_ceph_enabled }}
endpoints:
cluster_domain_suffix: {{ spec.internal_domain_name }}
{% include 'base/_admin_identity.yaml' %}
Expand Down Expand Up @@ -98,10 +126,23 @@ spec:
default: http
public: https
conf:
{%- if is_ceph_enabled %}
ceph:
keyrings:
{{ ceph.manila.username }}:
key: {{ ceph.manila.keyring }}
config:
global:
mon_host: {{ ceph.mon_host }}
{%- endif %}
policy.d:
01-controller-default.yaml: {{ service_policy }}
02-custom.yaml: {{ spec.get("features", {}).get("policies", {}).get("manila", {}) }}
manila:
{%- if is_ceph_enabled %}
DEFAULT:
enabled_share_protocols: CEPHFS
{%- endif %}
keystone_authtoken:
memcache_security_strategy: ENCRYPT
memcache_secret_key: {{ credentials[0].memcached }}
Expand Down Expand Up @@ -141,6 +182,7 @@ spec:
prometheus_exporter:
rabbit_exporters: "overview,exchange,node"
{%- endif %}
{%- if not share_backends %}
standalone_backends:
daemonset:
conf:
Expand All @@ -157,9 +199,15 @@ spec:
path_to_private_key: /etc/manila/ssh/manila
DEFAULT:
enabled_share_backends: generic
{%- endif %}
logging:
logger_manila:
level: {{ spec.get('features', {}).get('logging', {}).get('manila', {}).get('level', 'INFO') }}
{%- if share_sts %}
overrides:
manila_share_sts:
{{ share_sts | toyaml | indent(10) }}
{%- endif %}
jobs:
{% include 'base/_ks_jobs.yaml' %}
db_purge:
Expand All @@ -186,6 +234,7 @@ spec:
manifests:
secret_ca_bundle: true
cron_job_db_purge: {{ manila_db_cleanup.enabled }}
daemonset_share: true
daemonset_share: {{ not share_backends }}
service_instance_ssh_key: true
network_policy: {{ spec.features.network_policies.enabled }}
ceph_conf: {{ is_ceph_enabled }}
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ baremetal:
password: KBecvsPZsWBFzDqYnevHWArm7tFycZKr
username: neutronLeRjiDsyT
shared-file-system:
is_ceph_enabled: false
credentials: &credentials_shared-file-system
- database:
user:
Expand Down
Loading

0 comments on commit 5ee198b

Please sign in to comment.