Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to handle absent cross_az_attach #464

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/user/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,14 @@ Options under this group are used for configuring Openstack authentication for C
: If set, then the server's certificate will not be verified.
**Type**: `boolean`
**Default value**: `False`

## cinder
Options under this group are used for configuring OpenStack Cinder behavior.

`cross_az_attach`

: When set to False, Cluster Availability Zone will be used to create a volume.
For that Availability Zone names in Cinder and Nova should match.
Otherwise, default `nova` Availability Zone will be used for volumes.
**Type**: `boolean`
**Default value**: `True`
14 changes: 14 additions & 0 deletions magnum_cluster_api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
name="capi_client", title="Options for the Cluster API client"
)

cinder_group = cfg.OptGroup(name="cinder", title="Options for the Cinder client")

manila_client_group = cfg.OptGroup(
name="manila_client", title="Options for the Manila client"
)
Expand Down Expand Up @@ -98,6 +100,17 @@
),
]

cinder_opts = [
cfg.BoolOpt(
"cross_az_attach",
default=True,
help=_(
"In case of multiple availability zones, allows to create and "
"attach volumes from random AZ to worker nodes. When set to False "
"Availability Zone names in Cinder and Nova should match."
),
)
]

manila_client_opts = [
cfg.StrOpt(
Expand Down Expand Up @@ -157,6 +170,7 @@
(auto_scaling_group, auto_scaling_opts),
(capi_client_group, capi_client_opts),
(capi_client_group, common_security_opts),
(cinder_group, cinder_opts),
(manila_client_group, manila_client_opts),
(manila_client_group, common_security_opts),
(proxy_group, proxy_opts),
Expand Down
10 changes: 10 additions & 0 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ def get_object(self) -> pykube.ConfigMap:
if cinder.is_enabled(self.cluster):
volume_types = osc.cinder().volume_types.list()
default_volume_type = osc.cinder().volume_types.default()
# Default is set in accordance to the CSI:
# https://github.com/kubernetes/cloud-provider-openstack/blob/d228854cf58e7b4ed93d5e7ba68ab639450e3449/docs/cinder-csi-plugin/using-cinder-csi-plugin.md#supported-parameters
# If allow_availability_zone_fallback is set to False in Cinder
# and "nova" AZ is not present in Cinder, CSI request will fail.
volume_availability_zone = "nova"
if not CONF.cinder.cross_az_attach:
volume_availability_zone = self.cluster.labels.get(
"availability_zone", volume_availability_zone
)
data = {
**data,
**{
Expand Down Expand Up @@ -333,6 +342,7 @@ def get_object(self) -> pykube.ConfigMap:
"provisioner": "cinder.csi.openstack.org",
"parameters": {
"type": vt.name,
"availability": volume_availability_zone,
},
"reclaimPolicy": "Delete",
"volumeBindingMode": "Immediate",
Expand Down
Loading