-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #350 from aws/1.5.x
1.5.x
- Loading branch information
Showing
22 changed files
with
3,738 additions
and
191 deletions.
There are no files selected for viewing
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
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
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
47 changes: 47 additions & 0 deletions
47
lib/instance_agent/plugins/codedeploy/command_acknowledgement_request_builder.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module InstanceAgent; module Plugins; module CodeDeployPlugin | ||
class CommandAcknowledgementRequestBuilder | ||
@@MIN_ACK_TIMEOUT = 60 | ||
@@MAX_ACK_TIMEOUT = 4200 | ||
|
||
def initialize(logger) | ||
@logger = logger | ||
end | ||
|
||
def build(diagnostics, host_command_identifier, timeout) | ||
result = build_default(diagnostics, host_command_identifier) | ||
if timeout && timeout > 0 | ||
result[:host_command_max_duration_in_seconds] = correct_timeout(timeout) | ||
end | ||
|
||
result | ||
end | ||
|
||
private | ||
|
||
def build_default(diagnostics, host_command_identifier) | ||
{ | ||
:diagnostics => diagnostics, | ||
:host_command_identifier => host_command_identifier | ||
} | ||
end | ||
|
||
def correct_timeout(timeout) | ||
result = timeout | ||
if timeout < @@MIN_ACK_TIMEOUT | ||
log(:info, "Command timeout of #{timeout} is below minimum value of #{@@MIN_ACK_TIMEOUT} " + | ||
"seconds. Sending #{@@MIN_ACK_TIMEOUT} to the service instead.") | ||
result = @@MIN_ACK_TIMEOUT | ||
elsif timeout > @@MAX_ACK_TIMEOUT | ||
log(:warn, "Command timeout of #{timeout} exceeds maximum accepted value #{@@MAX_ACK_TIMEOUT} " + | ||
"seconds. Sending #{@@MAX_ACK_TIMEOUT} to the service instead. Commands may time out.") | ||
result = @@MAX_ACK_TIMEOUT | ||
end | ||
|
||
result | ||
end | ||
|
||
def log(severity, message) | ||
raise ArgumentError, "Unknown severity #{severity.inspect}" unless InstanceAgent::Log::SEVERITIES.include?(severity.to_s) | ||
@logger.send(severity.to_sym, "#{self.class.to_s}: #{message}") | ||
end | ||
end end end end |
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
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
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
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
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
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
Oops, something went wrong.