Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

api: support cAPI.UnitState() for a single unit #1679

Merged

Commits on Nov 7, 2016

  1. api: support GET method for stateResource

    HTTP client should be able to retrieve a unit state via
    URL like http://*/state/unitName.
    Support GET for stateResource just like unitResource.
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    76c43f9 View commit details
    Browse the repository at this point in the history
  2. schema: introduce Get method for UnitState

    Define Get method for UnitState in the schema, and regenerate both
    json and go.
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    826f9c5 View commit details
    Browse the repository at this point in the history
  3. client: introduce UnitState() for API interface

    Introduce UnitState() for API interface as well as HTTPClient struct.
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    ead9372 View commit details
    Browse the repository at this point in the history
  4. protobuf: define GetUnitState() for registryClient

    Protobuf must also its own method GetUnitState().
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    7afdc1d View commit details
    Browse the repository at this point in the history
  5. registry: introduce UnitState() for etcdRegistry and RPCRegistry

    UnitState() needs to be defined for etcdRegistry, RPCRegistry, and
    *RegistryMux*. Also inmemoryRegistry() needs to have UnitState().
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    43e23ef View commit details
    Browse the repository at this point in the history
  6. fleetctl: replace cAPI.UnitStates() with .UnitState()

    Now fleetctl should be able to retrieve a unit state, using
    cAPI.UnitState().
    Also get rid of getSingleUnitState() to simplify the logic.
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    2133db7 View commit details
    Browse the repository at this point in the history
  7. registry: add new unit tests for GetUnitState() and relevant ones

    We should add new unit tests like TestUnitState() as well as
    TestInMemoryUnitState(), to cover the new cases like
    EtcdRegistry.UnitState() or inmemoryRegistry.UnitState().
    Dongsu Park committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    8aa001f View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2016

  1. fleetctl: periodically check for systemd states using waitForState

    Although checkSystemdActiveState() doesn't have to depend on
    cAPI.UnitStates(), it's still impossible to remove additional sleep
    in case of error from assertSystemdActiveState(). That's actually a
    known issue. Sometimes it simply takes much time until fleetctl became
    able to get valid unit states. Adding additional sleeps or tuning the
    sleep time wouldn't be a good approach, as an optimal sleep interval
    could vary a lot case by case.
    
    To gracefully handle this case, let's do similar checking as done in
    functional tests.
    
    * Introduce a new helper waitForState(), just like util.WaitForState()
      from functional tests.
    * Squash assertFetchSystemdActiveState() into assertSystemdActiveState()
      to make it retry the assertion periodically up to defaultSleepTime.
    * Increase defaultSleepTime from 500 to 2000 msec.
    * Remove the additional sleep call as well as cAPI.UnitState() call.
    Dongsu Park committed Nov 9, 2016
    Configuration menu
    Copy the full SHA
    57443ca View commit details
    Browse the repository at this point in the history
  2. fleetctl: make use of waitForState also in assertUnitState()

    waitForUnitState() has been making use of an additional sleep, in case
    assertUnitState() returned error. Now that a helper waitForState() is
    available for fleetctl, we don't need to sleep there.
    
    So remove the sleep calls, and instead make assertUnitState() a wrapper
    of waitForState() over fetchUnitState(). That way, assertUnitState()
    can periodically retry to get a unit, up to defaultSleepTime.
    This is also good for consistency in the entire code, as
    assertSystemdActiveState() already depends on waitForState().
    Dongsu Park committed Nov 9, 2016
    Configuration menu
    Copy the full SHA
    9137746 View commit details
    Browse the repository at this point in the history