-
Notifications
You must be signed in to change notification settings - Fork 198
remove pkg/context, overhaul snapshot handling #417
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
base: main
Are you sure you want to change the base?
Conversation
f3ed2e1
to
128887b
Compare
Gets rid of `pkg/context` entirely along with the `Do()/Setup()/Teardown()` context-handling stuff that was added to deal with snapshots. Moves to a simpler and more straight-forward system of passing zero or more Option functors that build an Options struct. Removes the `ghw-snapshot` tool and makes the `ghwc` tool understand ghw snapshots natively (just pass a `-s <snapshot_path>` CLI flag). Added a `ghwc snapshot` command that creates snapshots. Signed-off-by: Jay Pipes <jaypipes@gmail.com>
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.
First of all thanks for filing this! design wise I like this approach a lot and I'm all for it.
The main question I have is: how do we deal with backward compatibilty? this is an API breakage both at golang package level and at command line level (tool removal).
Perhaps we can bump the major version? would that too much of a jump, or too little?
Glancing over the PR everything seems reasonnable, but it will take me some time to ready everything (other duties :\ )
@ffromani Ciao! :) Yeah, it's a breaking change for sure, though I worked hard to minimize the changes that "normal" users would see. The call signature for all of the Info() functions remains the same so their Go code that imports the ghw library would not need to change. And the I don't think it warrants a major version bump because there's no functional change to the API besides the removal of the SnapshotOptions/WithSnapshot functor. But, again, I don't think many people outside of us ever used that feature of the API/low-level calling interface. I did deprecate the top-level (alias.go) WithOption and renamed it just Option, but that's not a breaking change due to continuing to keep the old WithOption type in place. So, I think (unless you say otherwise) this should be "safe" to cut as another 0.x release. :) |
Note IF we decide we bump the major version, we can and probably should revamp and conclude my ancient SRIOV PR. It's stuck because last time I worked on it I could not find a reasonnably high backward compatibility. |
Sound reasonnable. I didn't yet grasp this because I only had a cursor glance over your PR, which I did because I wanted to acknowledge this work and the review request. I will have a deep enough look ASAP and comment again. |
First and foremost. This is great work. Kudos! Now: I tend to agree the happy/common path should be relatively safe/straightforward, or so it seems reviewing the changes. And, truth is, the more I review the more I like this change, so I would really like to have it in. But I'm still worried about how breaking this breaking change is. I think stability is a good plus, and while this change has a lot of value for maintainers, I don't see a compelling case for users of If we can wither minimize the disruption (avoid it completely would be ideal ofc) AND clearly outline the value proposition, I would be much more comfortable and we can just go ahead. What I can do next is to try out a Some minor comments inside; I didn't go much further because, well, the PR is already pretty clean and I'd rather settle out the compat. conversation before to dive into details. |
@ffromani thank you, as always, for the thoughtful review and commentary. I very much appreciate your focus on stability and backwards compatibility! There are actually only two backwards-incompatible changes to the API/ABI included in this PR, both of which I believe are only applicable to a very small slice of users (perhaps only you and I ;) ):
All other changes to the main For example, if the user's code looked like this: package main
import "github.com/jaypipes/ghw"
func main() {
cpu, err := ghw.CPU()
if err != nil {
...
}
} nothing has changed about the call signatures for either the type-aliased Same for the following: package main
import "github.com/jaypipes/ghw"
func main() {
cpu, err := ghw.CPU(ghw.WithDisableTools())
if err != nil {
...
}
} or this: package main
import (
"github.com/jaypipes/ghw"
"github.com/jaypipes/ghw/pkg/option"
func main() {
cpu, err := ghw.CPU(option.WithChroot("/mnt/newroot/")
if err != nil {
...
}
} or even this: package main
import (
"github.com/jaypipes/ghw/pkg/cpu"
"github.com/jaypipes/ghw/pkg/option"
func main() {
info, err := cpu.New(option.WithChroot("/mnt/newroot/")
if err != nil {
...
}
} I'm fine creating a v1 release series git branch and redirecting this PR to that branch, but AFAICT, apart from the minor incompatible things related to pkg/memory.CachesForNode() and the snapshotting code, it's actually backwards-compatible... anyway, I'll leave it to you what you want to do. Happy to do the v1 branch thing but also happy to do a v0 dot release. |
Thanks @jaypipes! Again, your points make sense and the code looks good. I'm not by any means trying to diminuish this work! I can't think in any way I could have done better. Thing is, I've seen I guess I need to convince myself trying by doing the upgrade as I mentioned in the previous comment. I will attempt shortly. Thanks again for the patience and the explanation, and apologies for the delay in review. |
thinking about it, I have a proposal. What if we identify few (in the order of like 4-5) prominent importers of Something like "project XYZ compiles with no changes and passes all the tests" or "project ABC needs this patch but then compiles cleanly and passes all the tests" or (hopefully not) "project FOO compiles with no changes but fails tests 1, 4, 77". EDIT: obviously I volunteer to help implementing this proposal, getting in touch with these projects, submitting test PRs and socializing the changes. |
I like the proposal. What would be your short-list of importing projects? |
Since my proposal is related to the breaking changes assessment, but is not necessarily gating, I'm moving the conversation here: #421 and I sketched an initial very rough draft of a shortlist and the criterias to add/keep projects in the list Will try out #417 (comment) as soon as possible |
DNM Signed-off-by: Francesco Romani <fromani@redhat.com>
update: testing is going good! I need to run a few more tests (disclosure: going slower because vacation) but so far so good, looks like we're trending towards merge! |
Gets rid of
pkg/context
entirely along with theDo()/Setup()/Teardown()
context-handling stuff that was added to deal with snapshots. Moves to a simpler and more straight-forward system of passing zero or more Option functors that build an Options struct.Removes the
ghw-snapshot
tool and makes theghwc
tool understand ghw snapshots natively (just pass a-s <snapshot_path>
CLI flag). Added aghwc snapshot
command that creates snapshots.