Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deploy timeouts #174

Merged
merged 1 commit into from
Apr 20, 2017
Merged

Fix deploy timeouts #174

merged 1 commit into from
Apr 20, 2017

Conversation

aguerra
Copy link
Contributor

@aguerra aguerra commented Apr 18, 2017

Deploy is a streaming operation and we need the connection open even with the presence of firewalls or load balancers that have idle timeouts. As we don't control go-swagger autogenerated server we send a "ping" to the client every 30 seconds by default (this value may be changed using the TERESADEPLOY_KEEPALIVE_TIMEOUT env var).


This change is Reviewable

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [NEXT_RELEASE] ##
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- ## [NEXT_RELEASE] ##
+ ## [NEXT_RELEASE]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
fmt.Fprintln(w, "deploy finished with success")
w.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not defer w.Close() on start of anonymous function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍

lc.WithError(err).Error("error updating deployment")
fmt.Fprintln(w, "error when doing rolling update")
return
L:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about use Loop: instead of L: for this label ?
Maybe it will help us for a quick understand of this block of code

case <-time.After(deploymentConfig.KeepAliveTimeout):
fmt.Fprint(w, keepAliveMessage)
case <-done:
break L
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or you can simplify it using two break, one for select and another for for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to pick two breaks.

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [NEXT_RELEASE]
### Fixed
- Deploy timeouts by sending a "ping" to the client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this isn't clear.

defer close(done)

// parsing teresa.yaml and updating app
if err := parsingTeresaYaml(app, file.Data); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If parsing teresa.yaml fails, the deployment goroutine shouldn't be created in the first place. Maybe we should try and parse it before creating the deployment goroutine and pass the file.Data to the deployment goroutine.

Also, the name of the function that would parse the teresa.yaml would be something as parseTeresaYaml instead of parsingTeresaYaml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side effect, we would decrease the this creates code and logic, which would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you guys agree with that, please don't forget to add a defer closing the file.Data outside this goroutine - and sorry for the many comments in series.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you have just fixed a strange periodic S3 related bug with this last suggestion 👍

Deploy is a streaming operation and we need the connection open
even with the presence of firewalls or load balancers that have
idle timeouts. As we don't control go-swagger autogenerated server
we send a "ping" to the client every 30 seconds by default (this
value may be changed using the TERESADEPLOY_KEEPALIVE_TIMEOUT env var).
Copy link
Contributor

@drgarcia1986 drgarcia1986 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔁

@arnaldopereira arnaldopereira merged commit 41c7d78 into master Apr 20, 2017
@arnaldopereira arnaldopereira deleted the ag-fix-deploy-timeouts branch April 20, 2017 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants