concept approval in category system administration

appears as: pprovals, pproval, approval, n approval, approvals
Operations Anti-Patterns DevOps Solutions

This is an excerpt from Manning's book Operations Anti-Patterns DevOps Solutions.

In some organizations there is a group or groups that seem to wield outsized power relative to their peers. The power is sometimes granted or enforced through things like access controls or approvals. The operations group that refuses to allow changes to systems without an extensive review process. The security team that prevents teams from adopting technology created after 1984. The development group that refuses to build tools that allows people to make changes without their watchful eye. The rules or mandates can typically be traced back to some inciting event that justified draconian action. But the very thing that was supposed to make the teams more effective instead drags them to a crawl. If you’ve seen this in your own company or teams, you’re not alone. I call this the paternalist syndrome, named after the parental like figure one group assumes over others.

Each of these needs to be represented programmatically somehow. But a major area of concern is that each of these checks might be radically different. Despite these differences, you’ll want to be able to treat them more or less the same. This allows you to add new checks easily. In order to accomplish this, using a base class for approvals is a good idea. The base class can require that all inherited approval classes follow a similar structure. The most useful pattern you’d want is for all approvals to report approval or denial in the same way. This allows you to check many approval types without needing to know the intricacies of the approval you’re checking against.

Listing 2.1 Define a base class for your approvals
class BaseApproval: //#A
def is_approved(self): //#B
raise NotImplementedError() //#C
def error_message(self): //#D
raise NotImplementedError()

With the base class defined, you can inherit from this class for your individual approvals. Treat the approval like an abstract class, where you’ll never instantiate it directly, only via inheritance. The goal with the individual approvals is to create a list of objects that you will be able to instantiate and call in order to ensure the approvals have been met.

With the base class defined all approvals inherit from the base class. This makes sure that the approvals all define the is_approved method for easier success checking. For example, the peer review requirement would be built into its own approval named PeerApproval. This allows you to put all of the logic necessary to check that a request has been peer approved into a single place. The is_approved method for the PeerApproval class performs the approval checking logic specific to that type of approval and a value indicating approval or denial. But this logic is all contained within the PeerApproval class and thanks to the is_approved method being well defined, anyone using it doesn’t need to know the specific internals of the approval.