Error talking to API Manager: {"name":"UniqueConstraintError","message":"Deployment already exists for the API"} - mulesoft

I am creating CICD pipeline for deploying mule proxy application to cloud hub. My approach is to using anypoint cli to automate the deployment. Using anypoint cli i am able to add api from exchange to api manager, but while deploying the proxy application to cloud hub i am getting the following error
Error: Error talking to API Manager: {"name":"UniqueConstraintError","message":"Deployment already exists for the API"} [code 400]
Below is the command which i am using to deploy the proxy application to cloudhub
api-mgr api deploy --applicationName muleweatherapi --gatewayVersion 4.4.0 --overwrite true 17946730
where 17946730 is the asset id.

That API ID name may already be in use by another application deployed in CloudHub. Ensure that only one application has the API ID.
See this KB article for more details: https://help.mulesoft.com/s/article/Unable-to-deploy-to-CloudHub-UniqueConstraintError

Related

where to get deployment logs of azure app service VS-Code extension

i have a react site that am trying to deploy to azure app service (free tiers windows) plan.
i am using VS-Code's Azure App service extention.
when i right click deploy to web app i get the error
11:44:47 AM amn-react-app: Starting deployment...
11:44:47 AM amn-react-app: Creating zip package...
11:53:39 AM amn-react-app: Zip package size: 298 MB
11:53:40 AM: Error: An error has occurred.
where to see the deployment logs to check what happened ?
update
following the update below i was able to see logs but they still not telling details.
I use vscode create a sample react project to test.
And I found, we can check delpoyment logs on portal.
Method 1
Method 2
I also try to use rest api to get deployments info, but failed because I don't find deployment id. If you are interested, you can also try.
Web Apps - Get Deployment

Updating task queue of appengine application via cloud build fails with PERMISSION_DENIED

I have a simple cloud build pipeline that updates the task queue of an appengine application via gcloud app deploy backend/src/main/config/queue.yaml. This fails with the following log ouput:
descriptor: [/workspace/backend/src/main/config/queue.yaml]
type: [task queues]
target project: [<project>]
ERROR: (gcloud.app.deploy) PERMISSION_DENIED: The caller does not have permission
I already assigned the following roles to the cloudbuild service account ...#cloudbuild.gserviceaccount.com of the project.
roles/appengine.appAdmin
roles/cloudtasks.admin
roles/cloudtasks.queueAdmin
Any ideas what i´m missing?
Thanks!
I found a similar issue on the Public Issue Tracker. It seems as you only need to add an extra permission roles/serviceusage.serviceUsageViewer and it should work.

Unable to access app engine datastore via Objectify on a local server

I am trying to run an app engine spring project on localhost using eclipse. I am getting the following error in the console.
Apr 23, 2018 4:01:04 PM com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.net.SocketException: Network is unreachable: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:104)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
at com.google.auth.oauth2.ComputeEngineCredentials.runningOnComputeEngine(ComputeEngineCredentials.java:191)
at com.google.auth.oauth2.DefaultCredentialsProvider.tryGetComputeCredentials(DefaultCredentialsProvider.java:270)
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentialsUnsynchronized(DefaultCredentialsProvider.java:194)
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:112)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:127)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:100)
at com.google.cloud.ServiceOptions.defaultCredentials(ServiceOptions.java:298)
at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:272)
at com.google.cloud.datastore.DatastoreOptions.<init>(DatastoreOptions.java:102)
at com.google.cloud.datastore.DatastoreOptions.<init>(DatastoreOptions.java:35)
...
How do I provide credentials to use the datastore in localhost?
I get the following on the console when i access the datastore.
2018-04-23 17:22:05.849:WARN:oejs.ServletHandler:qtp152005629-14: org.spring.framework.web.util.NestedServletException: Request processing failed; nested exception is com.google.cloud.datastore.DatastoreException: Unauthenticated.
Caused by:
com.google.cloud.datastore.DatastoreException: Unauthenticated
Objectify v6 uses the Datastore SDK for Google Cloud Platform (which you could think of as GCP's "general purpose" SDK). That SDK makes actual API calls to the cloud service, even when it's being run locally. If you want to run tests/develop against a local datastore, you need to do one of two things.
Option One
Instead of using the GCP Datastore SDK, use the App Engine SDK’s Datastore bindings. Objectify has committed in v6 to using the GCP SDK, but v5 used the App Engine SDK. You can downgrade to v5 and everything will "just work".
Option Two
If you want to keep using Objectify v6, you need to install an extra gcloud component to run a local datastore emulator and you'll need to set some environment variables. More details here, but the short version goes:
Install and start the datastore emulator:
$ gcloud components install cloud-datastore-emulator
$ gcloud beta emulators datastore start
Then tell your application where to find it:
$ (gcloud beta emulators datastore env-init)
Or you can set the relevant env vars manually. On the machine that runs your application, set the environment variables and values as directed by the output of the env-init command. For example:
gcloud beta emulators datastore env-init
export DATASTORE_EMULATOR_HOST=localhost:8432
export DATASTORE_PROJECT_ID=my-project-id

Google App Engine Flex Throws 502 After adding Cloud Endpoints

I have an app running on App Engine Flex (Google Go Runtime with a couple extra file in the docker runtime). It was working fine, with no issues.
I then added Google Cloud Endpoints and all of a sudden I was getting 502s for every request, both going directly to the app & going through Cloud Endpoints.
Logging into the instance, it looks like the nginx-proxy itself is throwing errors.
Downloading Endpoints Service Configuration to /etc/nginx/endpoints/service.json
curl: (22) The requested URL returned error: 403 Forbidden
Failed to obtain Endpoints Service Configuration from Service Management API
/sbin/start-stop-daemon: warning: failed to kill 26: No such process
The only addition to the app.yaml is
endpoints_api_service:
name: "redacted.appspot.com"
config_id: "2017-06-01r0"
I'm running the latest version of gcloud. I was getting 403 forbidden when deploying the openapi.yaml file, and then I updated to the latest gcloud which fixed that issue. Not sure if that's related or not.
Has anyone even encountered this before?
From Cloud Console UI, could you double check if your project has "Google Service Management API" enabled?
If already enabled, you can SSH into your Flex vm, and fetch the access token by:
curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
Then you can use this URL to check its scopes
https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=
Turns out the core issue was that the version of gcloud I first used to upload google cloud endpoints allowed me to use an unsupported parameter (File). After switching to a wildcard, everything worked.

Deploy a Spring app (JAR) for browser

I have no knowledge about deployment, production server, web server, etc. But I have a web application and my boss wants to deploy it in order to access it by web browser.
So, my application was generated by Spring Initializr.
It's using Spring (Boot, Security, Web, Data JPA), with web service REST (#RestController), HTML templates and AngularJS.
With mvn clean package, I generated a JAR file of this application. It is working on my desk. But, how can I deploy it?
I believe that my company has an OVH hosting. Can I install JBOSS or Tomcat on it, and upload my JAR on OVH?
You can deploy your application on Tomcat but you need to have a war instead of a jar to run it on an existing application server.
You can read the following documentation to create the war : http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging
Once done, you just have to upload it on the server in the webapps directory of your tomcat server.

Resources