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

gcbmgr: add list build jobs #1194

Merged
merged 1 commit into from
Mar 23, 2020
Merged

Conversation

cpanato
Copy link
Member

@cpanato cpanato commented Mar 18, 2020

What type of PR is this?

This PR adds the option to list the last X build jobs
example:

$ krel gcbmgr --branch release-1.18 --list-jobs 8
INFO Running gcbmgr with the following options: {false false false release-1.18 prerelease   8}
INFO Build options: {  cloudbuild.yaml   kubernetes-release-test false false false   }
INFO Retrieving Kubernetes release version for ci/latest on branch release-1.18
INFO Retrieving Kubernetes build version from https://dl.k8s.io/ci/latest-1.18.txt...
INFO Retrieved Kubernetes version: v1.18.0-rc.1.1+d5444327df0357
INFO Trying to get the kube-cross version for release-1.18...
INFO Found the following kube-cross version: v1.13.8-1
INFO Listing GCB substitutions prior to build submission...
INFO RC_TAG:
INFO RELEASE_BRANCH: release-1.18
INFO BUILDVERSION: --buildversion=v1.18.0-rc.1.1+d5444327df0357
INFO KUBE_CROSS_VERSION: v1.13.8-1
INFO TOOL_ORG: kubernetes
INFO TOOL_REPO: release
INFO OFFICIAL_TAG:
INFO OFFICIAL:
INFO RC:
INFO TOOL_BRANCH: master
INFO BUILD_POINT: v1.18.0-rc.1.1-d5444327df0357
INFO NOMOCK_TAG:
INFO NOMOCK:
INFO GCP_USER_TAG: ctadeu-at-gmail-com
INFO Listing last 8 GCB jobs:
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
|           START TIME           |          FINISH TIME           |  STATUS   |                                                 CONSOLE LOGS                                                  |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
| 2020-03-17T18:01:39.454011569Z | 2020-03-17T18:18:42.306307Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66caa764-d21b-465d-95d6-d8b754ed945b?project=648026197307 |
| 2020-03-17T17:05:46.596215978Z | 2020-03-17T17:58:40.563946Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/22413ad5-0e74-4118-98a8-c6a6b776f2e5?project=648026197307 |
| 2020-03-17T16:44:14.493028495Z | 2020-03-17T17:01:08.357092Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/313eaeba-386b-4744-ac5e-de2da0c0ec3a?project=648026197307 |
| 2020-03-17T15:47:22.036533888Z | 2020-03-17T16:39:33.880910Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/f7fb4817-0d2e-40ae-9fed-ec2f4ba90bb6?project=648026197307 |
| 2020-03-17T15:46:59.446635185Z | 2020-03-17T15:48:00.752557291Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/9283b1b4-e23c-4160-89d1-c9ca7e7cd326?project=648026197307 |
| 2020-03-17T15:41:08.534867366Z | 2020-03-17T15:48:10.707409281Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/afba1c94-a3b1-4a9f-a025-79549f5bf5f4?project=648026197307 |
| 2020-03-12T23:13:39.983798382Z | 2020-03-12T23:42:05.867161Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66715bd8-93a2-4000-86e9-ab734b72766a?project=648026197307 |
| 2020-03-12T22:47:12.056531535Z | 2020-03-12T22:47:23.343306181Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/88acc767-adfe-4ea4-8646-0287b05d5410?project=648026197307 |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

gcbmgr: Add list build jobs

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 18, 2020
@k8s-ci-robot
Copy link
Contributor

@cpanato: Adding label: do-not-merge/blocked-paths because PR changes a protected file.

Reasons for blocking this PR:

[Changes to certain release tools can affect our ability to test, build, and release Kubernetes. This PR must be explicitly approved by SIG Release repo admins.]

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 18, 2020
@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Mar 18, 2020
@k8s-ci-robot k8s-ci-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 Mar 18, 2020
@cpanato
Copy link
Member Author

cpanato commented Mar 18, 2020

the test is an initial one, we can discuss how to improve it.

@cpanato
Copy link
Member Author

cpanato commented Mar 18, 2020

/cc @justaugustus @saschagrunert

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Alright generally LGTM, I just have a few suggestions/nits 👇


func ListJobs(project string, lastJobs int64) error {
ctx := context.Background()
opts := option.WithCredentialsFile("")
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 follow up I suggest to wrap this in a new struct like we do in the guthub package. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I will review the github package and apply the same in a follow up.
thanks!

return errors.Wrap(err, "error fetching gcloud credentials... try running \"gcloud auth application-default login\"")
}

req, err := service.Projects.Builds.List(project).PageSize(lastJobs).Do()
Copy link
Member

Choose a reason for hiding this comment

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

Is there a maximum value for the page size? If yes, what do we do if we’re requesting more jobs?

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 tried to find in the docs but it does not say anything
https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds/list

Copy link
Member

Choose a reason for hiding this comment

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

Fair, do page sizes > 100 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.

i did with 301 and returned all 301 last jobs

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me, thanks for verifying.

Copy link
Member Author

Choose a reason for hiding this comment

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

tried with 500 :)

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 think this is not useful but a user can do weird things 😂

Copy link
Member

@saschagrunert saschagrunert Mar 19, 2020

Choose a reason for hiding this comment

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

What happens on -1? 😁

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 brings the jobs in the future :P

but looks like it not fail

INFO Listing last -1 GCB jobs:
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
|           START TIME           |          FINISH TIME           |  STATUS   |                                                 CONSOLE LOGS                                                  |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
| 2020-03-17T18:01:39.454011569Z | 2020-03-17T18:18:42.306307Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66caa764-d21b-465d-95d6-d8b754ed945b?project=648026197307 |
| 2020-03-17T17:05:46.596215978Z | 2020-03-17T17:58:40.563946Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/22413ad5-0e74-4118-98a8-c6a6b776f2e5?project=648026197307 |
| 2020-03-17T16:44:14.493028495Z | 2020-03-17T17:01:08.357092Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/313eaeba-386b-4744-ac5e-de2da0c0ec3a?project=648026197307 |
| 2020-03-17T15:47:22.036533888Z | 2020-03-17T16:39:33.880910Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/f7fb4817-0d2e-40ae-9fed-ec2f4ba90bb6?project=648026197307 |
| 2020-03-17T15:46:59.446635185Z | 2020-03-17T15:48:00.752557291Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/9283b1b4-e23c-4160-89d1-c9ca7e7cd326?project=648026197307 |
| 2020-03-17T15:41:08.534867366Z | 2020-03-17T15:48:10.707409281Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/afba1c94-a3b1-4a9f-a025-79549f5bf5f4?project=648026197307 |
| 2020-03-12T23:13:39.983798382Z | 2020-03-12T23:42:05.867161Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66715bd8-93a2-4000-86e9-ab734b72766a?project=648026197307 |
| 2020-03-12T22:47:12.056531535Z | 2020-03-12T22:47:23.343306181Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/88acc767-adfe-4ea4-8646-0287b05d5410?project=648026197307 |
| 2020-03-12T22:47:18.045150178Z | 2020-03-12T23:16:03.417070Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/c0cdf52a-d386-4de8-8eaa-c6c31fe86960?project=648026197307 |
| 2020-03-12T22:46:46.270468739Z | 2020-03-12T23:17:50.062883Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/0c33f75a-fe5d-4800-8c93-4864545fc96b?project=648026197307 |
| 2020-03-12T20:56:59.329664144Z | 2020-03-12T23:09:49.748778Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/56dcfb8d-4997-4d80-a26b-d98dcb16354e?project=648026197307 |
| 2020-03-12T20:52:03.334708890Z | 2020-03-12T22:40:16.286748Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/bd24d66d-671f-480f-b940-7dd8e4b195b2?project=648026197307 |
| 2020-03-12T20:49:17.189666168Z | 2020-03-12T22:42:03.250553Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/730e2680-1117-4ceb-b7ee-244ddfc73143?project=648026197307 |
| 2020-03-12T20:25:45.541744471Z | 2020-03-12T20:55:39.045461Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/f4553143-76cf-4302-8f8a-eb378d707755?project=648026197307 |
| 2020-03-12T20:19:33.605482117Z | 2020-03-12T20:46:59.117637Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/3cb43a19-5f65-4540-8eb4-ab6a2b44d1ba?project=648026197307 |
| 2020-03-12T20:18:26.464990013Z | 2020-03-12T20:48:07.174950Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/06b6dbbc-8041-47b1-8e21-38d9a62c917a?project=648026197307 |
| 2020-03-12T18:26:12.101181631Z | 2020-03-12T20:11:08.424601Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/53df157a-1a29-45ae-9ef6-2616cf89d0f4?project=648026197307 |
| 2020-03-12T18:25:17.403597155Z | 2020-03-12T18:25:29.064243395Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/16b647fc-6609-4a3c-a108-615be37b3477?project=648026197307 |
| 2020-03-12T18:21:02.673580173Z | 2020-03-12T20:24:24.667413Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/2a8c78a4-edd6-4769-8d7e-edb6c5b4062b?project=648026197307 |
| 2020-03-12T18:20:59.567154612Z | 2020-03-12T20:16:06.787010Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/27e6b98a-c59c-41e6-8f93-b0089a88c95e?project=648026197307 |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+

Copy link
Member

Choose a reason for hiding this comment

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

Follow-up: Normalize (set to default count) any non-positive number. Also, log that we're going to do that

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

/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 19, 2020
@justaugustus justaugustus removed the do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. label Mar 21, 2020
@justaugustus
Copy link
Member

Great job, @cpanato!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 21, 2020
@justaugustus
Copy link
Member

@cpanato -- I had a merge party and now this needs a rebase 😝

@k8s-ci-robot k8s-ci-robot added do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 21, 2020
@k8s-ci-robot
Copy link
Contributor

@cpanato: Adding label: do-not-merge/blocked-paths because PR changes a protected file.

Reasons for blocking this PR:

[Changes to certain release tools can affect our ability to test, build, and release Kubernetes. This PR must be explicitly approved by SIG Release repo admins.]

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.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2020
@cpanato cpanato force-pushed the listjobs branch 2 times, most recently from 7d1a8ac to 7de7619 Compare March 21, 2020 13:14
@cpanato
Copy link
Member Author

cpanato commented Mar 21, 2020

done @justaugustus

Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

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

@cpanato -- One more thing... can you squash the commits?
I'm seeing merge conflict text between the second and third commit.

@cpanato
Copy link
Member Author

cpanato commented Mar 23, 2020

@justaugustus done. PTAL

@justaugustus justaugustus removed the do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. label Mar 23, 2020
@justaugustus
Copy link
Member

Thanks!
/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, justaugustus, saschagrunert

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 be30d90 into kubernetes:master Mar 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Mar 23, 2020
@cpanato cpanato deleted the listjobs branch March 23, 2020 09:11
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/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. 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.

4 participants