SUSE / ha-sap-terraform-deployments

Automated SAP/HA Deployments in Public/Private Clouds
GNU General Public License v3.0
120 stars 88 forks source link

Pre-deployment of HANA scale-out cluster with no stand-by nodes fails with Jinja error: 'NoneType' object is not iterable #912

Closed abravosuse closed 9 months ago

abravosuse commented 9 months ago

Used cloud platform Azure

Used SLES4SAP version SLES15SP4

Used client machine OS openSUSE Leap 15.2

Expected behaviour vs observed behaviour Expected behavior: Deployment of HANA scale-out cluster (with no standby node) Observed behabior: predeployment fails

How to reproduce Specify the step by step process to reproduce the issue. This usually would look like something like this:

  1. Switch to the azure folder
  2. Create the terraform.tfvars file based on terraform.tfvars.example (content pasted later)
  3. Setup azure account
  4. Initialize terraform terraform init
  5. Create and switch to terraform workspace hsonsb terraform workspace new hsonsb
  6. Execute deployment terraform apply -auto-approve

Used terraform.tfvars

resource_group_name = "<my_rg>"
vnet_address_range = "10.130.0.0/16"
subnet_address_range = "10.130.1.0/24"
admin_user = "cloudadmin"
reg_code = "<my_internal_code>"
reg_email = "alberto.bravo@suse.com"
os_image = "SUSE:sles-sap-15-sp4-byos:gen2:latest"
public_key  = "~/.ssh/id_rsa_cloud.pub"
private_key = "~/.ssh/id_rsa_cloud"
cluster_ssh_pub = "salt://sshkeys/cluster.id_rsa.pub"
cluster_ssh_key = "salt://sshkeys/cluster.id_rsa"
ha_sap_deployment_repo = "https://download.opensuse.org/repositories/network:ha-clustering:sap-deployments:v9/"
provisioning_log_level = "error"
pre_deployment = true
cleanup_secrets = true
bastion_enabled = false
hana_name = "vmhsonsb"
hana_count = "4"
hana_scale_out_enabled = true
hana_scale_out_standby_count = 0
hana_scale_out_shared_storage_type = "anf"      
anf_pool_size                      = "4"    
anf_pool_service_level             = "Standard" 
hana_scale_out_anf_quota_shared    = "2000" 
storage_account_name = "<my_storage_account_name>"
storage_account_key = "<my_storage_account_key>"
hana_inst_master = "//<my_storage_account_name>.file.core.windows.net/hana/51055267"
hana_ha_enabled = true
hana_ips = ["10.130.1.11", "10.130.1.12", "10.130.1.13", "10.130.1.14"]
hana_cluster_vip = "10.130.1.15"
hana_sid = "SC1"
hana_instance_number = "30"
hana_master_password = "<my_password>"
hana_primary_site = "NBG"
hana_secondary_site = "WDF"
hana_cluster_fencing_mechanism = "sbd"
iscsi_name = "vmiscsihsonsb"
iscsi_srv_ip = "10.130.1.4"

Logs

Full log files salt-os-setup.log, salt-predeployment.log and salt-result.log will be delivered via PM if needed. The salt-result.log file ends with the following:

local:
    Data failed to compile:
    Rendering SLS "predeployment:shared_storage.nfs" failed: Jinja error: "NoneType" object is not iterable
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/utils/templates.py", line 476, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 63, in top-level template code
TypeError: 'NoneType' object is not iterable

; line 63

[...]
  {% elif (host_num|int % 2) == 0 %}
    {% set site = 2 %}
  {% endif %}
{% endif %}

{%- for mount in mounts %}    <======================
  # role+provider section
  {% if grains['role'] == "netweaver_node" %}
    # globally set netweaver nfs variables
    {% if grains['netweaver_nfs_share'] != "" %}
      # define IPs and share
[...]
---
Wed Nov  8 13:58:01 UTC 2023::vmhsonsb02::[ERROR] predeployment failed
yeoldegrove commented 9 months ago

@abravosuse Please have a look at https://github.com/SUSE/ha-sap-terraform-deployments/blob/d27d45e6a36c4ced8e5134ecb3f9eab13a4fc908/azure/terraform.tfvars.example#L245-L264

You need a hana_data_disks_configuration without /hana/shared. The default is a scale-up configuration which of course includes /hana/shared. This way, a netapp volume for /hana/shared will be created and https://github.com/SUSE/ha-sap-terraform-deployments/blob/d27d45e6a36c4ced8e5134ecb3f9eab13a4fc908/azure/modules/hana_node/salt_provisioner.tf#L44 and https://github.com/SUSE/ha-sap-terraform-deployments/blob/d27d45e6a36c4ced8e5134ecb3f9eab13a4fc908/salt/shared_storage/nfs.sls#L40 will not result in an empty anf_mount_ip.shared.

abravosuse commented 9 months ago

Thank you @yeoldegrove ! I was able to move forward including a hana_data_disks_configuration without /hana/shared in the terraform.tfvars file. Unfortunately I'm running now into another issue. But I close this ticket and open a new one for the latter.