quota_project_id not propagated
See original GitHub issueWhat version of gRPC-Java are you using?
24.0.0
What is your environment?
jdk17
What did you expect to see?
A call being made with header x-goog-user-project
header when service account has quota_project_id
set so that calls are properly counted against chosen quota.
What did you see instead?
No header set.
Steps to reproduce the bug
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.monitoring.v3.MetricServiceClient;
import com.google.cloud.monitoring.v3.MetricServiceSettings;
import com.google.monitoring.v3.ListMetricDescriptorsRequest;
class GcpSample {
public static void main(String[] args) throws IOException {
// content of the service account key in json format with quota_project_id field set
String serviceKey="[SERVICE_ACCOUNT_KEY_IN_JSON_FORMAT]";
String projectId="[YOUR_PROJECT_NAME]";
InputStream tokenStream = new ByteArrayInputStream(serviceKey.getBytes(StandardCharsets.UTF_8));
GoogleCredentials creds = GoogleCredentials.fromStream(tokenStream);
MetricServiceSettings.Builder builder = MetricServiceSettings.newBuilder();
builder.setCredentialsProvider(FixedCredentialsProvider.create(creds));
MetricServiceClient stackDriverClient = MetricServiceClient.create(builder.build());
ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
.setName("projects/" + projectId)
.setFilter("metric.type=\"compute.googleapis.com/instance/cpu/utilization\"")
.build();
stackDriverClient.listMetricDescriptors(request);
}
}
After some debugging I found out that at some point ServiceAccountCredentials
will be converted to ServiceAccountJwtAccessCredentials
and it loses the quota_project_id
during that conversion. Conversion is done in GoogleAuthLibraryCallCredentials#JwtHelper and the field is just not set.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How does the UI calculate the resource quota set for ... - GitHub
Updating an existing namespace default limit for a quota at the project level will not result in that value being propagated to existing ......
Read more >gcloud auth application-default set-quota-project
API-first integration to connect existing data and applications. ... Solution to bridge existing care systems and apps on Google Cloud. ... No-code development ......
Read more >How Resource Quotas Work in Rancher Projects
In Rancher, you apply a resource quota to the project, and then the quota propagates to each namespace, whereafter Kubernetes enforces your ...
Read more >Plan Error: Cloud Resource Manager API has not been used
json introduced by command the login cmd. try to remove "quota project id" from the application_default_credentials.json and instead do. gcloud ...
Read more >Quotas and Limit Ranges | OpenShift Container Platform 3.11
Quotas. A resource quota, defined by a ResourceQuota object, provides constraints that limit aggregate resource consumption per project. It can limit the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This was released in 1.49.0.
@ejona86 Could you let me know when this is released?