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

Error sometimes when launching instance #3

Open
JackDunnNZ opened this issue Sep 27, 2018 · 2 comments
Open

Error sometimes when launching instance #3

JackDunnNZ opened this issue Sep 27, 2018 · 2 comments

Comments

@JackDunnNZ
Copy link

Sometimes as I launch an instance I get the following error. It doesn't seem to be deterministic - I just launched 162 instances in a loop before it failed on the 163rd. Do you have any idea what could be the cause? I am on AWSCore v0.3.9 and AWSEC2 v0.3.1

ERROR: LoadError: InvalidInstanceID.NotFound -- The instance ID 'i-0685ec5bea7f6cb45' does not exist
HTTP.ExceptionRequest.StatusError(400, HTTP.Messages.Response:
"""
HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Date: Thu, 27 Sep 2018 16:52:47 GMT
Connection: close
Server: AmazonEC2

<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidInstanceID.NotFound</Code><Message>The instance ID 'i-0685ec5bea7f6cb45' does not exist</Message></Error></Errors><RequestID>bd908f70-3493-42d7-a0fe-65a34cdebb41</RequestID></Response>""")

Stacktrace:
 [1] #request#1(::Array{Any,1}, ::Function, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::Vararg{Any,N} where N) at /Users/jack/.julia/v0.6/HTTP/src/ExceptionRequest.jl:22
 [2] (::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::String) at ./<missing>:0
 [3] #request#1(::VersionNumber, ::String, ::Void, ::Void, ::Array{Any,1}, ::Function, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::String) at /Users/jack/.julia/v0.6/HTTP/src/MessageRequest.jl:45
 [4] (::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::String) at ./<missing>:0
 [5] macro expansion at /Users/jack/.julia/v0.6/AWSCore/src/http.jl:36 [inlined]
 [6] macro expansion at /Users/jack/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
 [7] http_request(::Dict{Symbol,Any}) at /Users/jack/.julia/v0.6/AWSCore/src/http.jl:20
 [8] macro expansion at /Users/jack/.julia/v0.6/AWSCore/src/AWSCore.jl:421 [inlined]
 [9] macro expansion at /Users/jack/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
 [10] do_request(::Dict{Symbol,Any}) at /Users/jack/.julia/v0.6/AWSCore/src/AWSCore.jl:399
 [11] #service_query#7(::Array{Any,1}, ::Function, ::Dict{Symbol,Any}) at /Users/jack/.julia/v0.6/AWSCore/src/AWSCore.jl:241
 [12] (::AWSCore.#kw##service_query)(::Array{Any,1}, ::AWSCore.#service_query, ::Dict{Symbol,Any}) at ./<missing>:0
 [13] ec2(::Dict{Symbol,Any}, ::String, ::Dict{String,String}) at /Users/jack/.julia/v0.6/AWSEC2/src/AWSEC2.jl:28
 [14] #create_ec2#2(::String, ::Array{Tuple{String,String,String},1}, ::String, ::Array{Any,1}, ::Function, ::Dict{Symbol,Any}, ::String) at /Users/jack/.julia/v0.6/AWSEC2/src/AWSEC2.jl:152
@samoconnor
Copy link
Owner

EC2 is a distributed system, so state is not always consistent between all EC2 server nodes. It takes time for changes to propagate.
Can you try this patch?

--- a/src/AWSEC2.jl
+++ b/src/AWSEC2.jl
@@ -149,9 +149,14 @@ function create_ec2(aws::AWSConfig, name; ImageId="ami-1ecae776",

     r = r["instancesSet"]["item"]

-    ec2(aws, "CreateTags", Dict("ResourceId.1" => r["instanceId"],
-                                "Tag.1.Key"    => "Name",
-                                "Tag.1.Value"  => name))
+    @repeat 3 try
+
+        ec2(aws, "CreateTags", Dict("ResourceId.1" => r["instanceId"],
+                                    "Tag.1.Key"    => "Name",
+                                    "Tag.1.Value"  => name))
+    catch e
+        @delay_retry if ecode(e) == "InvalidInstanceID.NotFound"
+    end

     return r
 end

@JackDunnNZ
Copy link
Author

Thanks for the quick reply, that did the trick (with a missing end added in the catch line):

--- a/src/AWSEC2.jl
+++ b/src/AWSEC2.jl
@@ -149,9 +149,14 @@ function create_ec2(aws::AWSConfig, name; ImageId="ami-1ecae776",

     r = r["instancesSet"]["item"]

-    ec2(aws, "CreateTags", Dict("ResourceId.1" => r["instanceId"],
-                                "Tag.1.Key"    => "Name",
-                                "Tag.1.Value"  => name))
+    @repeat 3 try
+
+        ec2(aws, "CreateTags", Dict("ResourceId.1" => r["instanceId"],
+                                    "Tag.1.Key"    => "Name",
+                                    "Tag.1.Value"  => name))
+    catch e
+        @delay_retry if ecode(e) == "InvalidInstanceID.NotFound" end
+    end

     return r
 end

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

No branches or pull requests

2 participants