Merge pull request #14377 from derekwaynecarr/improve_vagrant_node_stability
Vagrant salt-minion should have low oom_score_adj and restart policy
This commit is contained in:
		@@ -307,6 +307,28 @@ if ! which salt-minion >/dev/null 2>&1; then
 | 
				
			|||||||
  # Install Salt minion
 | 
					  # Install Salt minion
 | 
				
			||||||
  curl -sS -L --connect-timeout 20 --retry 6 --retry-delay 10 https://bootstrap.saltstack.com | sh -s
 | 
					  curl -sS -L --connect-timeout 20 --retry 6 --retry-delay 10 https://bootstrap.saltstack.com | sh -s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Edit the Salt minion unit file to do restart always
 | 
				
			||||||
 | 
					  # needed because vagrant uses this as basis for registration of nodes in cloud provider
 | 
				
			||||||
 | 
					  # set a oom_score_adj to -999 to prevent our node from being killed with salt-master and then making kubelet NotReady
 | 
				
			||||||
 | 
					  # because its not found in salt cloud provider call
 | 
				
			||||||
 | 
					  cat <<EOF >/usr/lib/systemd/system/salt-minion.service 
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=The Salt Minion
 | 
				
			||||||
 | 
					After=syslog.target network.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/salt-minion
 | 
				
			||||||
 | 
					Restart=Always
 | 
				
			||||||
 | 
					OOMScoreAdjust=-999
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  systemctl daemon-reload
 | 
				
			||||||
 | 
					  systemctl restart salt-minion.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  # Only run highstate when updating the config.  In the first-run case, Salt is
 | 
					  # Only run highstate when updating the config.  In the first-run case, Salt is
 | 
				
			||||||
  # set up to run highstate as new minions join for the first time.
 | 
					  # set up to run highstate as new minions join for the first time.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,6 +163,29 @@ swapoff -a
 | 
				
			|||||||
if ! which salt-minion >/dev/null 2>&1; then
 | 
					if ! which salt-minion >/dev/null 2>&1; then
 | 
				
			||||||
  # Install Salt
 | 
					  # Install Salt
 | 
				
			||||||
  curl -sS -L --connect-timeout 20 --retry 6 --retry-delay 10 https://bootstrap.saltstack.com | sh -s
 | 
					  curl -sS -L --connect-timeout 20 --retry 6 --retry-delay 10 https://bootstrap.saltstack.com | sh -s
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  # Edit the Salt minion unit file to do restart always
 | 
				
			||||||
 | 
					  # needed because vagrant uses this as basis for registration of nodes in cloud provider
 | 
				
			||||||
 | 
					  # set a oom_score_adj to -999 to prevent our node from being killed with salt-master and then making kubelet NotReady
 | 
				
			||||||
 | 
					  # because its not found in salt cloud provider call
 | 
				
			||||||
 | 
					  cat <<EOF >/usr/lib/systemd/system/salt-minion.service 
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=The Salt Minion
 | 
				
			||||||
 | 
					After=syslog.target network.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/salt-minion
 | 
				
			||||||
 | 
					Restart=Always
 | 
				
			||||||
 | 
					OOMScoreAdjust=-999
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  systemctl daemon-reload
 | 
				
			||||||
 | 
					  systemctl restart salt-minion.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  # Sometimes the minion gets wedged when it comes up along with the master.
 | 
					  # Sometimes the minion gets wedged when it comes up along with the master.
 | 
				
			||||||
  # Restarting it here un-wedges it.
 | 
					  # Restarting it here un-wedges it.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user