aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-07-01 15:01:22 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-07-01 15:01:22 +0200
commitd671e65bde10a92b58d40a50229ec28a5a75ee69 (patch)
tree72235203d850e6d0b5a417b207183dd9f8ed6a0f /bootstrap
parent98118d806331045d4035c0f6bfffdf151c6d553b (diff)
[CODESEARCH] Add option to define custom polling interval
The default polling interval is set to 1h. Refreshing too often might result in too many requests in time and a remote service disruption or denial of access for client (too many requests) Change-Id: I490792ddedeb7a2c13f1bbb0f11ec68ed8fc2d5b Issue-ID: INT-1942 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap/codesearch/create_config.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/bootstrap/codesearch/create_config.py b/bootstrap/codesearch/create_config.py
index 6d72f1725..4ff059d19 100755
--- a/bootstrap/codesearch/create_config.py
+++ b/bootstrap/codesearch/create_config.py
@@ -18,6 +18,7 @@ CODE_LOCATION = "{path}{anchor}"
GITWEB_ANCHOR = "#l{line}"
GIT_ANCHOR = "#n{line}"
+DEFAULT_POLL = 3600
def get_projects_list(gerrit):
"""Request list of all available projects from ONAP Gerrit."""
@@ -31,7 +32,7 @@ def get_projects_list(gerrit):
return projects.keys()
-def create_repos_list(projects, gerrit, ssh, git):
+def create_repos_list(projects, gerrit, ssh, git, poll):
"""Create a map of all projects to their repositories' URLs."""
gerrit_url = "https://{}{}".format(gerrit, API_PREFIX)
gerrit_project_url_base = "{}/{{}}.git".format(gerrit_url)
@@ -54,7 +55,8 @@ def create_repos_list(projects, gerrit, ssh, git):
"url": project_url,
"url-pattern": {
"base-url": code_url,
- "anchor": anchor
+ "anchor": anchor,
+ "ms-between-poll": poll * 1000
}
}
@@ -67,6 +69,7 @@ def parse_arguments():
parser.add_argument('--gerrit', help='Gerrit address', default=DEFAULT_GERRIT)
parser.add_argument('--ssh', help='SSH information: user, port', nargs=2)
parser.add_argument('--git', help='external git address')
+ parser.add_argument('--poll-interval', help='repositories polling interval in seconds', type=int, default=DEFAULT_POLL)
return parser.parse_args()
@@ -76,7 +79,7 @@ def main():
arguments = parse_arguments()
projects = get_projects_list(arguments.gerrit)
- repos = create_repos_list(projects, arguments.gerrit, arguments.ssh, arguments.git)
+ repos = create_repos_list(projects, arguments.gerrit, arguments.ssh, arguments.git, arguments.poll_interval)
config = {
"max-concurrent-indexers": 2,
"dbpath": "data",