Add timestamps to Nodes, PCUs and Interfaces to make concrete
authorStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 2 Jul 2010 23:49:54 +0000 (19:49 -0400)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Fri, 2 Jul 2010 23:52:25 +0000 (19:52 -0400)
commitd15fad5be58c081c4ba49fbfa1f2ab0a48046ae3
tree6982c792232ce4add87e904e737b65d4c35ac3ba
parentbd8f4e7220c2c7dbdae92e4902e5715f28058fe6
Add timestamps to Nodes, PCUs and Interfaces to make concrete
statements about a node's configuration state.

Added:
    Node.last_boot             -- updated by BootUpdateNode()
    Node.last_download         -- updated by GetBootMedium()
    Node.last_pcu_reboot       -- updated by RebootNodeWithPCU()
    Node.last_pcu_confirmation -- updated by BootUpdateNode()
    Interface.last_updated     -- updated by UpdateInterface()
    PCU.last_updated           -- updated by UpdatePCU()

With these timestamps we can implement isValid() routines that indicate
whether the DB state is consistent with respect to the external deployment.
Previously, the DB state could be inconsistent, but there was no way to
identify this until runtime.  These checks should make it possible to validate
the DB state prior to runtime.

Also, isValid() is different from whether a node is online.  A node can be
offline and have a valid DB state.

For instance (in pseudocode):

    def Node.isValid():
        return Node.last_download < Node.last_boot &&
                Node.PCU.isValid(Node) &&
                Node.Interface.isValid(Node)

    def PCU.isValid(Node):
        return PCU.last_updated < Node.last_pcu_confirmation

    def Interface.isValid(Node):
        return Interface.last_updated < Node.last_download

In other words, if the primary interface for a node is updated more recently
than a bootimage is downloaded, then the DB configuration is out of sync with
the node deployment.

If the PCU is updated more recently than the last confirmed use of the PCU,
then the DB configuration is potentially out of sync with the deployment.

If the Node has downloaded a boot image prior to rebooting, then the DB config
is potentially out of sync with the deployment.

All of these states can be flagged in the GUI to help a technical contact
known the status of his configuration and deployment more easily.  The
recommended steps to take should be straight forward based on the conditions
above.  i.e. Create new boot image, reboot node, verify PCU, etc.
migrations/102-down-isvalid.sql [new file with mode: 0644]
migrations/102-up-isvalid.sql [new file with mode: 0644]