Reducing API Requests for Cloud Run Services via Anthos Config Management

89 Views Asked by At

I am currently provisioning GCP Cloud Run services using the Anthos Config Management. I have noticed in the logs that there are three attempts per second to retrieve service information from the Cloud Run API (Cloud RunGetService). The principal associated with these requests is the account linked to the Config Connector.

I have encountered quota limit errors on several occasions due to the high frequency of these requests. I am curious about the reasons behind these multiple attempts and would like to know if there is a way to reduce the number of requests to the API.

Your assistance and guidance on this matter would be greatly appreciated.

Summary:

2023-04-07T09:29:53.637281Z - google.cloud.run.v2.Services.GetService
2023-04-07T09:29:53.544169Z - google.cloud.run.v2.Services.GetService
2023-04-07T09:29:52.487437Z - google.cloud.run.v2.Services.GetService
2023-04-07T09:29:51.521130Z - google.cloud.run.v2.Services.GetService
2023-04-07T09:29:51.482940Z - google.cloud.run.v2.Services.GetService
2023-04-07T09:29:51.440035Z - google.cloud.run.v2.Services.GetService
[
  {
    "insertId": "6o7xwnd1apc",
    "logName": "projects/projectId/logs/cloudaudit.googleapis.com%2Fdata_access",
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "authenticationInfo": {
        "principalEmail": "anthos-config-managment-service-account",
        "principalSubject": "serviceAccount:anthos-config-managment-service-account"
      },
      "authorizationInfo": [
        {
          "granted": true,
          "permission": "run.services.get",
          "resource": "projects/projectId/locations/region/services/serviceName",
          "resourceAttributes": {}
        }
      ],
      "methodName": "google.cloud.run.v2.Services.GetService",
      "requestMetadata": {
        "callerIp": "10.156.0.8",
        "callerNetwork": "//compute.googleapis.com/projects/projectId/global/networks/__unknown__",
        "callerSuppliedUserAgent": "kcc/controller-manager blueprints/kpt-pkg-fn-live DeclarativeClientLib/0.0.1,gzip(gfe),gzip(gfe)",
        "destinationAttributes": {},
        "requestAttributes": {
          "auth": {},
          "time": "2023-04-07T09:29:53.658779Z"
        }
      },
      "resourceLocation": {
        "currentLocations": ["region"]
      },
      "resourceName": "projects/projectId/locations/region/services/serviceName",
      "serviceName": "run.googleapis.com"
    },
    "receiveTimestamp": "2023-04-07T09:29:54.442225196Z",
    "resource": {
      "labels": {
        "configuration_name": "",
        "location": "region",
        "project_id": "projectId",
        "revision_name": "",
        "service_name": "serviceName"
      },
      "type": "cloud_run_revision"
    },
    "severity": "INFO",
    "timestamp": "2023-04-07T09:29:53.637281Z"
  },
  {
    "insertId": "y4uoutd1cbh",
    "logName": "projects/projectId/logs/cloudaudit.googleapis.com%2Fdata_access",
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "authenticationInfo": {
        "principalEmail": "anthos-config-managment-service-account",
        "principalSubject": "serviceAccount:anthos-config-managment-service-account"
      },
      "authorizationInfo": [
        {
          "granted": true,
          "permission": "run.services.get",
          "resource": "projects/projectId/locations/region/services/serviceName",
          "resourceAttributes": {}
        }
      ],
      "methodName": "google.cloud.run.v2.Services.GetService",
      "requestMetadata": {
        "callerIp": "10.156.0.8",
        "callerNetwork": "//compute.googleapis.com/projects/projectId/global/networks/__unknown__",
        "callerSuppliedUserAgent": "kcc/controller-manager blueprints/kpt-pkg-fn-live DeclarativeClientLib/0.0.1,gzip(gfe),gzip(gfe)",
        "destinationAttributes": {},
        "requestAttributes": {
          "auth": {},
          "time": "2023-04-07T09:29:53.561641Z"
        }
      },
      "resourceLocation": {
        "currentLocations": ["region"]
      },
      "resourceName": "projects/projectId/locations/region/services/serviceName",
      "serviceName": "run.googleapis.com"
    },
    "receiveTimestamp": "2023-04-07T09:29:54.124104694Z",
    "resource": {
      "labels": {
        "configuration_name": "",
        "location": "region",
        "project_id": "projectId",
        "revision_name": "",
        "service_name": "serviceName"
      },
      "type": "cloud_run_revision"
    },
    "severity": "INFO",
    "timestamp": "2023-04-07T09:29:53.544169Z"
  },
  {
    "insertId": "170bquhc1db",
    "logName": "projects/projectId/logs/cloudaudit.googleapis.com%2Fdata_access",
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "authenticationInfo": {
        "principalEmail": "anthos-config-managment-service-account",
        "principalSubject": "serviceAccount:anthos-config-managment-service-account"
      },
      "authorizationInfo": [
        {
          "granted": true,
          "permission": "run.services.get",
          "resource": "projects/projectId/locations/region/services/serviceName",
          "resourceAttributes": {}
        }
      ],
      "methodName": "google.cloud.run.v2.Services.GetService",
      "requestMetadata": {
        "callerIp": "10.156.0.8",
        "callerNetwork": "//compute.googleapis.com/projects/projectId/global/networks/__unknown__",
        "callerSuppliedUserAgent": "kcc/controller-manager blueprints/kpt-pkg-fn-live DeclarativeClientLib/0.0.1,gzip(gfe),gzip(gfe)",
        "destinationAttributes": {},
        "requestAttributes": {
          "auth": {},
          "time": "2023-04-07T09:29:52.504497Z"
        }
      },
      "resourceLocation": {
        "currentLocations": ["region"]
      },
      "resourceName": "projects/projectId/locations/region/services/serviceName",
      "serviceName": "run.googleapis.com"
    },
    "receiveTimestamp": "2023-04-07T09:29:53.491235721Z",
    "resource": {
      "labels": {
        "configuration_name": "",
        "location": "region",
        "project_id": "projectId",
        "revision_name": "",
        "service_name": "serviceName"
      },
      "type": "cloud_run_revision"
    },
    "severity": "INFO",
    "timestamp": "2023-04-07T09:29:52.487437Z"
  }]
0

There are 0 best solutions below