HewlettPackard / terraform-provider-oneview

Automates the provisioning of physical infrastructure from a private cloud using templates from HPE OneView with Terraform
Apache License 2.0
49 stars 30 forks source link

Creating Server profile for DLs fails #404

Closed ClaireHayard closed 3 years ago

ClaireHayard commented 3 years ago

Scenario/Intent

Hello,

I am trying to create SPT and SP for DLs servers using terraform modules. However, the terraform execution fails when creating the Server Profiles from their templates.

Note: during the workflow, the creation of the Server Profile Templates is successfull.

Environment Details

Expected Result

The Server Profiles for the DLs are configured using the previously created SPT.

Actual Result

Error: An unexpected problem occurred and has been logged at approximately 2021-09-24 13:39:21.604 UTC. 
Retry the operation. If the problem persists, contact your authorized support representative and provide a support dump.

  on ../Server_Profile/main.tf line 1, in resource "oneview_server_profile" "ServerProfiles":
   1: resource "oneview_server_profile" "ServerProfiles" {
yuvirani commented 3 years ago

@ClaireHayard, Thanks for reaching us, we were able to reproduce the error. Here is the fix:

When you create server profile template with bios option, we must provide overridden_settings along with manage_bios attribute. Otherwise, you will not be able to create SP from template, though SPT creation is successful. Please add the below code in your configuration and let us know if this resolved your issue.

 bios_option {
    manage_bios = true
    overridden_settings {
      id    = "TimeFormat"
      value = "Utc"
    }
  }
ClaireHayard commented 3 years ago

Hello @yuvirani,

I added the overriden_settings attribute as you said and the creation of the SP is now working fine. However, I now have an idempotency issue when I do a second terraform apply for the SPT. Do I have to add other parameters to achieve idempotency for the DLs SPT ?

  # module.server_profile_templates.oneview_server_profile_template.ServerProfileTemplate["SPTDL380G10TRNOD"] will be updated in-place
  ~ resource "oneview_server_profile_template" "ServerProfileTemplate" {
        id                        = "SPTDL380G10TRNOD"
        name                      = "SPTDL380G10TRNOD"
        # (17 unchanged attributes hidden)

      ~ boot {
          + compliance_control = "Checked"
            # (2 unchanged attributes hidden)
        }

      - local_storage {
          - compliance_control = "CheckedMinimum" -> null

          - controller {
              - device_slot              = "Embedded" -> null
              - drive_write_cache        = "Unmanaged" -> null
              - import_configuration     = false -> null
              - initialize               = true -> null
              - mode                     = "Mixed" -> null
              - predictive_spare_rebuild = "Unmanaged" -> null

              - logical_drives {
                  - accelerator         = "Unmanaged" -> null
                  - bootable            = false -> null
                  - name                = "SYSTEM" -> null
                  - num_physical_drives = 2 -> null
                  - num_spare_drives    = 0 -> null
                  - raid_level          = "RAID1" -> null
                  - sas_logical_jbod_id = 0 -> null
                }
            }
        }
      + local_storage {
          + compliance_control = "CheckedMinimum"

          + controller {
              + device_slot       = "Embedded"
              + drive_write_cache = "Unmanaged"
              + initialize        = true
              + mode              = "Mixed"

              + logical_drives {
                  + accelerator         = "Unmanaged"
                  + bootable            = false
                  + name                = "SYSTEM"
                  + num_physical_drives = 2
                  + raid_level          = "RAID1"
                }
            }
        }

        # (5 unchanged blocks hidden)
    }

Plan: 0 to add, 2 to change, 0 to destroy.
yuvirani commented 3 years ago

@ClaireHayard, We have fixed the idempotency issue of SPT. Please pull latest changes from master and close this issue if it worked as expected.

ClaireHayard commented 3 years ago

Hello @yuvirani,

I still have the same issue with the same blocks that are changed. In addition, the firmware block is also part of the changes announced by the terraform apply command.

      ~ firmware {
          + firmware_activation_type = "Immediate"
          + firmware_baseline_uri    = "null"
          + firmware_install_type    = "FirmwareOnly"
            # (3 unchanged attributes hidden)
        }
ClaireHayard commented 3 years ago

Here is the complete output from my terraform plan:

 # module.server_profile_templates.oneview_server_profile_template.ServerProfileTemplate["sptdl380g10trnod"] will be updated in-place
  ~ resource "oneview_server_profile_template" "ServerProfileTemplate" {
        id                        = "sptdl380g10trnod"
        name                      = "sptdl380g10trnod"
        # (17 unchanged attributes hidden)

      ~ boot {
          + compliance_control = "Checked"
            # (2 unchanged attributes hidden)
        }

      ~ firmware {
          + firmware_activation_type = "Immediate"
          + firmware_install_type    = "FirmwareOnly"
            # (3 unchanged attributes hidden)
        }

      - local_storage {
          - compliance_control = "CheckedMinimum" -> null

          - controller {
              - device_slot              = "Embedded" -> null
              - drive_write_cache        = "Unmanaged" -> null
              - import_configuration     = false -> null
              - initialize               = true -> null
              - mode                     = "Mixed" -> null
              - predictive_spare_rebuild = "Unmanaged" -> null

              - logical_drives {
                  - accelerator         = "Unmanaged" -> null
                  - bootable            = true -> null
                  - name                = "SYSTEM" -> null
                  - num_physical_drives = 2 -> null
                  - num_spare_drives    = 0 -> null
                  - raid_level          = "RAID1" -> null
                  - sas_logical_jbod_id = 0 -> null
                }
            }
        }
      + local_storage {
          + compliance_control = "CheckedMinimum"

          + controller {
              + device_slot       = "Embedded"
              + drive_write_cache = "Unmanaged"
              + initialize        = true
              + mode              = "Mixed"

              + logical_drives {
                  + accelerator         = "Unmanaged"
                  + bootable            = true
                  + name                = "SYSTEM"
                  + num_physical_drives = 2
                  + raid_level          = "RAID1"
                }
            }
        }

        # (4 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
nabhajit-ray commented 3 years ago

Hi @ClaireHayard ,

I tried creating SPT using the configuration shared. The local storage attribute have to be changed to below to resolve idempotency issue:

local_storage = { storage_ctlr_checking = "CheckedMinimum"

  # Controller parameters
  device_slot             = "Embedded" #Not present in LLD > to check
  import_configuration     = false
  reinitialize_controller = true
  predictive_spare_rebuild = "Unmanaged"
  write_cache             = "Unmanaged"
  disk_mode               = "Mixed"

  # Logical drive options/parameter
  accelerator        = "Unmanaged"
  drive_bootable     = false #Correspond to "boot" in LLD ?
  drive_technology   = null
  logical_drive_name = "SYSTEM" #Not present in LLD
  num_phys_drives    = 2 #Not present in LLD
  num_spare_drives   = 0
  raid_level         = "RAID1"
}

As for the firmware being non idempotent, again the data needs to be modified . In the firmware section the manage_firmware atribute is set as false since it is not mentioned. With false value, other firmware attributes is not relevant. In case you want to set manage firmware as true the attributes should be as below:

firmware = { compliance_control = "Unchecked" manage_firmware = true firmware_baseline_uri = "/rest/firmware-drivers/Synergy_Custom_SPP_2021_02_01_Z7550-97110" force_install_firmware = false firmware_install_type = "FirmwareOnlyOfflineMode" firmware_activation_type = "Immediate" }

Please add this in your configuration and let us know the idempotency is resolved or not.

Thanks

ClaireHayard commented 3 years ago

Hello @nabhajit-ray,

I have a new configuration for my DLs:

      local_storage = object({
        storage_ctlr_checking = string
      })
      controller = list(object({
        device_slot              = string
        import_configuration     = bool
        reinitialize_controller  = bool
        predictive_spare_rebuild = string
        write_cache              = string
        disk_mode                = string
        logical_drives = list(object({
          accelerator        = string
          drive_bootable     = bool
          drive_technology   = string
          logical_drive_name = string
          num_phys_drives    = number
          num_spare_drives   = number
          raid_level         = string
        }))
      }))

      firmware = object({
        firmware_compliance_control = string
        manage_firmware             = bool
        firmware_baseline_uri       = string
        force_install_firmware      = bool
        firmware_install_type       = string
        firmware_activation_type    = string
      })

I don't have any new changes on the local storage, as described above. However, I still have some issues on the firmware when doing a second apply command. Here are the changes from the second apply:

      ~ firmware {
          ~ compliance_control       = "Unchecked" -> "Checked"
          + firmware_activation_type = "Immediate"
          + firmware_install_type    = "FirmwareOnly"
ClaireHayard commented 3 years ago

I am commenting those three parameters from the firmware block as I do not have a valid SPP to test it with. As I was putting the "manage_firmware" parameter to false, all other parameters were logically not taken into account and causing issue for idempotency.

I will test my code again when I have a working SPP.