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

ci-k8sio-audit periodic job #20742

Merged
merged 2 commits into from
Feb 11, 2021
Merged

ci-k8sio-audit periodic job #20742

merged 2 commits into from
Feb 11, 2021

Conversation

hh
Copy link
Member

@hh hh commented Feb 4, 2021

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Feb 4, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 4, 2021
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 4, 2021
@hh hh changed the title ci-k8sio-audit perodic job / fixes #244 WIP: ci-k8sio-audit perodic job / fixes #244 Feb 4, 2021
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 4, 2021
@hh
Copy link
Member Author

hh commented Feb 4, 2021

I’m trying to use ./config/pj-on-kind.sh to verify a job that needs to use gcloud. It will eventually run in run in the k8s-infra-prow-build-trusted cluster and
use the k8s-infra-gcp-auditor GCP service account via workload identity. I’m trying to figure how how to pass my own GCP , gcloud auth login generated creds into the local prow job so it has access to run gcloud w/ audit permissions.... will cross post this to #sig-testing in slack.

Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

Some suggestions

Comment on lines 32 to 33
testgrid-alert-email: [email protected]
testgrid-num-failures-to-alert: '1'
Copy link
Member

Choose a reason for hiding this comment

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

I would change these while you're iterating on this job

./audit-gcp.sh
git diff
git add --all
git commit -m "audit: update as of $(date +%Y-%m-%d)"
Copy link
Member

Choose a reason for hiding this comment

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

As a start, you could have this job fail if there are changes to commit, and pass if there are none

Copy link
Member Author

Choose a reason for hiding this comment

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

I may swing back around to that. Trying to get a full run to ensure all the tooling works.

@hh hh force-pushed the ci-k8sio-audit branch 4 times, most recently from 8de871c to d7c5700 Compare February 10, 2021 18:37
@hh
Copy link
Member Author

hh commented Feb 10, 2021

/retitle ci-k8sio-audit periodic job

@k8s-ci-robot k8s-ci-robot changed the title WIP: ci-k8sio-audit perodic job / fixes #244 ci-k8sio-audit periodic job Feb 10, 2021
@k8s-ci-robot k8s-ci-robot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Feb 10, 2021
Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

Some suggestions

- -c
- |
echo "Some initial debuging to figure out what it looks like here" >&2
pwd
Copy link
Member

Choose a reason for hiding this comment

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

periodic jobs will have the working directory set to the root of the repo specified by the first ref in extra_refs (if specified)

ref: https://github.com/kubernetes/test-infra/blob/master/prow/pod-utilities.md

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's useful!

Comment on lines 73 to 74
git config user.name "Kubernetes Prow Robot"
git config user.email "[email protected]"
Copy link
Member

Choose a reason for hiding this comment

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

This should correspond to the GH_USER being used, and I would advise we not use k8s.ci.robot

echo -n "Calculate github user from token: " >&2
GH_TOKEN=$(cat /etc/github-token/oauth)
GH_USER=$(curl -H "Authorization: token $GH_TOKEN" "https://api.github.com/user" 2>/dev/null | sed -n "s/\s\+\"login\": \"\(.*\)\",/\1/p")
FORK_GH_BRANCH=autoaudit-${PROW_INSTANCE_NAME:-prow}
Copy link
Member

Choose a reason for hiding this comment

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

not blocking but what's the purpose of the PROW_INSTANCE_NAME substitution?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit of copy-pasta from here:

# Set this to something more specific if the repo hosts multiple Prow instances.
# Must be a valid to use as part of a git branch name. (e.g. no spaces)
PROW_INSTANCE_NAME="${PROW_INSTANCE_NAME:-prow}"

Possibly not necessary as I don't expect there to be multiple FORK_GH_BRANCH, but I suspect this repo does host multiple prow instances.

volumes:
- name: github
secret:
secretName: oauth-token
Copy link
Member

Choose a reason for hiding this comment

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

I need to double check if we have this. If we don't, I suggest we not use k8s-ci-robot, and for the short-term use a user under your control (using fejta-bot as the model, which is not an org member)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm... I'm not sure how to load secrets like this into the production prow instance.
I generated an oauth-token for @cncf-ci and can send that in a secure way as soon as I learn how. :)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
secretName: oauth-token
secretName: cncf-ci-github-token
gcloud secrets versions access \
  --project=k8s-infra-prow-build-trusted \
  --secret=cncf-ci-github-token \
  latest | \
    kubectl --context=gke_k8s-infra-prow-build-trusted_us-central1_prow-build-trusted \
      apply -f -
secret/cncf-ci-github-token created

It's not complete yet, but it may be eaiser to merge and iterate.

Co-authored-by: Aaron Crickenberger <[email protected]>
@hh
Copy link
Member Author

hh commented Feb 11, 2021

Created a google secret in the format of a k8s secret in the test-pods namespace:

kubectl create secret  --dry-run=client \
  -n test-pods \
  generic cncf-ci-github-token \
  --from-literal=token=${GH_TOKEN} \
  -o yaml \
| gcloud secrets versions add \
  --project=k8s-infra-prow-build-trusted \
  cncf-ci-github-token \
  --data-file=-
Created version [1] of the secret [cncf-ci-github-token].

Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

Added the secret @hh transferred to me via secret manager, job needs some config updates to match name of/in the secret

volumes:
- name: github
secret:
secretName: oauth-token
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
secretName: oauth-token
secretName: cncf-ci-github-token
gcloud secrets versions access \
  --project=k8s-infra-prow-build-trusted \
  --secret=cncf-ci-github-token \
  latest | \
    kubectl --context=gke_k8s-infra-prow-build-trusted_us-central1_prow-build-trusted \
      apply -f -
secret/cncf-ci-github-token created

echo "Ensure gcloud creds are working" >&2
gcloud config list
echo -n "Calculate github user from token: " >&2
GH_TOKEN=$(cat /etc/github-token/oauth)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
GH_TOKEN=$(cat /etc/github-token/oauth)
GH_TOKEN=$(cat /etc/github-token/token)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 7663f60

This also adds dynamically pulling the email and name via the token
rather than needing to hard code them in the job.

Note that it's the default email that is used for the token provided.

Also switched to parsing curl output via jq rather than sed. GNU sed and
BSD sed act a bit differently and I was getting inconsistent results on
OSX vs Linux.
Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm
/wg k8s-infra
/sig testing

@k8s-ci-robot k8s-ci-robot added wg/k8s-infra sig/testing Categorizes an issue or PR as relevant to SIG Testing. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 11, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hh, spiffxp

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 11, 2021
@k8s-ci-robot k8s-ci-robot merged commit 492140b into kubernetes:master Feb 11, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 11, 2021
@k8s-ci-robot
Copy link
Contributor

@hh: Updated the job-config configmap in namespace default at cluster test-infra-trusted using the following files:

  • key wg-k8s-infra-trusted.yaml using file config/jobs/kubernetes/wg-k8s-infra/trusted/wg-k8s-infra-trusted.yaml

In response to this:

Fixes kubernetes/k8s.io#244

Developing using https://github.com/kubernetes/test-infra/blob/master/prow/build_test_update.md#using-pj-on-kindsh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

extra_refs:
- org: kubernetes
repo: k8s.io
base_ref: master
Copy link
Member

Choose a reason for hiding this comment

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

https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/ci-k8sio-audit/1359969296511406080

d'oh, this should have been main not master, my bad for missing this on review

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. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup a job to automatically run and PR the results of audit/audit-gcp.sh
3 participants