Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Add overrides to memquota2#1256

Merged
mandarjog merged 4 commits intoistio:masterfrom
mandarjog:quota2
Sep 11, 2017
Merged

Add overrides to memquota2#1256
mandarjog merged 4 commits intoistio:masterfrom
mandarjog:quota2

Conversation

@mandarjog
Copy link
Copy Markdown
Contributor

@mandarjog mandarjog commented Sep 10, 2017

This PR adds override support to memquota2 as back end configuration with the intention of migrating then to individual config resources in 0.3

It gains feature parity with the old memquota setup + old config model.
This lets Mixer switch off old quota dispatch after creating replacement test configurations.

Release note:

NONE

This change is Reviewable

@mandarjog
Copy link
Copy Markdown
Contributor Author

Added istio/istio PR


message Params {
message Quota {
option (gogoproto.goproto_getters) = true;
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.

Need getters so we can abstract over Quota and Override message.
They both implement

interface {
 GetValidDuration()
  GetMaxAmount()
}


if qu.Logger.VerbosityLevel(4) {
if len(t) > 0 && qu.Logger.VerbosityLevel(4) {
qu.Logger.Infof("Running repear to reclaim %d old deduplication entries", len(t))
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.

let's also fix: "repear" -> "reaper"

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.

How do we keep ending up with this change being removed? This is at least the third time.

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 PR can now remove the entire adapter, but I will send a separate PR for that.

// matchDimensions matches configured dimensions with dimensions of the instance.
func matchDimensions(cfg map[string]string, inst map[string]interface{}) bool {
for k, val := range cfg {
rval := inst[k]
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.

so, this requires the dimensions to be in the same order as well, right?

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.

This is a map lookup - it shouldn't impose ordering constraints, right?

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.

Not really. we are checking all dimensions specified in adapterConfig. They can appear in any order.

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.

ah, ok. i was looking too quickly while trying to participate in that meeting.

func limit(cfg *config.Params_Quota, instance *quota.Instance) Limit {
for idx := range cfg.Overrides {
o := cfg.Overrides[idx]
if matchDimensions(o.Dimensions, instance.Dimensions) {
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.

don't the MakeKey() methods provide a set of functionality we could use instead of matchDimensions? Is there a reason not to use the existing Key funcs?

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.

MakeKey() creates a unique key using all dimensions.
matchDimensions needs to match on partial dimensions.

}
}

if glog.V(2) {
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.

do we want this section of code? Doesn't this imply dimensions that might not be on the quota descriptor? For instance, I might not choose to dimension quota with source.name.

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.

regardless of quota dimensioning, I want accessLog to convey just some reasonable notion of source and target, how much quota was requested and how much was granted.

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.

+1, I don't like this chunk. If we want this kind of logging, just log "allocated %d tokens along dimensions: %v". Don't hard code attributes anywhere.

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 just log destination.service along with quota response now.

I also log full dimensions at log level 2.

if inst.Name != qma.Quota {
continue
}
// if inst.Name != qma.Quota {
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.

what is the harm in leaving this check enabled?

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.

It will not work. The qma.Name == RequestCount, however instance names in config are fully qualified. So mixer client will have to send the specific fully qualified name over.

@@ -17,7 +23,7 @@ metadata:
spec:
dimensions:
source: source.labels["app"] | "unknown"
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 the raw vm work, i'm wondering if we should switch from labels to source.service (at least for 0.2).

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.

how about source.labels["app"] | source.service

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.

how about source.labels["app"] | source.service | "unknown" to cover all bases?

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.

done.

@douglas-reid
Copy link
Copy Markdown
Contributor

/lgtm

@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: douglas-reid

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@mandarjog mandarjog merged commit 36994fb into istio:master Sep 11, 2017
rvkubiak pushed a commit to rvkubiak/mixer that referenced this pull request Oct 10, 2017
* Add overrides to memquota2

* change access log, reduce logs

* remove adapter/kubernetes/kubeconfig added my mistake

* make linter happy
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants