apigee / devrel

Common solutions and tools developed for Apigee
Apache License 2.0
181 stars 159 forks source link

Identity-facade fails to deploy with missing API Proxy ID error #582

Closed cyterdan closed 2 years ago

cyterdan commented 2 years ago

Hi,

I'm following the readme here : https://github.com/apigee/devrel/tree/main/references/identity-facade

I've setup the env variables.

Running ./pipeline.sh --googleapi against a freshly created evaluation environment yields the following maven error:

[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:2.2.2:deploy (deploy-bundle-step) on project apigee-deployer: MojoExecutionException: 400 Bad Request [ERROR] { [ERROR] "error": { [ERROR] "code": 400, [ERROR] "message": "invalid API proxy name \"organizations/my org id/apis/\": missing API Proxy ID", [ERROR] "status": "INVALID_ARGUMENT", [ERROR] "details": [ [ERROR] { [ERROR] "@type": "type.googleapis.com/google.rpc.RequestInfo", [ERROR] "requestId": "5523700978876868598" [ERROR] } [ERROR] ] [ERROR] } [ERROR] } [ERROR] -> [Help 1

Appreciate any help here.

Thanks

danistrebel commented 2 years ago

I haven't seen a "missing API Proxy ID" error. Can you confirm you set the org/env/hostname variables as described here: https://github.com/apigee/devrel/tree/main/references/identity-facade#apigee-x--hybrid?

Adding @JoelGauci to see if he has an idea

OmidTahouri commented 2 years ago

I've also not seen this error from the API before. @cyterdan what shell environment are you running in?

cyterdan commented 2 years ago

I'm using standard bash on ubuntu.

The 3 env variables are set and seem to be getting picked up since I can see them in the logs.

danistrebel commented 2 years ago

That sounds reasonable. Just to be sure can we try if this returns the correct environment resource?

curl https://apigee.googleapis.com/v1/organizations/$APIGEE_X_ORG/environments/$APIGEE_X_ENV -v -H "Authorization: Bearer $(gcloud auth print-access-token)"

If there's nothing fishy with the variables I'd try to get verbose output from the deployment by adding --debug on this line here https://github.com/apigee/devrel/blob/main/references/identity-facade/pipeline.sh#L357.

JoelGauci commented 2 years ago

@cyterdan : can you please answer @danistrebel point? On my side I have been able to reproduce the exact same error message than you with a ./identity-facade/apiproxy/identity-facade-v1.xml that is corrupted. Here are some examples of corrupted contents:

APIProxy revision="1" xxname="identity-facade-v1" // bad attribute

or

APIProxies revision="1" name="identity-facade-v1" // bad xml element

Can you please also check the content of this file: ./identity-facade/apiproxy/identity-facade-v1.xml has not been modified/corrupted?

cyterdan commented 2 years ago

Appreciate the help on this.

@danistrebel : I get back something that seems valid:

{ "name": "eval", "createdAt": "1659550540653", "lastModifiedAt": "1659550544930", "state": "ACTIVE", "deploymentType": "PROXY", "apiProxyType": "PROGRAMMABLE" }

will attempt the debug flag.

@JoelGauci: that's interesting, the xml seems valid:

cyterdan commented 2 years ago

With the --debug flag added, I get the following

[INFO] --- apigee-edge-maven-plugin:2.2.2:deploy (deploy-bundle-step) @ apigee-deployer --- [DEBUG] Configuring mojo io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:2.2.2:deploy from plugin realm ClassRealm[plugin>io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:2.2.2, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057] [DEBUG] Configuring mojo 'io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:2.2.2:deploy' with basic configurator --> [DEBUG] (f) apiType = apiproxy [DEBUG] (f) apiVersion = v1 [DEBUG] (f) artifactId = apigee-deployer [DEBUG] (f) authType = basic [DEBUG] (s) baseDirectory = /tmp/devrel/references/identity-facade/deploy-1660147025-4854 [DEBUG] (f) bearer = (redacted) [DEBUG] (f) buildDirectory = /tmp/devrel/references/identity-facade/deploy-1660147025-4854/target [DEBUG] (f) deploymentEnv = eval [DEBUG] (f) googleTokenEmail = [DEBUG] (f) hostURL = https://apigee.googleapis.com [DEBUG] (s) options = override [DEBUG] (f) orgName = (redacted) [DEBUG] (f) projectName = [DEBUG] (f) projectVersion = v1 [DEBUG] (s) skip = false [DEBUG] (f) tokenURL = https://login.apigee.com/oauth/token [DEBUG] -- end configuration -- 15:57:13.168 [main] ERROR io.apigee.buildTools.enterprise4g.rest.RestUtil - 400 Bad Request { "error": { "code": 400, "message": "invalid API proxy name \"organizations/insite360-apigee-playground-dc/apis/\": missing API Proxy ID", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.RequestInfo", "requestId": "15925111396599043037" } ] } }

15:57:13.173 [main] ERROR io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo -

danistrebel commented 2 years ago

As @JoelGauci hinted I am able to reproduce it if I change the manifest.xml e.g. references/oidc-mock/apiproxy/oidc-mock-v1.xml from

<APIProxy revision="1" name="oidc-mock-v1"/>

to

<APIProxy revision="1"/>

To see what's going on you could prevent the temporary deployment folder from being deleted by commenting out this line: https://github.com/apigee/devrel/blob/main/tools/apigee-sackmesser/cmd/deploy/deploy.sh#L31

which should keep the folder references/identity-facade/deploy-XYZ after you see the error. Depending on the proxy that fails to deploy file in question should be references/identity-facade/deploy-XYZ/apiproxy/oidc-mock-v1.xml or similar.

cyterdan commented 2 years ago

The proxy that seems to be failing to deploy is identity-facade-v1. I removed the delete step and the xml file (identity-facade/deploy-1660227591-9063/apiproxy/identity-facade-v1.xml) contains :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!--
 Copyright 2020 Google LLC
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<APIProxy revision="1" name="identity-facade-v1"/>

I'm looking at the various XML files generated but so far they all look valid

JoelGauci commented 2 years ago

@cyterdan Just some ideas/questions that come to my mind:

  1. Could you control there are no special characters in the identity-facade-v1.xml file?
  2. If you apply the sackmesser command to deploy the API proxy (identity-facade-v1) out of the execution of the pipeline.sh script, what is the result?
  3. Can you try to deploy another Apigee Devrel reference to see if it is deployed correctly?

Thanks

cyterdan commented 2 years ago

I just tried running this from another instance and it worked just great.

Definitely had some corrupted files (the edge.json files as it turned out). thanks for pointing me in the right direction, this issue can be closed.

OmidTahouri commented 2 years ago

Thanks for coming back to clarify and close the issue! Good luck!