Skip to content

Add an audit system to Spack#23053

Merged
alalazo merged 17 commits intospack:developfrom
alalazo:features/spack_audit
Jun 18, 2021
Merged

Add an audit system to Spack#23053
alalazo merged 17 commits intospack:developfrom
alalazo:features/spack_audit

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Apr 16, 2021

This PR adds a way to check various parts of Spack from the command line. The motivation to start this has been seeing a few issues where errors / inconsistencies in package recipes where mistaken for bugs in the new concretizer, due to poor reporting, and a debug session with @jjellio in which after much struggle we understood that an issue was due to a compiler being defined multiple times in the configuration (which is not allowed but Spack was not clear at all on what was the problem).

The PR should introduce:

  • A way to declare new class of audits (e.g. audits for compiler configuration, audits for package directives etc.)
  • A way to register functions as part of those audits
  • A command to drive this from the terminal
  • Documentation of the new feature
  • Tests for the spack.audit module

As a first example, recreating a case like the one debugged with @jjellio we can obtain with this PR:

culpo@MacBook-Pro bootstrap % cat spack.yaml             
spack:
  specs:
  - zlib
  compilers:
  - compiler:
      spec: [email protected]
      paths:
        cc: /Users/culpo/PycharmProjects/spack/opt/spack/darwin-bigsur-cannonlake/apple-clang-12.0.0/gcc-10.2.0-zm6u6otbxbacpvsbx6lugzo6qeb2hd7v/bin/gcc
        cxx: /Users/culpo/PycharmProjects/spack/opt/spack/darwin-bigsur-cannonlake/apple-clang-12.0.0/gcc-10.2.0-zm6u6otbxbacpvsbx6lugzo6qeb2hd7v/bin/g++
        f77: /Users/culpo/PycharmProjects/spack/opt/spack/darwin-bigsur-cannonlake/apple-clang-12.0.0/gcc-10.2.0-zm6u6otbxbacpvsbx6lugzo6qeb2hd7v/bin/gfortran
        fc: /Users/culpo/PycharmProjects/spack/opt/spack/darwin-bigsur-cannonlake/apple-clang-12.0.0/gcc-10.2.0-zm6u6otbxbacpvsbx6lugzo6qeb2hd7v/bin/gfortran
      flags:
        cflags: '-O3'
      operating_system: bigsur
      target: x86_64
      modules: []
      environment: {}
      extra_rpaths: []
culpo@MacBook-Pro bootstrap % spack audit configuration     
culpo@MacBook-Pro bootstrap % spack -e . audit configuration
CFG-COMPILER: 1 issue found
1. Compiler defined multiple times: [email protected]
    in "/Users/culpo/spack/bootstrap/spack.yaml", line 5, column 5
    in "/Users/culpo/.spack/darwin/compilers.yaml", line 2, column 3

Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

I have a few preliminary comments but I think the most important discussion to address first is the one I marked as "high-level": I'm wondering about the necessity of the AuditClass class.

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 1, 2021

@scheibelp Ready for a second review

@scheibelp scheibelp reopened this Jun 15, 2021
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 16, 2021

@scheibelp Pushed again to fix a conflict with command completion

@scheibelp
Copy link
Copy Markdown
Member

Close/reopen to restart CI

@scheibelp scheibelp closed this Jun 18, 2021
@scheibelp scheibelp reopened this Jun 18, 2021
@alalazo alalazo enabled auto-merge (squash) June 18, 2021 13:51
@alalazo alalazo merged commit 32f1aa6 into spack:develop Jun 18, 2021
@alalazo alalazo deleted the features/spack_audit branch June 18, 2021 13:52
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 18, 2021

Thanks @scheibelp !

bollig pushed a commit to bollig/spack that referenced this pull request Jun 29, 2021
Add a new "spack audit" command. This command can check for issues
with configuration or with packages and is intended to help a
user debug a failed Spack build. 

In some cases the reported issues are always errors but are too
costly to check for (e.g. packages that specify missing variants on
dependencies). In other cases the issues may be legitimate but
uncommon usage of Spack and we want to be sure the user intended the
behavior (e.g. duplicate compiler definitions).

Audits are grouped by theme, and for now the two themes are packages
and configuration. For example you can run all available audits
on packages with "spack audit packages". It is intended that in
the future users will be able to define their own audits.

The package audits are good candidates for running in package_sanity
(i.e. they could catch bugs in user-submitted packages before they
are merged) but that is left for a later PR.
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.

2 participants