-
Notifications
You must be signed in to change notification settings - Fork 68
Complete more of the move from certification to internal #840
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
Complete more of the move from certification to internal #840
Conversation
5fe0887
to
d3f0b67
Compare
As a library caller, this PR would not allow me to extract artifacts, such as the preflight.log, from my execution. The artifacts package needs to be made available so that a library caller can manipulate the context with the appropriate ArtifactWriter. |
Should library users wish to retrieve the artifacts, I would propose that a (future) API could be added to reach internal and get a tar to get the artifacts. I currently view artifacts as a preflight-specific implementation detail, and not a general purpose thing for library users. |
This doesn't work for me. If a library caller gets an error or failing result, (i.e. they don't pass), they have nothing they can do to troubleshoot the problem. I don't see it as strictly internal functionality because of this. I also don't see it as a CLI-specific implementation detail. |
I also don't see a reason to remove the formatters. The API isn't complicated, and it does a single thing - and guides developers on how they can implement their own. With this said, I don't think it's strictly necessary. If you want it removed, you'll need to update doc/LIBRARY.md to remove the reference to it. |
I think I can meet you halfway here. While I don't think the current implementation is necessary to be exposed, I do think that some mechanism to retrieve the artifacts would be useful to a library user. So, what I would propose is moving forward here, but then being thoughtful about what API we want to expose. Does that work for you? I do agree that the library user should have the opportunity to review them, I just don't think they necessarily need to write them, which is more what this artifacts implementation currently does. |
I can come along with this. I'll pull them back out. |
d3f0b67
to
4edb93b
Compare
Re: Artifacts
This is fine - but we've got no roadmap planned on this. So, what do we do to bridge the gap until then? I think I would have less of an issue with moving the artifacts into an internal package if executing Preflight (either policy) and having a failing or erroring result could be debugged without it. But as of today, the results for certain checks themselves tell the user top refer to the artifacts for information on how to troubleshoot.. Let alone the embedding of the preflight.log as an artifact for library callers.
While some of the implementation makes reference to "Write", It's really just a semantic. We can call these methods anything we want. The FilesystemWriter "writes" to the fs, but the MapWriter is just building a map. The Re: Formatters I know you said you'd pull these back out. I'll propose an alternative path - realistically, we don't care what people do with the formatted results, but our ResponseFormatter gives describes extra functionality such as the extension that we don't necessary need to expose. If we want to limit our API surface, maybe we just expose the FormatterFunc and a few functions such as The surface would be just that one type definition and the function(s) that we want to provide as, sort of, "defaults". That way, we encourage folks to write their own FormatterFunc, and we can keep our interface, implementations, internal to be modified. |
certification/results.go
Outdated
ElapsedTime time.Duration | ||
} | ||
|
||
type Results struct { | ||
TestedImage string | ||
PassedOverall bool | ||
TestedOn OpenshiftClusterVersion | ||
TestedOn string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we changed this implementation detail, and added a String()
method in runtime.go. Does this buy us something I'm not seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this doesn't seem to work. This is always unknown/unknown
in the json that gets written to disk and displayed to the user, even though internal results struct is correct internally pre-formatter call. I assume it's the genericFormatter that's causing the issue, but didn't look further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we changed this implementation detail, and added a
String()
method in runtime.go. Does this buy us something I'm not seeing?
There was no reason to expose the OpenshiftClusterVersion struct. I'll admit that where it stands right now is completely naive and may (probably?) doesn't work as it stands. I haven't looked at it further either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do 'expose' OpenshiftClusterVersion struct though, in the sense that it is written to disk, and written to the console. And as it stands that does not work for the reasons I stated above.
As I proposed elsewhere, I think the API to artifacts should just be a 'SaveXXX', like 'SaveTar', or 'SaveFs', 'SaveDir'. Or, 'Save(opt ArtifactOption)'. I don't think the writing of artifacts is something that the library user should be relying on the library to do. If a library user wants to add artifacts, they do so to their own artifacts payload without having to reach into the library to do it. Now, to GET the artifacts that the library generates, that makes sense.
I get that, however, I don't think it's necessary to expose that from the library. As I previously stated, I think the library should provide the capability to get to the artifacts generated, but not be responsible for writing to the library user's artifacts. |
I can get on board with this. Expose our current formatters that we've implemented, but still allow for creating your own formatter. This tells me that these should probably be separate PRs. |
However you want to do this is fine by me. |
Maybe we're not in the seeing each other regarding this point. The ArtifactWriter isn't something that the library caller consumes. It's effectively a choice the library caller makes, telling preflight how to write its artifacts in a way that the library caller can consume. "Write my artifacts here, and I'll retrieve them later". As an example, if a library caller wanted to... say write an S3 Uploader ArtifactWriter - they could do that, then embed the artifact writer in the context and preflight would write its artifacts however the caller wishes. |
4edb93b
to
d9d921a
Compare
d9d921a
to
d30904c
Compare
* Moves certification/engine * Moves certification/pyxis * Moves certification/runtime * Moves certification/policy * Moves certification/artifacts -> artifacts * Moves certification/formatters -> formatters and internal/formatters * Leaves the FormatterFunc type exported * Creates runtime top-level package Signed-off-by: Brad P. Crochet <[email protected]>
d30904c
to
4308ab0
Compare
Just to close the discussion loop here, I believe we landed on leaving the artifacts implementation on this branch as is for the moment, while @bcrochet reaches an alternative implementation that may be a bit more clearly defined for our use case. The artifacts implementation as it exists in this branch would, therefore, move to the top level and outside of the certification module (as it is not needed). Regarding logging, I believe we landed on exposing a few of our formatting functions as opposed to the internal formatter logic itself. Formatting, in itself, can be done however the user sees fit, and so we only intend to provide the execution our results formatting that we use as a baseline @bcrochet please correct me if I've captured this incorrectly, it's been several days since our discussion! |
"github.com/redhat-openshift-ecosystem/openshift-preflight/internal/runtime" | ||
) | ||
|
||
type openshiftClusterVersion = runtime.OpenshiftClusterVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ignore - does this still need to be here? It just looks like an alias, but I'm not sure why we would have used it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an alias that reaches into internal so it can still be used as a type here, without having to duplicate it, and so that it isn't exposed as an actual part of the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Thanks for this heavy lift!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: acornett21, bcrochet, komish 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 |
Signed-off-by: Brad P. Crochet [email protected]