envoy icon indicating copy to clipboard operation
envoy copied to clipboard

GoogleGrpcValidationError thrown in envoy when setting ChannelCredentials to LocalCredentials

Open quanjielin opened this issue 8 years ago • 3 comments

Description: below error is thrown in envoy when setting ChannelCredentials to LocalCredentials

[2018-10-01 18:08:24.287][11][warning][config] bazel-out/k8-opt/bin/external/envoy/source/common/config/_virtual_includes/grpc_mux_subscription_lib/common/config/grpc_mux_subscription_impl.h:70] gRPC config for type.googleapis.com/envoy.api.v2.Cluster rejected: Proto constraint validation failed (ClusterValidationError.TlsContext: ["embedded message failed validation"] | caused by UpstreamTlsContextValidationError.CommonTlsContext: ["embedded message failed validation"] | caused by CommonTlsContextValidationError.TlsCertificateSdsSecretConfigs[i]: ["embedded message failed validation"] | caused by SdsSecretConfigValidationError.SdsConfig: ["embedded message failed validation"] | caused by ConfigSourceValidationError.ApiConfigSource: ["embedded message failed validation"] | caused by ApiConfigSourceValidationError.GrpcServices[i]: ["embedded message failed validation"] | caused by GrpcServiceValidationError.GoogleGrpc: ["embedded message failed validation"] | caused by GoogleGrpcValidationError.ChannelCredentials: ["embedded message failed validation"] | caused by field: "credential_specifier", reason: is required): name: "outbound|80||default-http-backend.kube-system.svc.cluster.local"
type: EDS
eds_cluster_config {
  eds_config {
    ads {
    }
  }
  service_name: "outbound|80||default-http-backend.kube-system.svc.cluster.local"
}
connect_timeout {
  seconds: 1
}
circuit_breakers {
  thresholds {
  }
}
tls_context {
  common_tls_context {
    validation_context {
      trusted_ca {
        filename: "/etc/istio/certs/ca-root-cert.pem"
      }
      verify_subject_alt_name: "spiffe://cluster.local/ns/kube-system/sa/default"
    }
    alpn_protocols: "istio"
    tls_certificate_sds_secret_configs {
      name: "spiffe://cluster.local/ns/kube-system/sa/default"
      sds_config {
        api_config_source {
          api_type: GRPC
          grpc_services {
            google_grpc {
              target_uri: "unix:/var/run/sds/uds_path"
              channel_credentials {
                3: ""
              }
              call_credentials {
                google_compute_engine {
                }
              }
              stat_prefix: "sdsstat"
            }
          }
        }
      }
    }
  }

Repro steps:

  1. setup a gRPC server in golang(istio pilot), which constructs and distributes SDS config to envoy
  2. start the gRPC server and envoy sidecars, error in above bug description is thrown in envoy, which prevents envoy updated config, error is pilot is
2018-10-01T18:08:29.101866Z	warn	ads	ADS:CDS: ACK ERROR 10.16.1.88:35264 sidecar~10.16.1.88~httpbin-6d6c88c4f5-sqsc2.foo~foo.svc.cluster.local-1 node:<id:"sidecar~10.16.1.88~httpbin-6d6c88c4f5-sqsc2.foo~foo.svc.cluster.local" cluster:"httpbin.default" metadata:<fields:<key:"INTERCEPTION_MODE" value:<string_value:"REDIRECT" > > fields:<key:"ISTIO_PROXY_SHA" value:<string_value:"istio-proxy:f49833732cab7e6f249760d1ec9d3ec19d19fe2c" > > fields:<key:"ISTIO_PROXY_VERSION" value:<string_value:"1.1.0" > > fields:<key:"ISTIO_VERSION" value:<string_value:"1.0-dev" > > fields:<key:"POD_NAME" value:<string_value:"httpbin-6d6c88c4f5-sqsc2" > > fields:<key:"istio" value:<string_value:"sidecar" > > > build_version:"f49833732cab7e6f249760d1ec9d3ec19d19fe2c/1.8.0-dev/Clean/RELEASE" > type_url:"type.googleapis.com/envoy.api.v2.Cluster" response_nonce:"e6f8c9c4-176f-4dcb-9fb8-c62684806bea" error_detail:<code:13 message:"Proto constraint validation failed (ClusterValidationError.TlsContext: [\"embedded message failed validation\"] | caused by UpstreamTlsContextValidationError.CommonTlsContext: [\"embedded message failed validation\"] | caused by CommonTlsContextValidationError.TlsCertificateSdsSecretConfigs[i]: [\"embedded message failed validation\"] | caused by SdsSecretConfigValidationError.SdsConfig: [\"embedded message failed validation\"] | caused by ConfigSourceValidationError.ApiConfigSource: [\"embedded message failed validation\"] | caused by ApiConfigSourceValidationError.GrpcServices[i]: [\"embedded message failed validation\"] | caused by GrpcServiceValidationError.GoogleGrpc: [\"embedded message failed validation\"] | caused by GoogleGrpcValidationError.ChannelCredentials: [\"embedded message failed validation\"] | caused by field: \"credential_specifier\", reason: is required): name: \"outbound|80||default-http-backend.kube-system.svc.cluster.local\"\ntype: EDS\neds_cluster_config {\n  eds_config {\n    ads {\n    }\n  }\n  service_name: \"outbound|80||default-http-backend.kube-system.svc.cluster.local\"\n}\nconnect_timeout {\n  seconds: 1\n}\ncircuit_breakers {\n  thresholds {\n  }\n}\ntls_context {\n  common_tls_context {\n    validation_context {\n      trusted_ca {\n        filename: \"/etc/istio/certs/ca-root-cert.pem\"\n      }\n      verify_subject_alt_name: \"spiffe://cluster.local/ns/kube-system/sa/default\"\n    }\n    alpn_protocols: \"istio\"\n    tls_certificate_sds_secret_configs {\n      name: \"spiffe://cluster.local/ns/kube-system/sa/default\"\n      sds_config {\n        api_config_source {\n          api_type: GRPC\n          grpc_services {\n            google_grpc {\n              target_uri: \"unix:/var/run/sds/uds_path\"\n              channel_credentials {\n                3: \"\"\n              }\n              call_credentials {\n                google_compute_engine {\n                }\n              }\n              stat_prefix: \"sdsstat\"\n            }\n          }\n        }\n      }\n    }\n  }\n  sni: \"outbound|80||default-http-backend.kube-system.svc.cluster.local\"\n}\n" > 
  1. add logs in pilot, the sdsconfig in LDS that istio pilot distribute to envoy is below, which should be valid format (local_credentials is specified)
*******LDS: PUSH for node:httpbin-6d6c88c4f5-sqsc2.foo addr:"10.16.1.88:35264" rawListener:{Name:10.16.1.88_8000 Address:{Address:0xc420597790 XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} FilterChains:[{FilterChainMatch:<nil> TlsContext:common_tls_context:<tls_certificate_sds_secret_configs:<name:"spiffe://cluster.local/ns/foo/sa/default" sds_config:<api_config_source:<api_type:GRPC grpc_services:<google_grpc:<target_uri:"unix:/var/run/sds/uds_path" channel_credentials:<local_credentials:<> > call_credentials:<google_compute_engine:<> > stat_prefix:"sdsstat" >
  1. If I wrote a go client tool to send SDS gRPC request to istio pilot, it also works fine to get response like beow, which is also in valid format -
   "filterChains": [
    {
     "tlsContext": {
      "commonTlsContext": {
       "tlsCertificateSdsSecretConfigs": [
        {
         "name": "spiffe://cluster.local/ns/foo/sa/default",
         "sdsConfig": {
          "apiConfigSource": {
           "apiType": "GRPC",
           "grpcServices": [
            {
             "googleGrpc": {
              "targetUri": "unix:/var/run/sds/uds_path",
              "channelCredentials": {
               "localCredentials": {

               }
              },
              "callCredentials": [
               {
                "googleComputeEngine": {

                }
               }
              ],
              "statPrefix": "sdsstat"
             }
            }
           ]
          }
         }
        }
       ],
       "validationContext": {
        "trustedCa": {
         "filename": "/etc/istio/certs/ca-root-cert.pem"
        }
  1. compared the response in go client tool/envoy logs, seems envoy translates channel_credentials to below format for some reason, and it fails the validate check.
    tls_certificate_sds_secret_configs {
      name: "spiffe://cluster.local/ns/kube-system/sa/default"
      sds_config {
        api_config_source {
          api_type: GRPC
          grpc_services {
            google_grpc {
              target_uri: "unix:/var/run/sds/uds_path"
              channel_credentials {
                3: ""
              }

quanjielin avatar Oct 01 '18 18:10 quanjielin

/cc @JimmyCYJ @htuch @qiwzhang

quanjielin avatar Oct 01 '18 18:10 quanjielin

I think you're using a enovy (or istio proxy) that doesn't contain #4395, the proto built into it doesn't contain local_credentials so you see numbers in:

              channel_credentials {
                3: ""
              }

lizan avatar Oct 01 '18 20:10 lizan

thanks Lizan, I used latest istio master with proxy sha f49833732cab7e6f249760d1ec9d3ec19d19fe2c, points to envoy SHA f49833732cab7e6f249760d1ec9d3ec19d19fe2c without that PR, will try to update and try.

quanjielin avatar Oct 01 '18 21:10 quanjielin