Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Implemented timeout for requests targetting the registry
Browse files Browse the repository at this point in the history
Fixes #1113

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Oct 4, 2017
1 parent 9f8150f commit 9296f1e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ registry:
catalog_page:
value: 100

# Set the timeout in seconds for requests to the registry. Only change this
# value if you are *really* sure that you have an exceptionally slow
# connection to your private Docker registry.
timeout:
value: 2

# The FQDN of the machine where Portus is being deployed.
machine_fqdn:
value: "portus.test.lan"
Expand Down
5 changes: 4 additions & 1 deletion lib/portus/http_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def parse_unhauthorized_response(res)
# Performs an HTTP request to the given URI and request object. It returns an
# HTTP response that has been sent from the registry.
def get_response_token(uri, req)
options = { use_ssl: uri.scheme == "https", open_timeout: 2 }
options = {
use_ssl: uri.scheme == "https",
open_timeout: APP_CONFIG["registry"]["timeout"]["value"].to_i
}

Net::HTTP.start(uri.hostname, uri.port, options) do |http|
http.request(req)
Expand Down
7 changes: 7 additions & 0 deletions packaging/suse/portusctl/lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,20 @@ class Cli < Thor
# JWT EXPIRATION TIME
option "jwt-expiration-time",
desc: "Expiration time for the JWT token used by Portus",
type: :numeric,
default: 5

# Catalog pagination
option "catalog-page",
desc: "Pagination value for API calls to the registry",
type: :numeric,
default: 100

option "registry-timeout-value",
desc: "Timeout value for API calls to the registry",
type: :numeric,
default: 10

# FIRST USER
option "first-user-admin-enable",
desc: "Make the first registered user an admin",
Expand Down
3 changes: 3 additions & 0 deletions packaging/suse/portusctl/man/man1/portusctl-setup.1
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ your Docker registry. It defaults to 5 minutes.
Set a custom pagination value to be used for API calls with the registry. Only
set this value if you \fIreally\fP know what you are doing.
.TP
\fB\-\-registry\-timeout\-value\fP
Timeout value for API calls to the registry.
.TP
\fB\-\-first\-user\-admin\-enable\fP
When enabled, the first user to register into Portus will become an
administrator. It's enabled by default.
Expand Down
3 changes: 3 additions & 0 deletions packaging/suse/portusctl/man/markdown/portusctl-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ first time.
Set a custom pagination value to be used for API calls with the registry. Only
set this value if you *really* know what you are doing.

**--registry-timeout-value**
Timeout value for API calls to the registry.

**--first-user-admin-enable**
When enabled, the first user to register into Portus will become an
administrator. It's enabled by default.
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
# set
APP_CONFIG["registry"] = {
"jwt_expiration_time" => { "value" => 5 },
"catalog_page" => { "value" => 100 }
"catalog_page" => { "value" => 100 },
"timeout" => { "value" => 2 }
}

APP_CONFIG["user_permission"] = {
Expand Down

0 comments on commit 9296f1e

Please sign in to comment.