-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers: avoid referencing client/structs package #5157
Conversation
04e0647
to
770d7b3
Compare
Simplify allocDir.Build() function to avoid depending on client/structs, and remove a parameter that's always set to `false`. The motivation here is to avoid a dependency cycle between drivers/cstructs and alloc_dir.
Re-export the ResourceUsage structs in drivers package to avoid drivers directly depending on the internal client/structs package directly. I attempted moving the structs to drivers, but that caused some import cycles that was a bit hard to disentagle. Alternatively, I added an alias here that's sufficient for our purposes of avoiding external drivers depend on internal packages, while allowing us to restructure packages in future without breaking source compatibility.
770d7b3
to
34ee0ba
Compare
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.
This LGTM as long as @schmichael is ready to drop the old allocrunner code
// skip expensive embedding operations and only ephemeral operations (eg | ||
// mounting /dev) are done. | ||
func (t *TaskDir) buildChroot(chrootCreated bool, entries map[string]string) error { | ||
if !chrootCreated { |
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.
Why get rid of this check?
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.
Hmm I guess because it's only called /w false.
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.
Indeed - buildChroot
and taskdir.Build()
[1] always is called with false, so didn't see the value.
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.
👍
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.
Great job getting rid of that dead code in TaskDir.Build too!
} | ||
return nil | ||
// host and can't be embedded an error is returned. | ||
func (t *TaskDir) buildChroot(entries map[string]string) error { |
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.
This func seems like a useless wrapper now.
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.
Indeed, I liked having it around, as the function name and comment is useful. embedDirs()
doesn't convey the same thing.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Avoid drivers explicitly referencing the internal package,
nomad/client/structs
.Moved
FSIsolation
andDeviceNetwork
to drivers, but re-exported ResourceUsage interfaces to avoid drivers directly depending on the internal client/structs package directly.I attempted moving the structs to drivers, but that caused some import cycles that was a bit hard to disentangle. Alternatively, I added an alias here that's sufficient for our purposes of avoiding external drivers depend on internal packages, while allowing us to restructure packages in future without breaking source compatibility.