Skip to content

Added quota contoll without the service control client library#92

Closed
mangchiandjjoe wants to merge 13 commits intoistio:rate_limitingfrom
mangchiandjjoe:master
Closed

Added quota contoll without the service control client library#92
mangchiandjjoe wants to merge 13 commits intoistio:rate_limitingfrom
mangchiandjjoe:master

Conversation

@mangchiandjjoe
Copy link
Copy Markdown
Contributor

@googlebot
Copy link
Copy Markdown
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@istio-testing
Copy link
Copy Markdown
Collaborator

Running presubmits at https://istio-testing.appspot.com/job/proxy/job/presubmit/56/ ...

@istio-testing
Copy link
Copy Markdown
Collaborator

proxy/presubmit failed. Details at https://istio-testing.appspot.com/job/proxy/job/presubmit/56/.

@istio-testing
Copy link
Copy Markdown
Collaborator

Running presubmits at https://istio-testing.appspot.com/job/proxy/job/presubmit/57/ ...

@istio-testing
Copy link
Copy Markdown
Collaborator

proxy/presubmit failed. Details at https://istio-testing.appspot.com/job/proxy/job/presubmit/57/.

@istio-testing
Copy link
Copy Markdown
Collaborator

Running presubmits at https://istio-testing.appspot.com/job/proxy/job/presubmit/58/ ...

@istio-testing
Copy link
Copy Markdown
Collaborator

proxy/presubmit failed. Details at https://istio-testing.appspot.com/job/proxy/job/presubmit/58/.

@sebastienvas
Copy link
Copy Markdown
Contributor

Please run script/check-style, this is why Jenkins is failing:

script/check-style: line 26: /home/jenkins/clang/bin/clang-format: No such file or directory
Installing required clang-format 3.8.0 to /home/jenkins/clang
Checking file format ...
Files not formatted: contrib/endpoints/src/api_manager/proto/server_config.proto contrib/endpoints/src/api_manager/service_control/aggregated.cc

@mangchiandjjoe
Copy link
Copy Markdown
Contributor Author

Thanks. I just ran the tool.

@istio-testing
Copy link
Copy Markdown
Collaborator

Running presubmits at https://istio-testing.appspot.com/job/proxy/job/presubmit/59/ ...

@istio-testing
Copy link
Copy Markdown
Collaborator

proxy/presubmit failed. Details at https://istio-testing.appspot.com/job/proxy/job/presubmit/59/.

@@ -37,7 +37,8 @@ typedef std::shared_ptr<HttpRequestData> HttpRequestDataPtr;
class HttpControl final : public Logger::Loggable<Logger::Id::http> {
public:
// The constructor.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two changes should not be here

  1. you need to base your change to istio/proxy:rate_limting branch. It seems that you are based on master branch.
  2. or you need to sync rate_limiting branch to master

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I will do that.
let me close this PR and I will create a new one.

Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new PR after I re-base the repo

Please review the new one #93

return;
}

if (context->api_key().empty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to call quota for all requests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the paragraph


sa_token_quota_ = new auth::ServiceAccountToken(env);
sa_token_quota_->SetClientAuthSecret(
server_config->google_authentication_secret());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should NOT get token from server_file. You could define a new type
JWT_TOKEN_FOR_QUOTA_CONTROL, and set it audience. then you can get its token.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied

// Generate QuotaAggregationOptions
QuotaAggregationOptions GetQuotaAggregationOptions(
const ServerConfig* server_config,
const ::google::api::Service* service_config) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see service_config is used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the argument

delete response;
};

AllocateQuotaRequest* quota_request_copy = new AllocateQuotaRequest(*request);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this copy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

// TODO(jaebong) Temporarily call Chemist directly instead of using service
// control client library
Call(*request, response,
[this, quota_request_copy, response,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pass in check_on_done as 3rd argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

if (status.ok()) {
utils::Status status = Proto::ConvertAllocateQuotaResponse(
*response, service_control_proto_.service_name());
on_done(utils::Status::OK);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with converted status.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding the issue


auto check_on_done = [this, response, on_done, trace_span](
const ::google::protobuf::util::Status& status) {
if (status.ok()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace_span is not used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused captures

const std::string& url = typeid(RequestType) == typeid(CheckRequest)
? url_.check_url()
: url_.report_url();
const std::string& url =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a separate template function get_url() for this code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created

template
const std::string& Aggregated::GetApiReqeustUrl(const RequestType& request)

http_request->set_timeout_ms(config.quota_timeout_ms());
}
} else {
if (config.report_timeout_ms() > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider move all these time_out code into a separate function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created

template
void Aggregated::SetHttpRequestTimeout(
const RequestType& request, std::unique_ptr& http_request);

info->labels["servicecontrol.googleapis.com/caller_ip"] =
request_->GetClientIP();
info->labels["servicecontrol.googleapis.com/referer"] = this->http_referer_;
info->labels["servicecontrol.googleapis.com/user"] = "integration_test_user";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see info->labels get used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was moved to Proto::FillAllocateQuotaRequest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

jaellio added a commit that referenced this pull request Sep 19, 2024
Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
dcillera pushed a commit to dcillera/proxy-1 that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants