Skip to content

Commit

Permalink
Set shorter syncthing timeouts (#952)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chico de Guzman <pchico83@gmail.com>
  • Loading branch information
pchico83 committed Jun 25, 2020
1 parent fc9f957 commit c15cdd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/k8s/pods/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func ListBySelector(namespace string, selector map[string]string, c kubernetes.I
// GetDevPodInLoop returns the dev pod for a deployment and loops until it success
func GetDevPodInLoop(ctx context.Context, dev *model.Dev, c *kubernetes.Clientset, waitUntilDeployed bool) (*apiv1.Pod, error) {
ticker := time.NewTicker(500 * time.Millisecond)
to := 2 * config.GetTimeout() // 60 seconds
to := 4 * config.GetTimeout() // 120 seconds
timeout := time.Now().Add(to)

for i := 0; ; i++ {
Expand Down
5 changes: 5 additions & 0 deletions pkg/syncthing/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ func (s *Syncthing) APICall(ctx context.Context, url, method string, code int, p
var urlPath string
if local {
urlPath = path.Join(s.GUIAddress, url)
s.Client.Timeout = 2 * time.Second
} else {
urlPath = path.Join(s.RemoteGUIAddress, url)
s.Client.Timeout = 5 * time.Second
}
if url == "rest/events" || url == "rest/db/completion" {
s.Client.Timeout = 20 * time.Second
}

req, err := http.NewRequest(method, fmt.Sprintf("http://%s", urlPath), bytes.NewBuffer(body))
Expand Down

0 comments on commit c15cdd0

Please sign in to comment.