Skip to content

Enforce restrictions on dependency relationships between packages - #8284

Open
zjs wants to merge 8 commits into
vmware:masterfrom
zjs:topic/deps
Open

Enforce restrictions on dependency relationships between packages#8284
zjs wants to merge 8 commits into
vmware:masterfrom
zjs:topic/deps

Conversation

@zjs

@zjs zjs commented Sep 20, 2018

Copy link
Copy Markdown
Member

Enforce whitelist-based restrictions on the dependency relationship between packages. This allows us to ensure that undesirable dependency relationships are not introduced.

The enforcement works by enumerating the go packages, finding the applicable .godeps_rules file (looking first in the package's directory, then looking recursively in parent directories, and finally falling back to /dev/null — essentially "default deny"). Each rules file is a list of regular expressions to be evaluated by grep (with support for full-line #-prefixed comments).

The enforcement script leverages the existing go-deps.sh script, including its caching logic (enabled by setting VIC_CACHE_DEPS, purged via make cleandeps).

Careful review of PRs that introduce or modify rule files will be necessary for this enforcement to be as effective as possible.


Fixes #8203

I've created #8294 to track resolution of existing undesirable dependency relationships.

Please review both the enforcement script itself and the initial dependency rules, which are written by hand based on my understanding of the codebase and may have errors as a result.

zjs added 2 commits September 19, 2018 15:09
Address warnings from shellcheck (e.g., properly quoting expressions
and combining conditionals) to better follow bash best practices.

Additionally, introduce our standard set line to catch errors earlier
and conditionally provide debugging output.
Introduce a script to enforce rules about dependency relationships
between packages in the project.

This script leverages the existing go-deps.sh script, including its
caching logic (enabled by setting VIC_CACHE_DEPS).
@zjs zjs self-assigned this Sep 20, 2018
@zjs
zjs requested review from hickeng and wjun September 20, 2018 17:03
@zjs
zjs requested a review from a team as a code owner September 20, 2018 17:03

@hickeng hickeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've reviewed the mechanism and changes - I've not reviewed all of the deps files. I assume they are both sufficient and minimal at this time and I do not want to get distracted trying to track down why some of the odd dependencies exist in this PR.

Comment thread lib/apiservers/engine/.godeps_rules Outdated
zjs added 4 commits September 21, 2018 20:55
Define an initial set of dependency enforcement rules based on the
current state of the codebase.

Some problematic relationships were identified and annotated.
Add dependency relationship enforcement to the checks stage of the
build process so that it runs as a part of CI.
Add TODOs to track bad dependencies
@zjs zjs added this to the Sprint 36 milestone Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce dependency restrictions

4 participants