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

drivers: avoid referencing client/structs package #5157

Merged
merged 6 commits into from
Jan 9, 2019

Conversation

notnoop
Copy link
Contributor

@notnoop notnoop commented Jan 7, 2019

Avoid drivers explicitly referencing the internal package, nomad/client/structs.

Moved FSIsolation and DeviceNetwork 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.

Mahmood Ali added 6 commits January 8, 2019 09:11
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.
Copy link
Member

@nickethier nickethier left a 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 {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

[1] https://github.com/hashicorp/nomad/pull/5157/files/34ee0ba6b931f64dd5a97ca9df0c44506c17f07e#diff-301b205830d382e5f5ce9d97cd3e3404L78

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@schmichael schmichael left a 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 {
Copy link
Member

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.

Copy link
Contributor Author

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.

@notnoop notnoop merged commit d1fbd73 into master Jan 9, 2019
@notnoop notnoop deleted the r-drivers-no-cstructs branch January 9, 2019 18:06
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants