It's True if there was at least one ssconf upload error. We could use
something like ssconf_upload_error_occurred.

Maybe a more descriptive way would be to instead have a variable holding
failed result items, something along the lines of:

diff --git a/lib/config.py b/lib/config.py
index 3f5b56e..b796665 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -2515,22 +2515,28 @@ class ConfigWriter(object):
     ssconf = self._UnlockedGetSsconfValues()
     if ssconf != self._last_written_ssconf:
       logging.debug("Ssconf changed, distributing")
+      failed_items = []
       if not self._offline:
         result = self._GetRpc(None).call_write_ssconf_files(
           self._UnlockedGetNodeNames(self._UnlockedGetOnlineNodeList()),
           ssconf)
+        failed_items = [(nname, nresu) for nname, nresu in result.items()
+                                       if nresu.fail_msg]

-        for nname, nresu in result.items():
-          msg = nresu.fail_msg
-          if msg:
-            errmsg = ("Error while uploading ssconf files to"
-                      " node %s: %s" % (nname, msg))
-            logging.warning(errmsg)
+        for nname, nresu in failed_items:
+          errmsg = ("Error while uploading ssconf files to"
+                    " node %s: %s" % (nname, msg))
+          logging.warning(errmsg)

-            if feedback_fn:
-              feedback_fn(errmsg)
+          if feedback_fn:
+            feedback_fn(errmsg)

-      self._last_written_ssconf = ssconf
+      # If any of the upload operations failed, reset the marker so that we
+      # try to upload everything again at the next write.
+      if failed_items:
+        self._last_written_ssconf = {}
+      else:
+        self._last_written_ssconf = ssconf
     else:
       logging.debug("Ssconf unchanged")



On Fri, Jan 17, 2014 at 1:29 PM, Guido Trotter <[email protected]> wrote:

> On Wed, Jan 15, 2014 at 10:23 AM, Petr Pudlak <[email protected]> wrote:
> > This ensures that every node gets its ssconf copy as soon as possible.
> >
> > Signed-off-by: Petr Pudlak <[email protected]>
> > ---
> >  lib/config.py | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/config.py b/lib/config.py
> > index 3f5b56e..45cf7a7 100644
> > --- a/lib/config.py
> > +++ b/lib/config.py
> > @@ -2515,6 +2515,7 @@ class ConfigWriter(object):
> >      ssconf = self._UnlockedGetSsconfValues()
> >      if ssconf != self._last_written_ssconf:
> >        logging.debug("Ssconf changed, distributing")
> > +      uploaderr = False
>
> What does uploaderr stand for? Can we use a more descriptive name?
>
> Thanks,
>
> Guido
>
>
> >        if not self._offline:
> >          result = self._GetRpc(None).call_write_ssconf_files(
> >            self._UnlockedGetNodeNames(self._UnlockedGetOnlineNodeList()),
> > @@ -2523,6 +2524,7 @@ class ConfigWriter(object):
> >          for nname, nresu in result.items():
> >            msg = nresu.fail_msg
> >            if msg:
> > +            uploaderr = True
> >              errmsg = ("Error while uploading ssconf files to"
> >                        " node %s: %s" % (nname, msg))
> >              logging.warning(errmsg)
> > @@ -2530,7 +2532,12 @@ class ConfigWriter(object):
> >              if feedback_fn:
> >                feedback_fn(errmsg)
> >
> > -      self._last_written_ssconf = ssconf
> > +      # If any of the upload operations failed, reset the marker so
> that we
> > +      # try to upload everything again at the next write.
> > +      if uploaderr:
> > +        self._last_written_ssconf = {}
> > +      else: # all OK
> > +        self._last_written_ssconf = ssconf
> >      else:
> >        logging.debug("Ssconf unchanged")
> >
> > --
> > 1.8.5.2
> >
>
>
>
> --
> Guido Trotter
> Ganeti Engineering
> Google Germany GmbH
> Dienerstr. 12, 80331, München
>
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschäftsführer: Graham Law, Christine Elizabeth Flores
> Steuernummer: 48/725/00206
> Umsatzsteueridentifikationsnummer: DE813741370
>

Reply via email to