Skip to content

Relax the requirement for stackdriver project id for metrics exporter. - #147

Merged
knative-prow-robot merged 7 commits into
knative:masterfrom
akyyy:relaxsdproject
Oct 30, 2018
Merged

knative-prow-robot merged 7 commits into
knative:masterfrom
akyyy:relaxsdproject

Conversation

@akyyy

@akyyy akyyy commented Oct 29, 2018

Copy link
Copy Markdown
Contributor

When metrics.stackdriver-project-id is not provided and the deployment is in GKE, there is application default credentials for the stackdriver exporter.

This is to address @mattmoor 's comment in knative/serving#2337

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 29, 2018
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2018
@akyyy

akyyy commented Oct 29, 2018

Copy link
Copy Markdown
Contributor Author

/assign @mattmoor @mdemirhan

Comment thread metrics/config.go Outdated
if !ok || sdProj == "" {
return nil, errors.New("For backend stackdriver, metrics.stackdriver-project-id field must exist and cannot be empty")
if ok && sdProj != "" {
mc.stackdriverProjectID = sdProj

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.

When this is left empty, do OpenCensus pick the current GKE project as the SD project id?

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.

The question is my mind is: how discoverable would that be for users?

Noting that metadata.ProjectID() returns an optional error (e.g. not running on GCE), I would contend that we should explicitly use it here and surface the error (rejecting the configmap update).

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.

@mdemirhan yes, OpenCensus is able to use the current GCP project as the SD project ID in my testing.

@mattmoor If OpenCensus is not able to use the default account, it'll return an error when creating a metrics exporter:
errors.New("stackdriver: no project found with application default credentials")"
Is this sufficient?

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 error would surface here?

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.

Yes.

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.

Maybe add a comment for what will happen in case stackdriverProjectIDKey is not provided and OpenCensus is not able to use the default account.

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.

Added a comment

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2018
@akyyy

akyyy commented Oct 30, 2018

Copy link
Copy Markdown
Contributor Author

Gentle ping. Could you please take a look when you get a chance? After this pr is in, I can update knative/serving#2337.

Comment thread metrics/config.go Outdated
sdProj, ok := m[stackdriverProjectIDKey]
if !ok || sdProj == "" {
return nil, errors.New("For backend stackdriver, metrics.stackdriver-project-id field must exist and cannot be empty")
if ok && sdProj != "" {

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 could simply do:

mc.stackdriverProjectID = m[stackdriverProjectIDKey]

If the project doesnt exist, map will return "" anyway.

@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-pkg-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
metrics/config.go 92.1% 91.4% -0.7

@mdemirhan

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2018
@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akyyy, mdemirhan

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

The pull request process is described here

Details 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2018
@knative-prow-robot
knative-prow-robot merged commit 02b354e into knative:master Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants