apigee / apigee-deploy-maven-plugin

Apache License 2.0
80 stars 167 forks source link

Error in undeploying Shared Flow bundle - HTTP Status 415 Unsupported Media Type #169

Closed rodrigoaraujorosa closed 2 years ago

rodrigoaraujorosa commented 2 years ago

Hi,

we are trying to deploy Shared Flows, but Apigee is returning HTTP Status 415 at the time of undeploying the current Shared Flow revision. We are using version 1.2.2 of apigee-edge-maven-plugin.

Note: for proxies deploys this does not happen.

Below is our profile configuration:

<profile>
    <id>myenv</id>
    <properties>
        <org>myorg</org>  <!-- default org, replace with default org to avoid passing parameter e.g. -Dorg testmyapi -->
        <options>validate</options>  <!-- default org, replace with default org to avoid passing parameter e.g. -Dorg testmyapi -->
        <apigee.profile>myenv</apigee.profile>
        <apigee.env>myenv</apigee.env>
        <apigee.hosturl>http://apigee-host:8080</apigee.hosturl>
        <apigee.apiversion>v1</apigee.apiversion>
        <apigee.apitype>sharedflow</apigee.apitype> <!-- This is only for Shared Flows. Not required for deploying proxy -->
        <apigee.org>${org}</apigee.org>
        <apigee.username>${username}</apigee.username>
        <apigee.password>${password}</apigee.password>
        <apigee.options>${options}</apigee.options> <!-- Shared Flow supports override and update -->
        <apigee.tokenurl>${tokenurl}</apigee.tokenurl> <!-- optional: oauth -->
        <apigee.mfatoken>${mfatoken}</apigee.mfatoken> <!-- optional: mfa -->
        <apigee.authtype>${authtype}</apigee.authtype> <!-- optional: oauth|basic(default) -->
        <apigee.bearer>${bearer}</apigee.bearer> <!-- optional: Bearer token override -->
        <apigee.refresh>${refresh}</apigee.refresh> <!-- optional: Refresh token override -->
        <apigee.clientid>${clientId}</apigee.clientid> <!-- optional: Oauth Client Id - Default is edgecli-->
        <apigee.clientsecret>${clientSecret}</apigee.clientsecret> <!-- optional: Oauth Client Secret Default is edgeclisecret-->
    </properties>
</profile>

Command executed:

mvn install -Pmyenv -Dusername=someuser -Dpassword=somepass -Dorg=myorg -Dapigee.config.options=override

Error returned:

DELETE  http://apigee-host:8080/v1/organizations/myorg/environments/myenv/sharedflows/mysharedflow/revisions/2/deployments
accept: [application/json]                                                                                                        
accept-encoding: [gzip]                                                                                                           
authorization: [Basic [Not shown in log]                                                                                          
content-type: [application/x-www-form-urlencoded]                                                                                 
[ERROR] 415 Unsupported Media Type                                                                                                
[ERROR] The bundle is not undeployed                                                                                              
java.io.IOException: The bundle is not undeployed
.
.
.
[INFO] ------------------------------------------------------------------------                                                                                              
[INFO] BUILD FAILURE                                                                                                                                                         
[INFO] ------------------------------------------------------------------------                                                                                              
[INFO] Total time:  1.647 s                                                                                                                                                  
[INFO] Finished at: 2021-09-19T14:20:00-03:00                                                                                                                                
[INFO] ------------------------------------------------------------------------                                                                                              
[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.2.2:deploy (deploy-bundle) on project getnet: Error in undeploying bundle -> [Help 1]                                                                                                                                                                        

When we do the undeploy test via Postman, the error does not occur, as we are not setting the content-type to application/x-www-form-urlencoded

Postman test:

DELETE /v1/organizations/myorg/environments/myenv/sharedflows/mysharedflow/revisions/2/deployments HTTP/1.1
Accept: application/json
Authorization: Basic sometoken==
User-Agent: PostmanRuntime/7.28.4
Cache-Control: no-cache
Postman-Token: 45f6f362-5990-4654-92cf-d58c42bb4f70
Host: apigee-host:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

HTTP/1.1 200 OK
Date: Sun, 19 Sep 2021 17:38:26 GMT
Content-Type: application/json
X-Apigee.user: someuser
X-Apigee.organization: myorg
X-Apigee.environment: myenv
X-Apigee.backends: management-server
Date: Sun, 19 Sep 2021 17:38:26 GMT
Content-Length: 569

{
"environment" : "myenv",
"name" : "2",
"organization" : "myorg",
"revision" : "2",
"server" : [ {
"pod" : {
"name" : "gateway",
"region" : "dc-1"
},
"status" : "undeployed",
"type" : [ "message-processor" ],
"uUID" : "598f098f-f1a9-4f43-abb4-a87bcb63c65a"
}, {
"pod" : {
"name" : "gateway",
"region" : "dc-1"
},
"status" : "undeployed",
"type" : [ "message-processor" ],
"uUID" : "6e41d157-c133-45c0-bcdc-5358086495b1"
} ],
"sharedFlow" : "mysharedflow",
"state" : "undeployed"
}

I found a 2018 Issue with the same problem, but the guidelines described do not work in this latest version.

Could you help us?

ssvaidyanathan commented 2 years ago

Thanks @rodrigoaraujorosa for reaching out. Can you share the version of Apigee you are using? A side note - The argument you are using for override is wrong. You should be using -Dapigee.options=override That should not make any difference in the error you are seeing as the default for the deploy plugin is "override". Once I know the Apigee version, I can find out more

rodrigoaraujorosa commented 2 years ago

Hi @ssvaidyanathan we are using apigee version 4.50.00.

Thanks for the tip about the argument. Using -Dapigee.options=override, it works!!! Without the argument, it doesn't work.

ssvaidyanathan commented 2 years ago

@rodrigoaraujorosa - I believe if you pass the -Dapigee.options=override, the issue should not happen. Can you try that please?

Update your mvn call to something like this

mvn install -Pmyenv -Dusername=someuser -Dpassword=somepass -Dorg=myorg -Dapigee.options=override
ssvaidyanathan commented 2 years ago

Also I found an issue when you dont pass the apigee.options argument with that content-type. So I went ahead and pushed a new version 1.2.4 with the fix. You can do either of the following:

  1. Update the pom.xml to use 1.2.4 and leave everything as is
  2. Continue using 1.2.2 but make sure you pass the -Dapigee.options=override option