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

🦜 Support for binary builds 🦜 #381

Closed
wants to merge 16 commits into from

Conversation

eformat
Copy link
Contributor

@eformat eformat commented Mar 1, 2022

Describe the behavior changes introduced in this PR

Initial support for OpenShift binary builds by annotating the build config each time you build (e.g. from a pipeline).

Linked Issues?

resolves #317

Testing Instructions

deploy the committime exporter and test using an openshift binary build. you pipeline must annotate the build config on each build run.

@redhat-cop/mdt

@openshift-ci
Copy link

openshift-ci bot commented Mar 15, 2022

@eformat: PR needs rebase.

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.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 15, 2022
Copy link
Collaborator

@mpryc mpryc left a comment

Choose a reason for hiding this comment

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

@eformat reviewed your PR. Many thanks looks great with some minor questions/suggestions. Let me know if you will continue working on this PR or don't have bandwidth in which case we can look at reworking and merging.

Secondly some unit test would be nice to have.

Also this PR requires rebase as few things changed since it was created, but I will focus on getting it merged soon.

Thanks again.


```bash
oc annotate bc/${BUILD_CONFIG_NAME} --overwrite \
buildSpecSourceGitUri=${GIT_URL} \
Copy link
Collaborator

Choose a reason for hiding this comment

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

@eformat do you think it's worth matching the annotations with similar labels that are result of build process?
Those labels are described here

Here is example:

"io.openshift.build.source-location"
"io.openshift.build.commit.id" 
"io.openshift.build.commit.author"
"io.openshift.build.commit.ref"

buildSpecSourceGitUri=${GIT_URL} \
buildSpecRevisionGitCommit=${GIT_COMMIT} \
buildSpecRevisionGitAuthorName="${GIT_AUTHOR}"
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also note that we also missing branch / ref in your PR.


if build.spec.revision is None:
commit_sha = self._get_revision_from_build(build)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add logic to get commit_sha if one was not resolved from the self._get_revision_from_build() func and not always when the build.spec.revision is not None?

@@ -191,7 +195,12 @@ def get_metric_from_build(self, build, app, namespace, repo_url):

metric.commit_hash = commit_sha
metric.name = app
metric.committer = build.spec.revision.git.author.name

if build.spec.revision is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, get it when metric.committer is not valid from the:
metric.committer = self._get_author_from_build(build)

I don't know if such use case is valid when information is missing from build.spec.revision and have generic option to fill that data in the build?

@@ -264,6 +273,9 @@ def _get_repo_from_build_config(self, build):
build_config = v1_build_configs.get(
namespace=build.status.config.namespace, name=build.status.config.name
)
if build.metadata.annotations.buildSpecSourceGitUri:
return build.metadata.annotations.buildSpecSourceGitUri
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there needed validation of URI at some point? e.g. valid git URI regex?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is handled in the CommitMetric class and/or the various collector implementations themselves.

:param build: the Build resource
:return: revisions as a str or None if not found
"""
if build.metadata.annotations.buildSpecSourceGitUri:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this mistake? Should it be:

if build.metadata.annotations.buildSpecRevisionGitCommit:

I also don't understand the logic:

if something:
   return something
return None

This is equivalent to just:
return something

Because:

something = None
if something:
   return something
return None

Unless you wanted to return None if string is empty, then check the len(something) as well.

But as on lines 276-277, I would add some validaitons if the revision is valid regex.

:param build: the Build resource
:return: author as a str or None if not found
"""
if build.metadata.annotations.buildSpecRevisionGitAuthorName:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very similar comment as above with the unnecessary checking if value exists.

mpryc added a commit to mpryc/pelorus that referenced this pull request Jun 10, 2022
Change to resolve dora-metrics#317.

The idea is taken from PR dora-metrics#381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>
mpryc added a commit to mpryc/pelorus that referenced this pull request Jun 10, 2022
Change to resolve dora-metrics#317.

The idea is taken from PR dora-metrics#381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>
mpryc added a commit to mpryc/pelorus that referenced this pull request Jun 10, 2022
Change to resolve dora-metrics#317.

The idea is taken from PR dora-metrics#381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>
@mpryc
Copy link
Collaborator

mpryc commented Jun 10, 2022

I took the idea and implemented this as another PR #498. Co-authored by @eformat.
Please let me know if we can close this one?

mpryc added a commit to mpryc/pelorus that referenced this pull request Jun 15, 2022
Change to resolve dora-metrics#317.

The idea is taken from PR dora-metrics#381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>
mpryc added a commit to mpryc/pelorus that referenced this pull request Jun 21, 2022
Change to resolve dora-metrics#317.

The idea is taken from PR dora-metrics#381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>
weshayutin pushed a commit that referenced this pull request Jun 21, 2022
Change to resolve #317.

The idea is taken from PR #381, however the implementation
allows to have minimal required annotations to calculate
commit time. It also allows to define custom annotations.

Co-authored-by: Mike Hepburn <eformat@gmail.com>

Co-authored-by: Mike Hepburn <eformat@gmail.com>
@mpryc
Copy link
Collaborator

mpryc commented Jun 22, 2022

I am closing this PR as it's being already addressed via PR #498

@mpryc mpryc closed this Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

committime exporter doesn't work with binary builds
3 participants