2/26/2020

Validate an openapi or swagger API definition from a Gitlab-CI test step

Lets say you've built $BUILD_IMAGE container image at the build step. I did it on a NodeJS based project but it will work with other technology as well.

check-openapi-contract:
  stage: test
  retry: 1
  timeout: 15m
  script:
    - docker run --name=my-container -d -i -p 8080:8080 --rm $BUILD_IMAGE npm start
    - bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/swagger.json)" != "200" ]]; do sleep 5; done'
    - docker exec -i my-container curl http://localhost:8080/swagger.json -o ./swagger.json
    - docker exec -i my-container npx swagger-cli validate ./swagger.json

So what do we do? We start the server, then retrieve the swagger.json or openapi.json and leverage swagger-cli validate command to ensure our definition is valid and be notified if it is not. Nothing. More.

11/14/2019

Google Cloud Run - how to fix "ERROR: (gcloud.beta.run.deploy) Resource readiness deadline exceeded."

As a full-stack developer you might want to deploy your containers on Google Cloud Run instead of managing a full-blown Kubernetes cluster with knative on top of it. However please note that Google Cloud Run is currently still in beta so your experience may vary.

Yesterday I saw increased build failure related to a soon-to-be-merge branch from a co-worker, the CI gcloud run deploy command yields:

ERROR: (gcloud.beta.run.deploy) Resource readiness deadline exceeded.

Unlike in a traditional Kubernetes cluster, Readiness probes are not currently configurable in Cloud Run full managed mode and looking inside Cloud Run logs everything seemed to be fine, the app was listening to 8080 after some time.

After a deep dive into the code changes I found that some new code was delaying for up to 12 seconds the app socket listening step. Worst, those 12 seconds delay was a measure I took on my MacBook and this new code was highly Disk I/O bound so it explained why Cloud Run readiness probe timed out.

The fix was then to remove this delay and load what was needed from the filesystem on-demand (instead of loading everything — with a lot of never-used stuff — somewhere in the app life-cycle). I hope this post will help someone because I've found nothing on the web on that matter :) !

10/25/2019

Fix the SchemaError(io.k8s.api.apps.v1beta2.StatefulSetStatus): invalid object doesn't have additional properties error

Issue: Kubernetes API server version and kubectl CLI version mismatch.

  • Kubernetes API server version (e.g. v1.14.7) 
  • kubectl CLI version (e.g. {Major:"1", Minor:"10"})

Solution: upgrade kubectl 👍

« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.