apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.02k stars 2.46k forks source link

bug: google-cloud-logging plugin refresh_access_token(): failed to refresh google oauth access token #11166

Open zkl94 opened 3 months ago

zkl94 commented 3 months ago

Current Behavior

it is not able to send request logs to google cloud logging now due to this bug.

Expected Behavior

The logs should be sent to google cloud logging successfully

Error Logs

2024/04/18 19:03:44 [error] 55#55: 67159 [lua] oauth.lua:62: refresh_access_token(): failed to refresh google oauth access token, 20: unable to get local issuer certificate, context: ngx.timer, client: 10.186.156.41, server: 0.0.0.0:9443 2024/04/18 19:03:44 [error] 55#55: 67159 [lua] batch-processor.lua:95: Batch Processor[google-cloud-logging] failed to process entries: failed to get google oauth token, context: ngx.timer, client: 10.186.156.41, server: 0.0.0.0:9443

Steps to Reproduce

  1. run apisix helm chart https://artifacthub.io/packages/helm/apisix/apisix on k8s 1.27 on GKE
  2. create the below ApisixGlobalRule CR (the GCP SA has owner access just in case of permission issue)
    
    apiVersion: apisix.apache.org/v2
    kind: ApisixGlobalRule
    metadata:
    name: google-cloud-logging
    spec:
    plugins:
    - name: google-cloud-logging
      enable: true
      config:
        auth_config:
          client_email: "xxxxxx"
          private_key_id: "xxxxx"
          client_id: "xxxxx"
          private_key: "xxxxx"
          project_id: "xxxxx"
          token_uri: "https://oauth2.googleapis.com/token"
          entries_uri: "https://logging.googleapis.com/v2/entries:write"
          auth_uri: "https://accounts.google.com/o/oauth2/auth"
          ssl_verify: false
        batch_max_size: 1
        retry_delay: 1
        inactive_timeout: 10
        max_retry_count: 10
3. just in case it is not applied globally, I added the google-cloud-logging section to ApisixRoute as well:

apiVersion: apisix.apache.org/v2 kind: ApisixRoute metadata: name: apisix-dashboard spec: http:

Environment

nitishfy commented 3 months ago

Thanks for raising this issue! It seems like the SSL/TLS certificate of the server issuing the OAuth token cannot be verified.

zkl94 commented 3 months ago

@nitishfy Could you suggest your solution? According to my understanding, Google is the entity issuing the OAuth token. What is the wrong configuration that you see here? Are you saying that google SSL/TLS certificate cannot be verified?

balaji-n4 commented 2 months ago

@nitishfy could you explain how to fix the issue or any work around for the issue?