Remove kube and scshutdown endpoint
This commit is contained in:
		
							parent
							
								
									e9d24dc5ff
								
							
						
					
					
						commit
						79a05909d5
					
				
					 5 changed files with 2 additions and 218 deletions
				
			
		|  | @ -199,43 +199,6 @@ class SuperUserSetupDatabase(ApiResource): | |||
|         abort(403) | ||||
| 
 | ||||
| 
 | ||||
| # From: https://stackoverflow.com/a/44712205 | ||||
| def get_process_id(name): | ||||
|     """Return process ids found by (partial) name or regex. | ||||
| 
 | ||||
|     >>> get_process_id('kthreadd') | ||||
|     [2] | ||||
|     >>> get_process_id('watchdog') | ||||
|     [10, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61]  # ymmv | ||||
|     >>> get_process_id('non-existent process') | ||||
|     [] | ||||
|     """ | ||||
|     child = subprocess.Popen(['pgrep', name], stdout=subprocess.PIPE, shell=False) | ||||
|     response = child.communicate()[0] | ||||
|     return [int(pid) for pid in response.split()] | ||||
| 
 | ||||
| 
 | ||||
| @resource('/v1/superuser/shutdown') | ||||
| class SuperUserShutdown(ApiResource): | ||||
|     """ Resource for sending a shutdown signal to the container. """ | ||||
| 
 | ||||
|     @nickname('scShutdownContainer') | ||||
|     def post(self): | ||||
|         """ Sends a signal to the phusion init system to shut down the container. """ | ||||
|         # Note: This method is called to set the database configuration before super users exists, | ||||
|         # so we also allow it to be called if there is no valid registry configuration setup. | ||||
| 
 | ||||
|         if app.config['TESTING'] or not database_has_users(): | ||||
|             # Note: We skip if debugging locally. | ||||
|             if app.config.get('DEBUGGING') == True: | ||||
|                 return {} | ||||
| 
 | ||||
|             os.kill(get_process_id('my_init')[0], signal.SIGINT) | ||||
|             return {} | ||||
| 
 | ||||
|         abort(403) | ||||
| 
 | ||||
| 
 | ||||
| @resource('/v1/superuser/config/createsuperuser') | ||||
| class SuperUserCreateInitialSuperUser(ApiResource): | ||||
|     """ Resource for creating the initial super user. """ | ||||
|  |  | |||
		Reference in a new issue