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

Support HTTP Websocket Connections in wsclient #899

Merged
merged 2 commits into from
Jul 21, 2017

Conversation

dastbe
Copy link
Contributor

@dastbe dastbe commented Jul 21, 2017

Summary

This pull requests allows the wsclient (and therefore acs and tcs) to connect over http and upgrade to a plain websocket connection.

Implementation details

wss (secure websocket) was hardcoded. This change makes a determination based on http or https. Maybe there will be some crazy httpX in the future so I made it a switch.

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New tests cover the changes: yes

Description for the changelog

Enhancement - Allow plain HTTP connections through wsclient

Licensing

This contribution is under the terms of the Apache 2.0 License: yes

Copy link
Contributor

@petderek petderek left a comment

Choose a reason for hiding this comment

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

Should we gate this code path with an 'allowUnsecureACS' option? I don't think we want this enabled by default.

@@ -349,6 +350,19 @@ func (cs *ClientServerImpl) handleMessage(data []byte) {
}
}

func websocketScheme(httpScheme string) (wsScheme string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, we've avoided using named returns. Please change this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

case "https":
wsScheme = "wss"
default:
err = fmt.Errorf("Unknown httpScheme %s", httpScheme)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use format $context: msg and package errors.New()

errors.New("wsclient: Unknown httpScheme %s", httpScheme)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// TODO replace with gomock
func StartMockServer(t *testing.T, closeWS <-chan []byte) (*httptest.Server, chan<- string, <-chan string, <-chan error, error) {
func GetMockServer(t *testing.T, closeWS <-chan []byte) (*httptest.Server, chan<- string, <-chan string, <-chan error, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Should we gate this code path with an 'allowUnsecureACS' option?"

So my argument against is that we do allow using an http endpoint to talk to ECS via the SDK. If there were a flag, it should apply to both.

@samuelkarp
Copy link
Contributor

Should we gate this code path with an 'allowUnsecureACS' option? I don't think we want this enabled by default.

I'm somewhat okay with it being ungated since the endpoint is not actually configurable; you only get the endpoint from the result of a DiscoverPollEndpoint call.

@samuelkarp samuelkarp merged commit bc27acb into aws:dev Jul 21, 2017
@jhaynes jhaynes mentioned this pull request Aug 22, 2017
@samuelkarp samuelkarp added this to the 1.14.4 milestone Aug 22, 2017
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.

3 participants