-
Notifications
You must be signed in to change notification settings - Fork 602
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
Refactor ACS payload message handling #3840
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RichaGangwar
reviewed
Aug 8, 2023
Realmonia
reviewed
Aug 8, 2023
danehlim
force-pushed
the
payload-responder
branch
from
August 9, 2023 22:16
e2199b4
to
4539418
Compare
Realmonia
approved these changes
Aug 9, 2023
RichaGangwar
approved these changes
Aug 10, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. :)
danehlim
force-pushed
the
payload-responder
branch
from
August 10, 2023 17:25
4539418
to
95551a8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor ACS payload message handling, update other associated code, and improve/update tests.
Implementation details
agent/acs/handler/payload_handler.go
->ecs-agent/acs/session/payload_responder.go
(partial)payloadRequestHandler
struct and existing code intopayloadResponder
struct, such thatpayloadResponder
struct implements thewsclient.RequestResponder
interfacevalidatePayloadMessage
function to do some ACS payload message validation upfrontProcessMessage
method of the responder'sPayloadMessageHandler
github.com/aws/amazon-ecs-agent/ecs-agent/logger
instead ofgithub.com/cihub/seelog
for loggingerrors.Errorf
in favor offmt.Errorf
handleUnrecognizedTask
to more suitable namehandleInvalidTask
agent/acs/handler/payload_handler.go
->agent/acs/handler/payload_responder.go
(partial)payloadMessageHandler
struct such thatpayloadMessageHandler
struct implements thePayloadMessageHandler
interface defined inecs-agent/acs/session/payload_responder.go
github.com/aws/amazon-ecs-agent/ecs-agent/logger
instead ofgithub.com/cihub/seelog
for loggingagent/acs/handler/acs_handler.go
HandlerFunc
function as a request handler to the ACS client, such that payload responder dictates what to do in response to receiving payload messages from ACSpayloadMessageBufferSize
constant since they are no longer applicable/used after the refactor of ACS payload message handlingstart()
,stop()
,clearAcks()
, etc. can be removed. The resulting responder is a lot cleaner and simpler to follow.For reference see the following PR for a similar change previously made to the heartbeat responder for the same reason: Fix flakey leak test for ACS Handler #3232
ecs-agent/acs/session/generate_mocks.go
andecs-agent/acs/session/mocks/session_mock.go
PayloadMessageHandler
interface to be used in testingecs-agent/acs/logger/field/constants.go
agent/acs/handler/payload_handler_test.go
->ecs-agent/acs/session/payload_responder.go
(partial)agent/acs/handler/payload_handler_test.go
->agent/acs/handler/payload_responder_test.go
(partial)agent/acs/handler/acs_handler_test.go
agent/acs/handler/payload_handler_test.go
accordingly based off of above changes toagent/acs/handler/payload_handler.go
testconst.MessageID
test constant defined inecs-agent/acs/session/testconst/test_const.go
in favor ofpayloadMessageId
test constant currently defined inagent/acs/handler/payload_handler_test.go
Testing
Unit, integration, and functional tests.
New tests cover the changes: yes
Manually started and stopped task using a custom Agent with the changes from this pull request built into it. Both operations completed in a reasonable amount of time.
Description for the changelog
Refactor ACS payload message handling
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.