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

Dependency loop between juju/testing several other juju libraries #161

Open
gibmat opened this issue Oct 30, 2021 · 2 comments
Open

Dependency loop between juju/testing several other juju libraries #161

gibmat opened this issue Oct 30, 2021 · 2 comments

Comments

@gibmat
Copy link

gibmat commented Oct 30, 2021

A dependency loop exists between juju/testing and the two libraries juju/collections and juju/clock, each of which in turn depend on juju/testing.

Within juju/testing, the use of juju/collections and juju/clock seems to be limited to only the mgo.go file, which imports juju/collections/set and juju/clock.

This was noticed while reviewing dependencies needed to cleanly package LXD for Debian, where each library that LXD depends on must be able to build on its own with a clean set of dependencies. A dependency loop makes this very difficult to accomplish. This may not be a blocking issue as we may have to drop mongodb-specific code because mongodb is no longer in the Debian package archive.

@gibmat
Copy link
Author

gibmat commented Oct 31, 2021

An even tighter dependency loop was found:

                   juju/testing
                    ^       ^
                    |       |
                    V       V
            juju/errors<--juju/utils

If there's any way to make that dependency graph a DAG, it would make life much easier when individual libraries need to be packaged. 😄

(Helps if I draw the arrows correctly....)

@gibmat gibmat changed the title Dependency loop between juju/testing and libraries juju/collections and juju/clock Dependency loop between juju/testing several other juju libraries Nov 6, 2021
@gibmat
Copy link
Author

gibmat commented Nov 6, 2021

A few observations from my work while packaging this library for Debian:

  • I've ignored mgo.go & friends, as mongodb doesn't currently exist in the Debian archive. That also nicely cuts the dependency loop between testing and collections and clock; it still exists and should be fixed, but is not a blocking issue.

  • The use of the utils library within testing consists of calls to several small helper functions:

    • utils.ShQuote()
    • utils.SetHome()
    • utils.Home()

    Those are all basically one-liners, so I think it would be easy enough to just replace those calls into utils with the actual code. Doing so would break that dependency loop.

  • The dependency on the errors library is a bit stickier. There are several uses of the functions errors.Trace() and errors.New(). For the time being, I've just commented out affected tests (ugh) and adjusted the code to return the raw err, rather than wrapping it in Trace(). The code involved with use of errors is more complicated than utils, so I am going to have to rely on the actual authors of the code to cleanly break this loop.

The good news is that, with the above changes, I've been able to successfully build the following juju libraries without any dependency loops: clock, cmd, collections, errors, mutex, and utils.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant