GithubHelp home page GithubHelp logo

isabella232 / layer-status Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juju-solutions/layer-status

0.0 0.0 0.0 19 KB

Juju base layer for managing charm status

License: Apache License 2.0

Python 100.00%

layer-status's Introduction

Overview

This layer provides helpers for managing charm status and ensuring that status set by different layers are resolved in a reasonable way.

Usage

The layer library provides helpers to make setting status a bit more friendly:

from charms.reactive import when_not

from charms.layer import status
from charms.layer import foo as charm_lib


@when('config.set.required-config')
@when_not('charm.foo.installed')
def install():
    status.maintenance('installing foo')
    charm_lib.do_install()
    status.active('foo is ready')


@when_not('config.set.required-config')
def missing_required_config():
    status.blocked('missing required-config')

More details can be found in the docs.

Conflict Resolution

More importantly, status can be set by different layers without worrying about conflicting with each other. For instance, if one layer (or the charm) sets the status to blocked and another layer sets the status to waiting or active, the status will end up with whichever was set most recently. This is further exacerbated by the fact that the order in which reactive handlers are invoked can be non-determinate and / or hard to reason about, especially across layers.

With this layer, blocked status takes precedence over waiting, which takes precedence over active, and competing statuses of the same level are handled in a consistent way based on the layer that set it. More specifically, conflicting statuses are resolved in the following way:

  • Maintenance status is always set immediately
  • Other statuses are queued to be set at the end of the hook execution
  • Blocked status will override waiting or active
  • Waiting status will override active
  • If a given status is set more than once, such as by different layers, then the charm layer will take precedence, or the layer latest in the built charm's includes list will take precedence, or the most recently set will be used (i.e., current behavior). (Note: The name of the layer setting the status will be determined by the name of the file containing the call, as per the convention of naming reactive or library files after the layer that contains them.)

Layer Options

To ensure that layers which use charmhelpers.core.hookenv.status_set function directly work well with this layer, it will be patched to go transparently go through this layer. On the off chance that the patching causes issues with some other layer, you can disable this behavior with the patch-hookenv layer option:

includes: ['layer:basic', 'layer:status', ...]
options:
  status:
    patch-hookenv: false

layer-status's People

Contributors

johnsca avatar hyperbolic2346 avatar tylerscheuble avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.