GCP errors in discovery log - Pattern name: Google Cloud Platform (GCP) - Virtual Server


Description

Discovery of Google Cloud Platform fails.

The discovery log contains an error message pointing at the missing relation to the LDC [cmdb_ci_logical_datacenter] for resources not listed in the Regions API response.

The following is an example of the error message:

In payload no relations defined for dependent class [cmdb_ci_<table_name>] that matches any containment/hosting rules: 
[cmdb_ci_<table_name> >> Hosted on >> cmdb_ci_logical_datacenter,cmdb_ci_<table_name> >> Hosted on >> cmdb_ci_cloud_service_account].
Add appropriate relations in payload for '{resource in cmdb_ci_<table_name> in the payload}'

or

Identifier: Identification CI Errors:
In payload no relations defined for dependent class [cmdb_ci_disk_type] that matches any containment/hosting rules:
[cmdb_ci_disk_type >> Hosted on >> cmdb_ci_logical_datacenter]. Add appropriate relations in payload for '{"className":"cmdb_ci_disk_type","values":

Cause

Discovery fails if Google API calls return values for resource location that are not defined in the list of Regions for LDC [cmdb_ci_logical_datacenter]. When such a value is returned, the pattern cannot create a relation to the Google LDC. At the next step, the pattern payload is passed to the IRE, and the identification fails, because there is no valid identification relating to the LDC [cmdb_ci_logical_datacenter].

Steps to Reproduce

- Run GCP Discovery
- errors in discovery log:

2020-06-22 00:22:09: Identification CI Errors:
In payload no relations defined for dependent class [cmdb_ci_compute_template] that matches any containment/hosting rules: [cmdb_ci_compute_template >> Hosted on >> cmdb_ci_logical_datacenter,cmdb_ci_compute_template >> Hosted on >> cmdb_ci_cloud_service_account]. Add appropriate relations in payload for '{"className":"cmdb_ci_compute_template","values":{"short_description":"1 vCPU, 3.75 GB RAM","local_storage_gb":"10","discovery_source":"ServiceNow","zone":"europe-west5-c","name":"n1-standard-1","memory_mb":"3840","vcpus":"1","object_id":"3001:europe-west5-c","sys_class_name":"cmdb_ci_compute_template"}}',Too many other errors,In payload no relations defined for dependent class [cmdb_ci_compute_template] that matches any containment/hosting rules: [cmdb_ci_compute_template >> Hosted on >> cmdb_ci_logical_datacenter,cmdb_ci_compute_template >> Hosted on >> cmdb_ci_cloud_service_account]. Add appropriate relations in payload for '{"className":"cmdb_ci_compute_t

Workaround

As a workaround, either

Import the attached update set.

Please navigate to MID servers and click on 'Pattern Sync to Mid' UI action/button (at the top of the MID servers list).

or   

Manually add the missing regions to the Google LDC table in the Google GCP - Get Logical Datacenter pattern shared library by following these steps:

  1. Add "Set Parameter Value" step before the step 1.17 "Create a relation between account and LDC" in "Google GCP - Get Logical Datacenter" pattern shared library
  2. On Value field type EVAL() and click on the edit button that would appear
  3. Input the following text - further regions may be added if necessary

    var table = new Packages.java.util.ArrayList()
    var region = "europe-west5"
    var row = new Packages.java.util.HashMap();
    row.put("object_id", region)
    row.put("name", region)
    row.put("region", region)
    row.put("short_description", region)
    row.put("state", "1")
    row.put("operational_status", "1")
    table.add(row)

    var region = "us-east2"
    var row = new Packages.java.util.HashMap();
    row.put("object_id", region)
    row.put("name", region)
    row.put("region", region)
    row.put("short_description", region)
    row.put("state", "1")
    row.put("operational_status", "1")
    table.add(row)

    var region = "us-east3"
    var row = new Packages.java.util.HashMap();
    row.put("object_id", region)
    row.put("name", region)
    row.put("region", region)
    row.put("short_description", region)
    row.put("state", "1")
    row.put("operational_status", "1")
    table.add(row)

    var region = "us-central2"
    var row = new Packages.java.util.HashMap();
    row.put("object_id", region)
    row.put("name", region)
    row.put("region", region)
    row.put("short_description", region)
    row.put("state", "1")
    row.put("operational_status", "1")
    table.add(row)

    var region = "northamerica-northeast2"
    var row = new Packages.java.util.HashMap();
    row.put("object_id", region)
    row.put("name", region)
    row.put("region", region)
    row.put("short_description", region)
    row.put("state", "1")
    row.put("operational_status", "1")
    table.add(row)

    CTX.setAttribute("ldc_workaround", table)         

  4. Save script
  5. Create 1 new step after this one of type "Merge Table"
  6. use the following values

                6.1 Pre-condition

                                $shouldFilterBasedOnLDC            Equals   "false"

                6.2. First Table

                                $cmdb_ci_google_datacenter

                6.3 Second table

                                $ldc_workaround

                6.4 Target Table

                                $cmdb_ci_google_datacenter

                6.5 Merge Criteria

                                Field matching

                6.6 First Table Field

                                region

                6.7 Second Table Field

                                region

                6.8 Unmatched Values

                                Keep

Note: Also, confirm that cloud resources in datacenters whose location is not defined under Regions should be discovered. If not, the related pattern can be modified to ignore such resources.


Related Problem: PRB1411605