Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge mixer template. Stackdriver Adapter: Add support to write to Context Graph #6709

Merged
merged 14 commits into from
Jun 30, 2018

Conversation

jeffmendoza
Copy link
Contributor

This includes #6408, so I'll close that one.

Add Mixer template for edge instances. These can be used by adapters to construct graphs of the Istio mesh.

Add support to Stackdriver adapter to write to the Stackdriver Context Graph API.

The Context Graph client is not available upstream yet. So vendor it inside the Stackdriver adapter until it is available.

jeffmendoza and others added 10 commits June 27, 2018 14:19
This client is not available upstream yet.
Build edges and entities from workload instance assertions
Update edge template to have UIDs
Replace traffic cache with edge cache
Send from the new caches
Send all entities and edges in a batch with the same timestamp
Make it build
Use generic path to service account
Fix epochs
Move context API dependencies into a local vendor directory
Propagate endpoint setting from config
Fix identification of kubernetes owners and workload instances
Moved contextgraph adapter to be a part of stackdriver.
Move vendored contextgraph client
Fix Gopkg.toml
Update testconfig
Temp comment out stackdriver trace code, causing panic.
Update local test yaml
Fix two errors on determining k8s entities from owner/WI names
Don't escape project names
Add tests for workloadInstance
Only print details if they exist
Remove retry, so invalid entities and edges are not continually
 reasserted
Use a 30 second timeout on AssertBatch calls, and plumb through
 context in function parameters
@jeffmendoza jeffmendoza requested review from douglas-reid and removed request for sdake, linsun and geeknoid June 28, 2018 18:39
@jeffmendoza jeffmendoza requested a review from bianpengyuan June 28, 2018 18:40
Copy link
Contributor

@douglas-reid douglas-reid left a comment

Choose a reason for hiding this comment

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

mostly nits


// entityCache tracks the entities we've already seen.
// It is not thread-safe.
type entityCache struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

i assume that pkg/cache was insufficient for this purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@quentinmit Can you take a look? Thanks


// edgeCache tracks the edges we've already seen.
// It is not thread-safe.
type edgeCache struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

these (edgeCache and entityCache) look identical. Is there no way to refactor the code so as we don't have identical Flush and AssertAndCheck methods?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not until generics land in Go 2 ;)

}
}

type mockLogger struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use mixer/pkg/adapter/test/env.go instead?

or, at the very least, embed adapter.logger in the struct and only implement the needed methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, let me try this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}
case t := <-h.sendTick.C:
if t.After(lastFlush.Add(9 * time.Minute)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this (9 * time.Minute) be configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is a detail of the ContextGraph API, and wouldn't be good for the user to configure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Context API requires a refresh every 10m. This is something clients are just supposed to hardcode.

traffics: make(chan trafficAssertion),
entitiesToSend: make([]entity, 0),
edgesToSend: make([]edge, 0),
sendTick: time.NewTicker(30 * time.Second),
Copy link
Contributor

Choose a reason for hiding this comment

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

should 30s be a const, and/or configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it should be user configurable, but maybe. The ContextGraph API has a very low quota, and expects us to batch up asserts.

gax "github.com/googleapis/gax-go"

"google.golang.org/api/option"
contextgraphpb "google.golang.org/genproto/googleapis/cloud/contextgraph/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: we should separate out the istio imports section from the third-party. these two lines belong with the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov
Copy link

codecov bot commented Jun 28, 2018

Codecov Report

Merging #6709 into master will decrease coverage by 1%.
The diff coverage is 82%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #6709    +/-   ##
=======================================
- Coverage      71%     70%   -<1%     
=======================================
  Files         354     355     +1     
  Lines       30711   30610   -101     
=======================================
- Hits        21579   21406   -173     
- Misses       8284    8344    +60     
- Partials      848     860    +12
Impacted Files Coverage Δ
mixer/adapter/stackdriver/log/log.go 69% <0%> (ø) ⬆️
mixer/adapter/stackdriver/metric/metric.go 87% <0%> (ø) ⬆️
mixer/adapter/stackdriver/contextgraph/cache.go 100% <100%> (ø)
mixer/adapter/stackdriver/helper/common.go 84% <100%> (ø) ⬆️
mixer/adapter/stackdriver/trace/trace.go 89% <100%> (ø) ⬇️
mixer/adapter/stackdriver/stackdriver.go 50% <55%> (+1%) ⬆️
mixer/adapter/stackdriver/contextgraph/workload.go 76% <76%> (ø)
...r/adapter/stackdriver/contextgraph/contextgraph.go 83% <83%> (ø)
mixer/adapter/stackdriver/contextgraph/send.go 84% <84%> (ø)
...olarwinds/internal/papertrail/papertrail_logger.go 62% <0%> (-18%) ⬇️
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce70b47...f990f0f. Read the comment docs.

@douglas-reid
Copy link
Contributor

We need this PR in ASAP to make the 1.0 release cut. We can make small adjustments to the code moving forward, but I see no major blockers in my review.

/lgtm
/approve
/retest

@jeffmendoza
Copy link
Contributor Author

@douglas-reid Yay, all tests pass.

@douglas-reid
Copy link
Contributor

/lgtm

@istio-testing
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jeffmendoza
Copy link
Contributor Author

/test istio-presubmit

@jeffmendoza
Copy link
Contributor Author

Docker Hub!!

 error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/21/219e59ae4605f1a61d4f33dbc6dc46f170a8be109b3ba59cba317b7633a87b9b/data?verify=1530379542-2YTxCF70uquWqfVJSgIQqGuQg98%3D: dial tcp: lookup production.cloudflare.docker.com on 10.47.240.10:53: server misbehaving

@istio-testing istio-testing merged commit 0ccdef4 into istio:master Jun 30, 2018
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.

5 participants