On Thu, May 21, 2015 at 11:24:19AM +0200, 'BSRK Aditya' via ganeti-devel wrote: > They include updateCluster, updateNode, > updateInstance, updateNodegroup, updateNetwork, > updateDisk. > > Signed-off-by: BSRK Aditya <[email protected]> > --- > src/Ganeti/WConfd/ConfigModifications.hs | 125 > +++++++++++++++++++++++++++++- > 1 file changed, 124 insertions(+), 1 deletion(-)
> +-- | Updates an object present in a container. > +-- The presense of the object in the container > +-- is determined by the uuid of the object. > +-- > +-- A check that serial number of the > +-- object is consistent with the serial number > +-- of the object in the container is performed, > +-- unless the objects are identical (excluding > +-- serial number, and modification time). > +-- > +-- If the check passes, the object's serial number > +-- is incremented, and modification time is updated, > +-- and then is inserted into the container. > +replaceIn :: (Eq a, UuidObject a, TimeStampObjectL a, SerialNoObjectL a) > + => ClockTime > + -> a > + -> Container a > + -> GenericResult GanetiException (Container a) > +replaceIn now target = alterContainerL (uuidOf target) extract > + where extract Nothing = Bad $ ConfigurationError > + "Configuration object unknown" > + extract (Just current) = do > + unless (isIdentical now target current) $ checkSerial target > current > + return . Just . (serialL %~ (+1)) . (mTimeL .~ now) $ target Here the logic is wrong. If we find that the update is already included we should not change anything. Also note that not chaning anything also applies to the operations that bump the cluster serial as a side effect (like updateNode). So it might be the easiest to branch on the isIdentical check directly in the update* functions. Thanks, Klaus -- Klaus Aehlig Google Germany GmbH, Dienerstr. 12, 80331 Muenchen Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores
