Skip to content

Emit GKE PDCSI component version metric #719

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

Merged

Conversation

saikat-royc
Copy link
Member

@saikat-royc saikat-royc commented Feb 25, 2021

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This PR enables the gce-pd-driver container to emit 'component_version' metric. This metric will be emitted only by the controller driver gce-pd-driver container, when the env GKE_PDCSI_VERSION is setup in the driver manifest.
In GKE the env variable would be populated from metadata annotations (which is automatically populated for GKE pod). This metric will enable GroupBy queries on PDCSI component version

- name: GKE_PDCSI_VERSION
      valueFrom:
        fieldRef:
          # Component version annotation is populated by renderer
          fieldPath: metadata.annotations['components.gke.io/component-version']

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
Tested locally as follows:

  1. deploy the driver (with a --http-endpoint=:22015 and env: -name:GKE_PDCSI_VERSION value: )
    sample patch:
@@ -138,9 +138,12 @@ spec:
          args:
            - "--v=5"
            - "--endpoint=unix:/csi/csi.sock"
+            - "--http-endpoint=:22015"
          env:
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: "/etc/cloud-sa/cloud-sa.json"
+            - name: GKE_PDCSI_VERSION
+              value: "0.9.4"
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
  1. ssh into the node where the controller is running
  2. curl to the http endpoint as follows and check the metric emitted:
saikatroyc@e2e-test-saikatroyc-minion-group-s7lb ~ $ curl http://localhost:22015/metrics
# HELP component_version [ALPHA] Metric to expose the version of the PDCSI GKE component.
# TYPE component_version gauge
component_version{component_version="0.9.4"} 1

Does this PR introduce a user-facing change?:

Emit GKE component version metric 

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 25, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: saikat-royc

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 25, 2021
@saikat-royc
Copy link
Member Author

/assign @verult @mattcary

@saikat-royc saikat-royc force-pushed the component_version_metric branch from 26c0e8b to 43b5384 Compare February 25, 2021 09:17
@saikat-royc saikat-royc changed the title Add new metric to expose GKE component version Emit GKE component version metric Feb 25, 2021
@saikat-royc saikat-royc changed the title Emit GKE component version metric Emit GKE PDCSI component version metric Feb 25, 2021
@saikat-royc
Copy link
Member Author

/retest

@Jiawei0227
Copy link
Contributor

Can I ask what is benefit of adding this version through metrics? I think we have other ways to get the component version number through GKE

@Jiawei0227
Copy link
Contributor

I remember in GKE we have add_on_* something and that will contain the component versions.

@mattcary
Copy link
Contributor

I remember in GKE we have add_on_* something and that will contain the component versions.

GKE is moving to a different component release pipeline which changes how versions are exported.

@saikat-royc saikat-royc force-pushed the component_version_metric branch from 43b5384 to e4c88e3 Compare February 25, 2021 22:43

// InitializeHttpHandler sets up a server and creates a handler for metrics.
func (mm *metricsManager) InitializeHttpHandler(address, path string) {
mux := http.NewServeMux()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note that a mux is only necessary if there are multiple handlers, so here either this or the previous version of this code would work

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping mux for future proofing?

@saikat-royc saikat-royc force-pushed the component_version_metric branch from e4c88e3 to 6c7d43b Compare February 26, 2021 02:49
@saikat-royc
Copy link
Member Author

/retest

@Jiawei0227
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2021
@k8s-ci-robot k8s-ci-robot merged commit 0295284 into kubernetes-sigs:master Mar 1, 2021
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants