-
Notifications
You must be signed in to change notification settings - Fork 83
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
committime exporter doesn't work with binary builds #317
Comments
Hi @KevinMGranger @jlozano-rh .. i dont know if any prior art/thinking has gone on with this one? given that Binary Builds have none of the required information in OCP for git, i have a prototype / hack working that relies on annotating the Build from a pipeline (i'm using Tekton) but it could be any pipeline script really:
and then some minor modifications in the python i would be interested if others have any ideas since binary builds are extremely common |
@eformat yes, in my case... I had to modify the And modify def get_metric_from_build(self, build, app, namespace, repo_url):
try:
...
if not repo_url:
if build.spec.source.git:
repo_url = build.spec.source.git.uri
elif build.metadata.annotations.pelorusgiturl:
repo_url = build.metadata.annotations.pelorusgiturl
else:
repo_url = self._get_repo_from_build_config(build)
metric.repo_url = repo_url Or something like that. |
ah yup .. me to. same approach. OK .. wonder if we go with that? and add instructions for the annotations for binary builds. @KevinMGranger - WDYT ? |
Related to #371 |
@eformat we're thinking that the approach in #371 is probably best (have the resulting image have the commit ID and URL embedded). Do either you or @jlozano-rh know of any use cases where that wouldn't be an option? If so, this is still a good idea and we'll probably use your PR. |
hi @KevinMGranger .. #371 should work as well - ultimately the metadata for perlorus has to exist somewhere, so as labels on the OCI image also works. The only difference i think would be if you wanted to capture start/end build times - which is easier on the BuildConfig, no reason you couldn't put that on the built image as well if desired, it would just be more custom labels perhaps. |
For build times, I think we can get the metadata from the build pod itself, right? That's something we can investigate later. |
@jlozano-rh hello. The commit time exporter is expected to find out time of the repository commit and use it together with other metrics to measure "Lead time for change" - time from code committed to deployed to production. I don't fully understand the requirement of monitoring binary build where the commit time is missing from provided build input. Could you please elaborate on how this is going to help in measuring lead time for change? If the input for binary build provided is actually local git repository or compressed archive of git repository then it looks like it could potentially work ? Maybe you could describe a bit more about your use case and how the build and deployment happens, e.g. is the Dockerfile provided in the build stored in a repo and why it's passed from local box rather then in a pipeline where changes are stored outside of mechanism to track historical commits. |
@mpryc I understand the point. I have no access anymore to the customer resources, but I remember something like this: the customer has a pipeline that have tasks in sequence: checkout, test, update-file, binary-build, deploy. So the binary-build occurs inside the pipeline through a Dockerfile. I think like @KevinMGranger... maybe we can take the time from the build pod, for example: |
We need the time of the commit, not the time of the build. Is the checkout given as the input to the |
@KevinMGranger yes, the entire git repo directory (including the .git) is passed to binary-build task. So I think that we can do something like this: import git
from datetime import datetime
repo = git.Repo("/path/to/git-repository")
last_commit = repo.head.commit
timestamp = datetime.fromtimestamp(last_commit.committed_date)
print(timestamp)
|
Unfortunately, it's not possible to inspect the contents of the binary build input. The only option we have is inspecting manual labels, or having some other work done in the build process. We're looking into alternate solutions right now, but the manual labelling seems to be an okay solution. |
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>
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>
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>
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>
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>
In Red Hat we have customers that have all it's builds configured with Binary builds, that are similar to next:
But the committime exporter is trying to find the next properties in builds triggered
.spec.source.git.uri
and.spec.revision.git.commit
. These properties do not exist because the build is binary, so the committime exporter pod is recording the following log:It would be a good idea to propose that the committime exporter code implement a way of doing things for binary builds.
The text was updated successfully, but these errors were encountered: