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

Prow: Set proper user-agent in config #21067

Merged
merged 1 commit into from
Feb 28, 2021

Conversation

alvaroaleman
Copy link
Member

The default user-agentis $0/$version, which is pretty useless because it
always ends up being app.binary/$version. This PR changes that instead
be the components name which is useful for:

  • Audit log: We can now both use the user-agent or SA to identify
    components
  • ManagedFields: Managed fields now have the correct fieldOwner set

This allows for example the use of kubectl-blame:

$ k blame prowjob ebb68c01-792b-11eb-a360-96cd908b0bc6
                                              apiVersion: prow.k8s.io/v1
                                              kind: ProwJob
                                              metadata:
horologium (Update 2021-02-27 13:45:11 -0500)   annotations:
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/job: echo-test
                                                creationTimestamp: "2021-02-27T18:45:11Z"
                                                generation: 4
horologium (Update 2021-02-27 13:45:11 -0500)   labels:
horologium (Update 2021-02-27 13:45:11 -0500)     created-by-prow: "true"
app.binary (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/build-id: "1365734741038338048"
app.binary (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/id: ebb68c01-792b-11eb-a360-96cd908b0bc6
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/job: echo-test
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/type: periodic
                                                name: ebb68c01-792b-11eb-a360-96cd908b0bc6
                                                namespace: prow
                                                resourceVersion: "144661945"
                                                uid: 63f44066-411e-4ff3-9ab4-97ddb2ce636d
horologium (Update 2021-02-27 13:45:11 -0500) spec:
horologium (Update 2021-02-27 13:45:11 -0500)   agent: kubernetes
horologium (Update 2021-02-27 13:45:11 -0500)   cluster: default
horologium (Update 2021-02-27 13:45:11 -0500)   decoration_config:
horologium (Update 2021-02-27 13:45:11 -0500)     gcs_configuration:
horologium (Update 2021-02-27 13:45:11 -0500)       bucket: s3://prow-logs
horologium (Update 2021-02-27 13:45:11 -0500)       path_strategy: explicit
horologium (Update 2021-02-27 13:45:11 -0500)     s3_credentials_secret: s3-credentials
horologium (Update 2021-02-27 13:45:11 -0500)     utility_images:
horologium (Update 2021-02-27 13:45:11 -0500)       clonerefs: gcr.io/k8s-prow/clonerefs:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       entrypoint: gcr.io/k8s-prow/entrypoint:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       initupload: gcr.io/k8s-prow/initupload:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       sidecar: gcr.io/k8s-prow/sidecar:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)   job: echo-test
horologium (Update 2021-02-27 13:45:11 -0500)   namespace: test-pods
horologium (Update 2021-02-27 13:45:11 -0500)   pod_spec:
horologium (Update 2021-02-27 13:45:11 -0500)     containers:
horologium (Update 2021-02-27 13:45:11 -0500)     - command:
horologium (Update 2021-02-27 13:45:11 -0500)       - /bin/sleep
horologium (Update 2021-02-27 13:45:11 -0500)       - 1m
horologium (Update 2021-02-27 13:45:11 -0500)       image: alpine
horologium (Update 2021-02-27 13:45:11 -0500)       name: ""
horologium (Update 2021-02-27 13:45:11 -0500)       resources: {}
horologium (Update 2021-02-27 13:45:11 -0500)   report: true
horologium (Update 2021-02-27 13:45:11 -0500)   type: periodic
horologium (Update 2021-02-27 13:45:11 -0500) status:
app.binary (Update 2021-02-27 13:45:11 -0500)   build_id: "1365734741038338048"
app.binary (Update 2021-02-27 13:45:11 -0500)   description: Job triggered.
app.binary (Update 2021-02-27 13:45:11 -0500)   pendingTime: "2021-02-27T18:45:11Z"
app.binary (Update 2021-02-27 13:45:11 -0500)   pod_name: ebb68c01-792b-11eb-a360-96cd908b0bc6
app.binary (Update 2021-02-27 13:45:11 -0500)   prev_report_states:
app.binary (Update 2021-02-27 13:45:11 -0500)     gcsk8sreporter: pending
app.binary (Update 2021-02-27 13:45:11 -0500)     gcsreporter: pending
horologium (Update 2021-02-27 13:45:11 -0500)   startTime: "2021-02-27T18:45:11Z"
app.binary (Update 2021-02-27 13:45:11 -0500)   state: pending
app.binary (Update 2021-02-27 13:45:11 -0500)   url: https://prow.tld/view/s3/s3/prow-logs/logs/echo-test/1365734741038338048

Note: Due to a bug in controller-runtime, this doesn't work for a client
that comes from a Manager that has leader election enabled, like planks
prowjob client above: kubernetes-sigs/controller-runtime#1401
I will bump the dependency ASAP once the upstream fix is in.

The default user-agentis $0/$version, which is pretty useless because it
always ends up being app.binary/$version. This PR changes that instead
be the components name which is useful for:
* Audit log: We can now both use the user-agent or SA to identify
  components
* ManagedFields: Managed fields now have the correct fieldOwner set

This allows for example the use of `kubectl-blame`:
```
$ k blame prowjob ebb68c01-792b-11eb-a360-96cd908b0bc6
                                              apiVersion: prow.k8s.io/v1
                                              kind: ProwJob
                                              metadata:
horologium (Update 2021-02-27 13:45:11 -0500)   annotations:
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/job: echo-test
                                                creationTimestamp: "2021-02-27T18:45:11Z"
                                                generation: 4
horologium (Update 2021-02-27 13:45:11 -0500)   labels:
horologium (Update 2021-02-27 13:45:11 -0500)     created-by-prow: "true"
app.binary (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/build-id: "1365734741038338048"
app.binary (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/id: ebb68c01-792b-11eb-a360-96cd908b0bc6
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/job: echo-test
horologium (Update 2021-02-27 13:45:11 -0500)     prow.k8s.io/type: periodic
                                                name: ebb68c01-792b-11eb-a360-96cd908b0bc6
                                                namespace: prow
                                                resourceVersion: "144661945"
                                                uid: 63f44066-411e-4ff3-9ab4-97ddb2ce636d
horologium (Update 2021-02-27 13:45:11 -0500) spec:
horologium (Update 2021-02-27 13:45:11 -0500)   agent: kubernetes
horologium (Update 2021-02-27 13:45:11 -0500)   cluster: default
horologium (Update 2021-02-27 13:45:11 -0500)   decoration_config:
horologium (Update 2021-02-27 13:45:11 -0500)     gcs_configuration:
horologium (Update 2021-02-27 13:45:11 -0500)       bucket: s3://prow-logs
horologium (Update 2021-02-27 13:45:11 -0500)       path_strategy: explicit
horologium (Update 2021-02-27 13:45:11 -0500)     s3_credentials_secret: s3-credentials
horologium (Update 2021-02-27 13:45:11 -0500)     utility_images:
horologium (Update 2021-02-27 13:45:11 -0500)       clonerefs: gcr.io/k8s-prow/clonerefs:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       entrypoint: gcr.io/k8s-prow/entrypoint:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       initupload: gcr.io/k8s-prow/initupload:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)       sidecar: gcr.io/k8s-prow/sidecar:v20200608-16190316cf
horologium (Update 2021-02-27 13:45:11 -0500)   job: echo-test
horologium (Update 2021-02-27 13:45:11 -0500)   namespace: test-pods
horologium (Update 2021-02-27 13:45:11 -0500)   pod_spec:
horologium (Update 2021-02-27 13:45:11 -0500)     containers:
horologium (Update 2021-02-27 13:45:11 -0500)     - command:
horologium (Update 2021-02-27 13:45:11 -0500)       - /bin/sleep
horologium (Update 2021-02-27 13:45:11 -0500)       - 1m
horologium (Update 2021-02-27 13:45:11 -0500)       image: alpine
horologium (Update 2021-02-27 13:45:11 -0500)       name: ""
horologium (Update 2021-02-27 13:45:11 -0500)       resources: {}
horologium (Update 2021-02-27 13:45:11 -0500)   report: true
horologium (Update 2021-02-27 13:45:11 -0500)   type: periodic
horologium (Update 2021-02-27 13:45:11 -0500) status:
app.binary (Update 2021-02-27 13:45:11 -0500)   build_id: "1365734741038338048"
app.binary (Update 2021-02-27 13:45:11 -0500)   description: Job triggered.
app.binary (Update 2021-02-27 13:45:11 -0500)   pendingTime: "2021-02-27T18:45:11Z"
app.binary (Update 2021-02-27 13:45:11 -0500)   pod_name: ebb68c01-792b-11eb-a360-96cd908b0bc6
app.binary (Update 2021-02-27 13:45:11 -0500)   prev_report_states:
app.binary (Update 2021-02-27 13:45:11 -0500)     gcsk8sreporter: pending
app.binary (Update 2021-02-27 13:45:11 -0500)     gcsreporter: pending
horologium (Update 2021-02-27 13:45:11 -0500)   startTime: "2021-02-27T18:45:11Z"
app.binary (Update 2021-02-27 13:45:11 -0500)   state: pending
app.binary (Update 2021-02-27 13:45:11 -0500)   url: https://prow.tld/view/s3/s3/prow-logs/logs/echo-test/1365734741038338048
```

Note: Due to a bug in controller-runtime, this doesn't work for a client
that comes from a Manager that has leader election enabled, like planks
prowjob client above: kubernetes-sigs/controller-runtime#1401
I will bump the dependency ASAP once the upstream fix is in.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 27, 2021
@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Feb 27, 2021
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

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

Neat, TIL about kubectl blame.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, cjwagner

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 merged commit 1383067 into kubernetes:master Feb 28, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 28, 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. area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants