@@ -1137,7 +1137,13 @@ def _spawn_minions(self, timeout=60):
11371137
11381138 beacons_leader = True
11391139 for master in masters :
1140- s_opts = copy .deepcopy (self .opts )
1140+ # Use OptsDict copy-on-write instead of deepcopy
1141+ # Only master, multimaster, and beacons_leader are mutated
1142+ # Grains, pillar, and other large dicts are shared via copy-on-write
1143+ # self.opts is guaranteed to be OptsDict (set by MinionBase.__init__)
1144+ from salt .utils .optsdict import OptsDict
1145+
1146+ s_opts = OptsDict .from_parent (self .opts , name = f"minion_manager:{ master } " )
11411147 s_opts ["master" ] = master
11421148 s_opts ["multimaster" ] = True
11431149 s_opts ["beacons_leader" ] = beacons_leader
@@ -1697,7 +1703,12 @@ def _load_modules(
16971703 self .utils = salt .loader .utils (opts , proxy = proxy , context = context )
16981704
16991705 if opts .get ("multimaster" , False ):
1700- s_opts = copy .deepcopy (opts )
1706+ # Use OptsDict copy-on-write instead of deepcopy
1707+ # Loader already handles OptsDict, so this is safe
1708+ # opts is guaranteed to be OptsDict (set by MinionBase.__init__ via super().__init__)
1709+ from salt .utils .optsdict import OptsDict
1710+
1711+ s_opts = OptsDict .from_parent (opts , name = "minion_multimaster_loader" )
17011712 functions = salt .loader .minion_mods (
17021713 s_opts ,
17031714 utils = self .utils ,
0 commit comments