From 94a4d30901bf9edac08cdcb7363dcb42680e8c80 Mon Sep 17 00:00:00 2001
From: Rodrigo Barbieri <rodrigo.barbieri2010@gmail.com>
Date: Thu, 18 Jul 2024 17:09:24 -0300
Subject: [PATCH] Add goodness-function config

This allows specifying functions that further optimize the scheduling
of shares across backend stanzas.

This is needed due to a netapp-driver specific problem when using
SVM scoped accounts. It does not have enough permissions to obtain
the total_capacity_gb information, so it cannot calculate utilization,
and therefore the goodness_function always returns 50 and end up
scheduling shares always to the same pool.

Closes-bug: #2073537
Change-Id: Ia151c50421e75282f633e0b004c2e6c1bda638f3
---
 config.yaml                  | 8 ++++++++
 templates/queens/manila.conf | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/config.yaml b/config.yaml
index 9cf81c8..80d729c 100644
--- a/config.yaml
+++ b/config.yaml
@@ -131,3 +131,11 @@ options:
       LIF through which the share is exported. A Vserver static route is
       configured using this gateway.
     default: "172.16.31.1"
+  goodness-function:
+    type: string
+    description: |
+      Specify an optional goodness function (as a string) that will be
+      run against the backend to determine its goodness score for scheduling.
+      Please refer to the Manila documentation for the function structure,
+      valid operands and operators.
+    default: ""
diff --git a/templates/queens/manila.conf b/templates/queens/manila.conf
index 2438051..438dcee 100644
--- a/templates/queens/manila.conf
+++ b/templates/queens/manila.conf
@@ -11,7 +11,9 @@ netapp_transport_type = {{ options.transport_type }}
 netapp_server_port = {{ options.netapp_server_port }}
 backend_availability_zone = {{ options.backend_availability_zone }}
 netapp_aggregate_name_search_pattern = {{ options.aggregate_name_search_pattern }}
-
+{% if options.goodness_function %}
+goodness_function = "{{ options.goodness_function }}"
+{% endif %}
 {%- if options.driver_handles_share_servers %}
 netapp_root_volume_aggregate = {{ options.root_volume_aggregate_name }}
 netapp_root_volume_name = {{ options.root_volume_name }}