Fork me on GitHub
#datomic
<
2022-02-15
>
shields01:02:04

Finally working on the big upgrade for Datomic Cloud and when going to version 939-9127 I'm getting a 502 Bad Gateway response when calling the newly created IonApiGatewayEndpoint . Any suggestions?

Jarrod Taylor (Clojure team)02:02:25

Can you provide more detail on what has been done with regard to upgrading? How are you calling the ion endpoint and have you deployed an app that you expect to be able to hit?

shields02:02:57

• Upgrade Process going from 704-8957 -> 939-9127 ◦ Upgraded Storage succesfully ◦ Failed to upgrade compute nodes in CF(rollback) ◦ Deleted Compute nodes ◦ Created new nodes successfully with 939-9127 template ◦ Updated deps.edn w/ https://docs.datomic.com/cloud/releases.html#current ◦ Able to get data locally with the new ClientApiGatewayEndpoint ◦ Removed (apigw/ionize app) function ◦ App is using Reitit similar to https://github.com/JarrodCTaylor/ion-cognito-exemplar/blob/main/src/ion_cognito_exemplar/core.clj#L36 ◦ Edited ion-config.edn similar to https://github.com/JarrodCTaylor/ion-cognito-exemplar/blob/main/resources/datomic/ion-config.edn ◦ Push/deploy successfully ◦ Grabbed the IonApiGatewayEndpoint and it returns a 502 Bad Gateway response when calling from the browser, with curl, and with Postman.

shields02:02:38

Wondering if there is more configuration needed in API-Gateway. I see, in the terraform scripts the routes were configured someway. https://github.com/JarrodCTaylor/ion-cognito-exemplar/blob/main/scripts/main.tf#L88

shields20:02:19

Used your example app @U0508JRJC without the auth endpoints and I'm still getting the error after a successful deploy. Found this https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html#http-502-issues But not sure how to debug.

Jarrod Taylor (Clojure team)20:02:24

The terraform script is only modifying the api-gateway routes to accommodate the public/private routing in the example this isn’t strictly required for any application as a default. The default route created by the cloud formation script will proxy all requests to your app and in your case the reitit router. I would suspect the application as the source of the problem before turning to the LB. A newly created stack will return a 502 if there isn’t an app deployed yet. Can you run the application locally? Are you trying to hit the root ion endpoint or a deeper path in your router?

shields21:02:08

The app runs locally. I've tried both the base endpoint and the deeper paths. Changes to the app after upgrade: • Removed (apigw/ionize app) function • Removed the :integration :api-gateway/proxy lambda from the ion-config.edn • Edited ion-config.edn to

{:allow       [blvd.blvd-app-api.router/app]

 :http-direct {:handler-fn blvd.blvd-app-api.router/app}

 :app-name    "our-app-name"}

shields21:02:13

;;; Public routes
(defn ping-response [_]
  {:status 200
   :body   {:message "Pong'ing back"}})

(def public-routes
  ["/public"
   ["/ping" {:name ::ping
             :get  {:handler ping-response}}]])

(def app
  (ring/ring-handler
    (ring/router
      ["/api/v1" [public-routes]]
      {:data      {:muuntaja   m/instance
                   :middleware [mw/options-mw
                                mw/cors-mw
                                parameters/parameters-middleware
                                muuntaja/format-middleware]}})
    (ring/create-default-handler)))

Jarrod Taylor (Clojure team)22:02:43

That all appears correct, but I assume there is more to the application? If you want to / can share the actual application code I can poke it further <mailto:[email protected]|[email protected]> or JarrodCTaylor on github. If that is not an option you can enable logging in the api gateway which I don’t expect will report much other than that there was a 502 response issued, but it is something I always do when debugging.

shields22:02:47

Thanks, I'll keep poking at it tonight and if I don't figure it out will shoot you an e-mail tomorrow. One last question here, you said we'd get 502 if the app hasn't been deployed. Is there a way to check in the console if it was deployed other than the successful response and in the Step Functions? In the last version the lambda would be created for the proxy, anything similar for http-direct?

shields17:02:18

@U0508JRJC Any answer to that last question. I was able to clone your repo and deploy it to our system and hit the endpoint successfully. But when I deploy your app from our #polylith repo it doesn't connect. We've changed our deps to match yours. I've had no issue deploying from Polylith before with the ionize functions and they say in their https://clojurians.slack.com/archives/C013B7MQHJQ/p1645027134110639 they've been able to deploy on the latest version. Lambas also are built but the Ions endpoint isn't callable. Just wondering if the app is being deployed or not and wondering where I can check.

Jarrod Taylor (Clojure team)02:02:25

I will get a replay back to you tomorrow.

gratitude-thank-you 1