Skip to content

Rig v2 - new design, renewed focus on applicability of project #51

@TurboTurtle

Description

@TurboTurtle

It's been a long time since rig has received any attention or updates. That's completely on me as I've been tied up with other projects at work that have taken me away from here.

In the interim however, I've been scoping out a new design for rig that makes it easier to extend and maintain, while also being easier on end users and more in-line with other modern tools.

New design

As things currently stand, rig is designed around the concept of "a rig watches for one condition and then does one or many actions in response". While simple in concept, the underlying code for building "a rig" was...not the cleanest design. CLI commands were conflated with the handling of rig creation at a fundamental level, which leads to extensibility issues.

The new design changes this by instead making a rig "the" backgrounded process from which one or many "monitors" may be launched and when any of those monitors detect their specified conditions, trigger one or many actions in response." In other words, whereas before we would have "a logs rig" that watches for specific messages, we now have "a rig that monitors logs for a message, and possibly monitors other things as well".

By making this abstraction, we can also re-arrange a number of code flows that makes it easier to establish new commands/new functionality, without having as large of knock-on effects on the whole project.

Further, with so many rigs specifying rig-specific options, the CLI experience was frankly, painful. One rig may use the --interface option, while another used --iface and another may have needed to use --ifname to all reference the same physical piece of hardware.

v2 will resolve this by transitioning to using yaml-formatted configuration files, or "rigfiles". Most similar to ansible playbooks, these rigfiles will serve as the way to configure new rigs on a system. Rather than having a CLI subcommand for each rig type, there will simply be a main rig create command which will specify a rigfile to use, and then we will parse that rigfile to configure and deploy a rig as described.

By moving to this kind of deployment model, we simplify a number of aspects of the project:

  • rigs/monitors no longer need to handle the parser themselves. We can standardize how options are defined and validated much easier
  • we no longer need to fumble with "enabling opts" to enable a rig, or munging around with various parser descriptions. By leveraging a yaml configuration, we can source the pertinent bits we need and compare that with what is supported by rig at that point in time.
  • monitors and actions will now be easier to create

An example of a rigfile that would have previously been deployed by a CLI command of rig logs --interval 5 --message 'this is my test message' --logfile='/var/log/messages','/var/log/foo/bar.log' --journals='foo' --count=5 --sosreport --only-plugins kernel,logs --initial-sos would be:

name: myrig
interval: 5
monitors:
  logs:
    message: this is my test message
    files:
      - /var/log/messages
      - /var/log/foo/bar.log
    journals: foo
    count: 5
actions:
  sos:
    report:
      initial_sos: true
      only_plugins:
        - kernel
        - logs

Which is far more grokable, and more reusable.

I am beginning these changes on the rig-v2 branch and will be working my way through transitioning the various monitors, actions, and commands to this new design. Once done, I'll flip the changes over to master (or rather, it will be main at that point most likely).

Comments, feedback, and suggestions are surely welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions