Search code examples
gcloudgoogle-cloud-run

Any way to reduce output from Google Cloud Run emulator?


The Google Cloud Run emulator (gcloud beta code dev) watches for file changes and rebuilds on every change.

So, in my terminal, there's a constant churn of building messages as I type, and it's distracting.

I tried (reference: https://cloud.google.com/sdk/gcloud/reference)

  • --verbosity="none" (no effect)
  • --quiet just elminates interactivity.
  • --no-user-output-enabled crashes the emulator with
Flag --enable-rpc has been deprecated, flags --rpc-port or --rpc-http-port now imply --enable-rpc=true, so please use only those instead
^CException in thread Thread-13:
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()

and a whole bunch more that I can copy if it matters.

Is there a way to either silence build logs, but still get (1) my own console.logs and (2) errors?


Solution

  • I suspect (because your question was the first time I became aware of this [useful] facility) that, because gcloud beta code dev is using (in my case) minikube (locally), the output is being generated by minikube (kubelet) process and not gcloud, that you can't (yet!) control the output by adding gcloud flags.

    It's a good suggestion and I recommend you file an issue on Google's Issue Tracker.

    kubectl (!) has a new configuration that points to minikube while it's running and (!) I'm able to kubectl logs deployment/${APP} from another term to view only my app's logs:

    kubectl get deployments
    NAME      READY   UP-TO-DATE   AVAILABLE   AGE
    ${APP}    1/1     1            1           1m
    
    kubectl logs deployment/${APP}
    2022/01/06 17:21:58 Entered
    2022/01/06 17:21:58 Starting server [:8080]
    2022/01/06 17:21:58 Sleeping
    2022/01/06 17:26:58 Awake
    2022/01/06 17:26:58 Sleeping
    

    ~/.kube/config:

    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority: /path/to/.minikube/ca.crt
        extensions:
        - extension:
            last-update: Thu, 06 Jan 2022 09:21:47 PST
            provider: minikube.sigs.k8s.io
            version: v1.24.0
          name: cluster_info
        server: https://192.168.49.2:8443
      name: gcloud-local-dev
    contexts:
    - context:
        cluster: gcloud-local-dev
        extensions:
        - extension:
            last-update: Thu, 06 Jan 2022 09:21:47 PST
            provider: minikube.sigs.k8s.io
            version: v1.24.0
          name: context_info
        namespace: default
        user: gcloud-local-dev
      name: gcloud-local-dev
    current-context: gcloud-local-dev
    kind: Config
    preferences: {}
    users:
    - name: gcloud-local-dev
      user:
        client-certificate: /path/to/.minikube/profiles/gcloud-local-dev/client.crt
        client-key: /path/to/.minikube/profiles/gcloud-local-dev/client.key