MCPcopy Index your code
hub / github.com/saltstack/salt / start

Method start

salt/master.py:1008–1230  ·  view source on GitHub ↗

Turn on the master server components

(self)

Source from the content-addressed store, hash-verified

1006 return salt.crypt.Crypticle.read_key(path)
1007
1008 def start(self):
1009 """
1010 Turn on the master server components
1011 """
1012 self._pre_flight()
1013 log.info("salt-master is starting as user '%s'", salt.utils.user.get_user())
1014
1015 # Wipe stale health-probe sentinels from any previous run before
1016 # subprocesses come up, so a probe cannot pass on data from the
1017 # last incarnation. Failures are logged but non-fatal.
1018 salt.cluster.healthchecks.reset_health_dir(self.opts)
1019
1020 enable_sigusr1_handler()
1021 enable_sigusr2_handler()
1022
1023 self.__set_max_open_files()
1024
1025 # Configure OpenTelemetry metrics for the master parent process and
1026 # register the observable gauges (connected_minions, workers
1027 # queue depth, process open_fds). Observable gauges *must* be
1028 # registered exactly once, in the parent — registering them in
1029 # MWorker children would over-count. Workers call configure
1030 # again in ``MWorker.run`` but skip the observables.
1031 salt.utils.metrics.configure({**self.opts, "__role": "master"})
1032 # Cross-process counter for "MWorker payloads in flight". Created
1033 # here so all forked workers inherit the same shared memory. Stashed
1034 # at module level so ``MWorker._handle_payload`` can read it without
1035 # a constructor change.
1036 global _WORKERS_INFLIGHT # pylint: disable=global-statement
1037 _WORKERS_INFLIGHT = multiprocessing.Value("i", 0)
1038 _register_master_observables(self.opts, _WORKERS_INFLIGHT)
1039
1040 # Reset signals to default ones before adding processes to the process
1041 # manager. We don't want the processes being started to inherit those
1042 # signal handlers
1043 with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
1044 # Setup the secrets here because the PubServerChannel may need
1045 # them as well.
1046 self.populate_secrets()
1047
1048 log.info("Creating master process manager")
1049 # Since there are children having their own ProcessManager we should wait for kill more time.
1050 self.process_manager = salt.utils.process.ProcessManager(wait_for_kill=5)
1051
1052 log.info("Creating master event publisher process")
1053 ipc_publisher = salt.channel.server.MasterPubServerChannel.factory(
1054 self.opts,
1055 )
1056 ipc_publisher.pre_fork(self.process_manager)
1057 if not ipc_publisher.transport.started.wait(30):
1058 raise salt.exceptions.SaltMasterError(
1059 "IPC publish server did not start within 30 seconds. Something went wrong."
1060 )
1061
1062 ipc_publisher.send_aes_key_event()
1063
1064 # If this master has no cluster private key yet, it has not
1065 # completed a join handshake and needs to run the discover->join

Callers 12

salt_masterFunction · 0.95
runMethod · 0.45
_startMethod · 0.45
_send_ssh_pubMethod · 0.45
minion_processFunction · 0.45
salt_minionFunction · 0.45
proxy_minion_processFunction · 0.45
salt_proxyFunction · 0.45
_invoke_executionMethod · 0.45
add_periodic_callbackMethod · 0.45
tune_inMethod · 0.45
core.min.jsFile · 0.45

Calls 15

_pre_flightMethod · 0.95
__set_max_open_filesMethod · 0.95
_run_with_heartbeatMethod · 0.95
enable_sigusr1_handlerFunction · 0.90
enable_sigusr2_handlerFunction · 0.90
iter_transport_optsFunction · 0.90
configureMethod · 0.80
populate_secretsMethod · 0.80
waitMethod · 0.80
send_aes_key_eventMethod · 0.80
_has_joined_clusterMethod · 0.80

Tested by

no test coverage detected