GoogleCloudPlatform / application-integration-management-toolkit

This tool lets you interact with Application Integration, Integration Connectors or Apigee Integration/Connector APIs. The tool lets you manage (create, del, get, list) integrations, connections etc.
Apache License 2.0
22 stars 16 forks source link

Integration deploy with create not working as expected #126

Closed kondurure closed 10 months ago

kondurure commented 1 year ago

I'm trying to region specific deployments (overrides will be differ per region) with integrationcli integrations create but noticed below two issues post integration deployment to target environment.

integrationcli version 0.69.1-beta

1) I have few regions specific parm override for environments but with integrationcli integrations create, overrides from overrides not reflecting in target environments:

overrides for us-central1:

"param_overrides": [
    {
        "key": "_coveoUrl",
        "defaultValue": {
            "stringValue": "https://*************rest/search/v2"
        }
    },
    {
        "key": "_ctBrandUrl",
        "defaultValue": {
            "stringValue": "https://api.us-central1.*******.com/hl-shop-stg/graphql"
        }
    },
    {
        "key": "_ctCcUrl",
        "defaultValue": {
            "stringValue": "https://api.us-central1.**********.com/hl-shop-stg/graphql"
        }
    }
]

overrides for europe-west1:

"param_overrides": [
    {
        "key": "_coveoUrl",
        "defaultValue": {
            "stringValue": "https://*************rest/search/v2"
        }
    },
    {
        "key": "_ctBrandUrl",
        "defaultValue": {
            "stringValue": "https://api.europe-west1.*******.com/hl-shop-stg/graphql"
        }
    },
    {
        "key": "_ctCcUrl",
        "defaultValue": {
            "stringValue": "https://api.europe-west1.**********.com/hl-shop-stg/graphql"
        }
    }
]

2) we have requirement to deploy connectors and integrations in two regions (us-cetral1 and west-europe1) with same name but overrides of integrations differ Expectation: Integration of us-cetral1 should refer to us-cetral1 connector and Integration of west-europe1 should refer to west-europe1 connector

issue: integration which deployed in west-europe1 by using integrations create option, referring to us-cetral1 connector instead of west-europe1.

whereas above two issues not encountering if i use integration apply but here limitation is we don't have option to choose overrides based on regions

srinandan commented 1 year ago

Can you please show the actual commands that were executed? In the sequence you executed them.

kondurure commented 1 year ago

here is the integration execution.

      token=$(gcloud auth print-access-token)
      export INTEGRATIONCLI_VERSION=v0.69.1-beta
      curl -L https://raw.githubusercontent.com/GoogleCloudPlatform/application-integration-management-toolkit/main/downloadLatest.sh | sh -
      /home/runner/.integrationcli/bin/integrationcli prefs set --reg=${{ inputs.region }} --proj=${{ inputs.organization }}
      /home/runner/.integrationcli/bin/integrationcli token cache -t $token
      if [ "${{ inputs.region }}" == "europe-west1" ]; then
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides-weu.json > /tmp/response
      else
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o '${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides.json' > /tmp/response
      fi 
      echo "integration response: " $(cat /tmp/response)
      basename $(cat /tmp/response | jq -r .name) > /tmp/version
      echo "integration version: " $(cat /tmp/version)
      /home/runner/.integrationcli/bin/integrationcli integrations versions publish -n ${{ inputs.integration_name }} -v $(cat /tmp/version)
srinandan commented 1 year ago

Based on the commands you have entered, I think the behavior is expected.

You have the following line:

/home/runner/.integrationcli/bin/integrationcli prefs set --reg=${{ inputs.region }} --proj=${{ inputs.organization }}

This sets the region to ${{ inputs.region }} for all subsequent commands.

You have two options

  1. Don't set region as a preference and for every command pass the -r flag or
  2. Set a default region (just like you have done), and override the region with a -r flag when you want it to point to another region.
ssvaidyanathan commented 1 year ago

can you confirm its executing the if else condition you have correctly? Do you see the echo command getting executed if the region is europe-west1?

kondurure commented 1 year ago

Yes, it executing as expected, echo command executing when the region is europe-west1. image

@srinandan, as suggested tried with 1st option deployment failing with below error.

Tried with both options as suggested but both are not working.

1) getting Error: region was not set in preferences or supplied in the command

      /home/runner/.integrationcli/bin/integrationcli prefs set --proj=${{ inputs.organization }} 
      /home/runner/.integrationcli/bin/integrationcli token cache -t $token  > /tmp/logs.tst
      if [ "${{ inputs.region }}" == "europe-west1" ]; then
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides-weu.json -r ${{ inputs.region }} > /tmp/response
      else
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o '${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides.json' -r ${{ inputs.region }} > /tmp/response

      fi 

image

2) integration deployments is success but overrides not happening from overrides.

      if [ "${{ inputs.region }}" == "europe-west1" ]; then
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli prefs set --reg=${{ inputs.region }} --proj=${{ inputs.organization }}
        /home/runner/.integrationcli/bin/integrationcli token cache -t $token  > /tmp/logs.txt
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides-weu.json -r ${{ inputs.region }} > /tmp/response
      else
        /home/runner/.integrationcli/bin/integrationcli prefs set --reg=${{ inputs.region }} --proj=${{ inputs.organization }}
        /home/runner/.integrationcli/bin/integrationcli token cache -t $token  > /tmp/logs.txt
        echo "Integration deploy in ${{ inputs.region }}"
        /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -u $SHORT_SHA -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides.json -r ${{ inputs.region }} > /tmp/response
      fi 
ssvaidyanathan commented 1 year ago

can you test this from your local machine. Just execute the integrationcli command and make sure its doing the right thing for both regions?

srinandan commented 1 year ago

I recommend two things

  1. Since you are setting the flag -r with the integrationcli integrations create, I would remove the -r flag from the integrationcli pres set command.
  2. I recommend rerunning the command integrationcli integrations create with --verbose so we can see what is being to sent to the control plane.
srinandan commented 1 year ago

Since debug may have sensitive information, please send the logs to @ssvaidyanathan by email.

kondurure commented 1 year ago

Thanks @srinandan and @ssvaidyanathan. tried with manual deployment and deployment went fine as expected. /home/runner/.integrationcli/bin/integrationcli token cache -t $token > /tmp/logs.txt /home/runner/.integrationcli/bin/integrationcli prefs set --proj=${{ inputs.organization }} if [ "${{ inputs.region }}" == "europe-west1" ]; then echo "Integration deploy in ${{ inputs.region }}" /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides-weu.json -r ${{ inputs.region }} > /tmp/response else echo "Integration deploy in ${{ inputs.region }}" /home/runner/.integrationcli/bin/integrationcli integrations create -n ${{ inputs.integration_name }} -f ${{ github.workspace }}/src/${{ inputs.integration_name }}.json -o ${{ github.workspace }}/overrides/${{ inputs.deploy_environment }}/overrides.json -r ${{ inputs.region }} > /tmp/response fi echo "integration response: " $(cat /tmp/response)
basename $(cat /tmp/response | jq -r .name) > /tmp/version echo "integration version: " $(cat /tmp/version) /home/runner/.integrationcli/bin/integrationcli integrations versions publish -n ${{ inputs.integration_name }} -v $(cat /tmp/version) -r ${{ inputs.region }}