Skip to content

Commit

Permalink
Add option to handle absent cross_az_attach
Browse files Browse the repository at this point in the history
At the moment volumes for workers are gonna be spawn in a default
AZ completely disregarding user request for Availability Zone.

In a design where cross_az_attach is disabled, an attempt
to add a volume to worker has high failure percentage due to fallback
to the default scheduling zone, unless allow_availability_zone_fallback
is disabled.

This patch adds a configuration option `cross_az_attach` which is set
to True by default to align with Nova typical behavior. It will define
AZ to be set to `nova` according to a CSI default [1].

When `cross_az_attach` is set to False, AZ for the volume will be set to
the cluster AZ value.
This ensures that volume will be created in a same zone as workers are
preventing failures.

[1] https://github.com/kubernetes/cloud-provider-openstack/blob/d228854cf58e7b4ed93d5e7ba68ab639450e3449/docs/cinder-csi-plugin/using-cinder-csi-plugin.md#supported-parameters

Relates-to: #366
  • Loading branch information
noonedeadpunk committed Nov 29, 2024
1 parent 724a3fb commit 04da372
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
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`
16 changes: 16 additions & 0 deletions magnum_cluster_api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
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 +102,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 +172,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
9 changes: 9 additions & 0 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ 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 +341,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

0 comments on commit 04da372

Please sign in to comment.