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

[azure_rm_openshiftmanagedcluster] properties.clusterProfile.resourceGroupId set to null, produces error #1628

Closed
paulczar opened this issue Jul 11, 2024 · 1 comment · Fixed by #1629
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority

Comments

@paulczar
Copy link
Contributor

SUMMARY

When trying to deploy an aro cluster, it fails with "error": {\n "code": "InvalidParameter",\n "message": "The provided resource group \'\' is invalid.",\n "target": "properties.clusterProfile.resourceGroupId"\n }\n}\n', 400)

This field is not set in my task, therefore should be null, the error sees it as an empty string which may be the problem?

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_openshiftmanagedcluster

ANSIBLE VERSION
ansible [core 2.17.1]
  config file = /Users/pczarkow/dev/redhat/ansible/ansible-aro/ansible.cfg
  configured module search path = ['/Users/pczarkow/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/Users/pczarkow/dev/redhat/ansible/ansible-aro/plugins/modules']
  ansible python module location = /Users/pczarkow/dev/redhat/ansible/ansible-aro/virtualenv/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/pczarkow/.ansible/collections:/usr/share/ansible/collections
  executable location = ./virtualenv/bin/ansible
  python version = 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] (/Users/pczarkow/dev/redhat/ansible/ansible-aro/virtualenv/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
# /Users/pczarkow/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 2.6.0

# /Users/pczarkow/dev/redhat/ansible/ansible-aro/virtualenv/lib/python3.12/site-packages/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 2.4.0
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
   - name: Create openshift cluster
      azure.azcollection.azure_rm_openshiftmanagedcluster:
        resource_group: "{{ azr_resource_group }}"
        name: "{{ azr_aro_cluster }}"
        location: "{{ azr_location }}"
        # cluster_profile:
        ingress_profiles:
          - visibility: "{{ azr_aro_public_ingress | ternary('Public', 'Private') }}"
        api_server_profile:
          visibility: "{{ azr_aro_public_api | ternary('Public', 'Private') }}"
        service_principal_profile:
          client_id: "{{ azr_service_principal_application_id }}"
          client_secret: "{{ azr_service_principal_application_secret }}"
        network_profile:
          pod_cidr: "10.128.0.0/14"
          service_cidr: "172.30.0.0/16"
        worker_profiles:
          - vm_size : "Standard_D4s_v3"
            subnet_id : "{{ _machine_subnet.state.id }}"
            disk_size : 128
            count : 3
            name: worker
        master_profile:
          vm_size : "Standard_D8s_v3"
          subnet_id: "{{ _control_subnet.state.id }}"
EXPECTED RESULTS
ACTUAL RESULTS
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: pczarkow
<localhost> EXEC /bin/sh -c 'echo ~pczarkow && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/pczarkow/.ansible/tmp `"&& mkdir "` echo /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779 `" && echo ansible-tmp-1720729734.072547-32027-108228347043779="` echo /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779 `" ) && sleep 0'
Using module file /Users/pczarkow/.ansible/collections/ansible_collections/azure/azcollection/plugins/modules/azure_rm_openshiftmanagedcluster.py
<localhost> PUT /Users/pczarkow/.ansible/tmp/ansible-local-27702710ei523/tmpuecmyl9w TO /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779/AnsiballZ_azure_rm_openshiftmanagedcluster.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779/ /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779/AnsiballZ_azure_rm_openshiftmanagedcluster.py && sleep 0'
<localhost> EXEC /bin/sh -c './virtualenv/bin/python /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779/AnsiballZ_azure_rm_openshiftmanagedcluster.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/pczarkow/.ansible/tmp/ansible-tmp-1720729734.072547-32027-108228347043779/ > /dev/null 2>&1 && sleep 0'

TASK [roles/cluster-create : Create openshift cluster] *********************************************************************************************************************************************************************************
task path: /Users/pczarkow/dev/redhat/ansible/ansible-aro/roles/cluster-create/tasks/main.yml:39
The full traceback is:
  File "/var/folders/9w/p_xqbz6j46zd9gn5mqw3gd800000gn/T/ansible_azure.azcollection.azure_rm_openshiftmanagedcluster_payload_vf4u00lc/ansible_azure.azcollection.azure_rm_openshiftmanagedcluster_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_openshiftmanagedcluster.py", line 730, in create_update_resource
    response = self.mgmt_client.query(self.url,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/folders/9w/p_xqbz6j46zd9gn5mqw3gd800000gn/T/ansible_azure.azcollection.azure_rm_openshiftmanagedcluster_payload_vf4u00lc/ansible_azure.azcollection.azure_rm_openshiftmanagedcluster_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common_rest.py", line 86, in query
    raise exp
fatal: [localhost]: FAILED! => changed=false
  invocation:
    module_args:
      ad_user: null
      adfs_authority_url: null
      api_profile: latest
      api_server_profile:
        ip: null
        url: null
        visibility: Public
      append_tags: true
      auth_source: auto
      cert_validation_mode: null
      client_id: null
      cloud_environment: AzureCloud
      cluster_profile:
        cluster_resource_group_id: null
        domain: null
        pull_secret: null
        version: null
      disable_instance_discovery: false
      ingress_profiles:
      - ip: null
        name: default
        visibility: Public
      location: eastus
      log_mode: null
      log_path: null
      master_profile:
        subnet_id: /subscriptions/xxxxxxx/resourceGroups/ans-pczarkow-rg/providers/Microsoft.Network/virtualNetworks/openshift-vnet/subnets/openshift-control-subnet
        vm_size: Standard_D8s_v3
      name: ans-pczarkow
      network_profile:
        pod_cidr: 10.128.0.0/14
        service_cidr: 172.30.0.0/16
      password: null
      profile: null
      provisioning_state: null
      resource_group: ans-pczarkow-rg
      secret: null
      service_principal_profile:
        client_id: xxxx
        client_secret: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      state: present
      subscription_id: null
      tags: null
      tenant: null
      thumbprint: null
      worker_profiles:
      - count: 3
        disk_size: 128
        name: worker
        subnet_id: /subscriptions/xxxxx/resourceGroups/ans-pczarkow-rg/providers/Microsoft.Network/virtualNetworks/openshift-vnet/subnets/openshift-machine-subnet
        vm_size: Standard_D4s_v3
      x509_certificate_path: null
  msg: |-
    Error creating the OpenShiftManagedCluster instance: {'properties': {'clusterProfile': {'pullSecret': None, 'resourceGroupId': None, 'domain': 'tqdjn3yb', 'version': None}, 'servicePrincipalProfile': {'ClientId': 'xxxx', 'clientSecret': '********'}, 'networkProfile': {'podCidr': '10.128.0.0/14', 'serviceCidr': '172.30.0.0/16'}, 'masterProfile': {'subnetId': '/subscriptions/xxxx/resourceGroups/ans-pczarkow-rg/providers/Microsoft.Network/virtualNetworks/openshift-vnet/subnets/openshift-control-subnet', 'vmSize': 'Standard_D8s_v3'}, 'workerProfiles': [{'name': 'worker', 'subnetId': '/subscriptionsxxxxxxresourceGroups/ans-pczarkow-rg/providers/Microsoft.Network/virtualNetworks/openshift-vnet/subnets/openshift-machine-subnet', 'count': 3, 'vmSize': 'Standard_D4s_v3', 'diskSizeGB': 128}], 'apiserverProfile': {'visibility': 'Public', 'url': None, 'ip': None}, 'ingressProfiles': [{'visibility': 'Public', 'name': 'default', 'ip': None}]}, 'location': 'eastus'}
    ('{\n    "error": {\n        "code": "InvalidParameter",\n        "message": "The provided resource group \'\' is invalid.",\n        "target": "properties.clusterProfile.resourceGroupId"\n    }\n}\n', 400)
@paulczar
Copy link
Contributor Author

p3ck added a commit that referenced this issue Jul 11, 2024
Looks like we need to check if the attribute is set before trying to use it.

Fixes #1628
@Fred-sun Fred-sun added bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority labels Jul 15, 2024
xuzhang3 pushed a commit that referenced this issue Jul 23, 2024
Looks like we need to check if the attribute is set before trying to use it.

Fixes #1628
Justwmz pushed a commit to Justwmz/azure that referenced this issue Nov 4, 2024
Looks like we need to check if the attribute is set before trying to use it.

Fixes ansible-collections#1628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants