apigee / apigee-deploy-maven-plugin

Apache License 2.0
80 stars 167 forks source link

Maven loops infinitely if some Apigee X/hybrid proxy validation fails #158

Closed laughingbiscuit closed 3 years ago

laughingbiscuit commented 3 years ago

Steps to reproduce: 1) Run mvn install on a bundle with an invalid OAS specification 2) Note that maven is looping (tested at 3mins+)

Request prepared for the server                                                       
 **************************                                                           
GET  https://apigee.googleapis.com/v1/organizations/***/environments/test/apis/demo-v1/revisions/1/deployments
accept: [application/json]
accept-encoding: [gzip]
authorization: [Bearer [Not shown in log]
x-goog-api-format-version: 2
[INFO] Getting Deployment Info for Revision: 1                                       
[INFO] Using the bearer token
[INFO]

3) In a separate session, get the deployment status...

davissean@seans-dev-env:~$ curl -H "Authorization: Bearer $(gcloud auth print-access-token)" https://apigee.googleapis.com/v1/organizations/***/environments/test/apis/demo-v1/revisions/1/deployments
{
  "environment": "test",
  "apiProxy": "demo-v1",
  "revision": "1",
  "deployStartTime": "1621338729262",
  "state": "ERROR",
  "errors": [
    {
      "code": 2,
      "message": "instance \"cluster-gke-europe-west1\" reported error steps.oasvalidation.OasCompilationFailed: \"OASValidation : Compilation of OASResource oas://OpenAPI-Spec-Validation-1.json failed with error:com.atlassian.oai.validator.OpenApiInteractionValidator$ApiLoadException: Unable to load API spec from provided URL or payload:\\n\\t- attribute paths.'/'(get).responses.200.description is missing. Context {2}\""    
    }
  ],
  "instances": [
    {
      "instance": "cluster-gke-europe-west1",                                        
      "deployedRoutes": [
        {
          "basepath": "/demo/v1",
          "envgroup": "test-group",
          "environment": "test",
          "percentage": 100
        }
      ]
    }
  ]
}

Desired behaviour: mvn command will fail if "state": "ERROR" rather than endlessly looping.

ssvaidyanathan commented 3 years ago

I just tried deploying a proxy with an invalid policy, the plugin fails as expected

Request prepared for the server
 **************************
POST  https://apigee.googleapis.com/v1/organizations/***/apis?action=import&name=Mock-v1
accept: [application/json]
accept-encoding: [gzip]
authorization: [Bearer [Not shown in log]
x-goog-api-format-version: 2
content-type: multipart/form-data; boundary=__END_OF_PART__
 [Request body contains data, not shown]

[ERROR] 400 Bad Request
{
  "error": {
    "code": 400,
    "message": "bundle contains errors",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/edge.configstore.bundle.BadBundle",
        "violations": [
          {
            "filename": "apiproxy/policies/AM-Set-Headers.xml",
            "description": "unknown XML root element \"AssinMessage\""
          },
          {
            "filename": "apiproxy/proxies/default.xml",
            "description": "The Step element references policies that don't exist: \"AM-Set-Headers\"."
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.RequestInfo",
        "requestId": "9158716448136585439"
      }
    ]
  }
}

[ERROR]

* * * * * * * * * * *

This deployment could have failed for a variety of reasons.

* * * * * * * * * * *

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.899 s
[INFO] Finished at: 2021-05-18T10:15:54-07:00
[INFO] ------------------------------------------------------------------------

Looks like its failing only when the error is beyond the validation that runs while importing the bundle

ssvaidyanathan commented 3 years ago

Fixed and released in v2.1.1