MCPcopy
hub / github.com/saltstack/salt / fill_buckets

Method fill_buckets

salt/master.py:706–757  ·  view source on GitHub ↗

Get the configured backends and the intervals for any backend which supports them, and set up the update "buckets". There will be one bucket for each thing being updated at a given interval.

(self)

Source from the content-addressed store, hash-verified

704 self.fill_buckets()
705
706 def fill_buckets(self):
707 """
708 Get the configured backends and the intervals for any backend which
709 supports them, and set up the update "buckets". There will be one
710 bucket for each thing being updated at a given interval.
711 """
712 update_intervals = self.fileserver.update_intervals()
713 self.buckets = {}
714 for backend in self.fileserver.backends():
715 fstr = f"{backend}.update"
716 try:
717 update_func = self.fileserver.servers[fstr]
718 except KeyError:
719 log.debug("No update function for the %s filserver backend", backend)
720 continue
721 if backend in update_intervals:
722 # Variable intervals are supported for this backend
723 for id_, interval in update_intervals[backend].items():
724 if not interval:
725 # Don't allow an interval of 0
726 interval = DEFAULT_INTERVAL
727 log.debug(
728 "An update_interval of 0 is not supported, "
729 "falling back to %s",
730 interval,
731 )
732 i_ptr = self.buckets.setdefault(interval, OrderedDict())
733 # Backend doesn't technically need to be present in the
734 # key, all we *really* need is the function reference, but
735 # having it there makes it easier to provide meaningful
736 # debug logging in the update threads.
737 i_ptr.setdefault((backend, update_func), []).append(id_)
738 else:
739 # Variable intervals are not supported for this backend, so
740 # fall back to the global interval for that fileserver. Since
741 # this backend doesn't support variable updates, we have
742 # nothing to pass to the backend's update func, so we'll just
743 # set the value to None.
744 try:
745 interval_key = f"{backend}_update_interval"
746 interval = self.opts[interval_key]
747 except KeyError:
748 interval = DEFAULT_INTERVAL
749 log.warning(
750 "%s key missing from configuration. Falling back to "
751 "default interval of %d seconds",
752 interval_key,
753 interval,
754 )
755 self.buckets.setdefault(interval, OrderedDict())[
756 (backend, update_func)
757 ] = None
758
759 @staticmethod
760 def _do_update(backends):

Callers 1

__init__Method · 0.95

Calls 7

backendsMethod · 0.80
debugMethod · 0.80
warningMethod · 0.80
update_intervalsMethod · 0.45
itemsMethod · 0.45
setdefaultMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected