Skip to content

Restrict some scap subcommands to deploy servers only

All of the relevant subcommands were already marked with
"affected_by_blocked_deployments", so I renamed this flag to
"primary_deploy_server_only". If this flag is set on a subcommand, a
check is performed to see if the hostname begins with "deploy" before
allowing the command.

Before:  
user@mwmaint1002:/srv/mediawiki-staging$ scap backport 1038310  
14:28:19 Unhandled error:  
Traceback (most recent call last):  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/cli.py", line 553, in run  
    exit_status = app.main(app.extra_arguments)  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/plugins/backport.py", line 309, in main  
    self.gerrit,  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/plugins/backport.py", line 88, in __init__  
    self.config_repos = self._get_submodules_paths(self.mediawiki_location)  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/plugins/backport.py", line 94, in _get_submodules_paths  
    paths_urls = git.list_submodules_paths_urls(location, "--recursive")  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/git.py", line 652, in list_submodules_paths_urls  
    ensure_dir(repo)  
  File "/var/lib/scap/scap/lib/python3.7/site-packages/scap/git.py", line 312, in ensure_dir  
    raise IOError(errno.ENOENT, "Location is not a git repo", location)  
FileNotFoundError: [Errno 2] Location is not a git repo: '/srv/mediawiki-staging'  
14:28:19 backport failed: <FileNotFoundError> [Errno 2] Location is not a git repo: '/srv/mediawiki-staging'  
  
After:  
user@mwmaint1002:/srv/mediawiki-staging$ scap backport 1038310  
Aborting: This scap command can only be used on a deploy server.  

Bug: T366480

Merge request reports