These are chat archives for CharlesGust/django-imagr

21st
Nov 2014
Charlie
@charlieRode
Nov 21 2014 01:44
Did you guys get it deployed?
Ben Friedland
@BFriedland
Nov 21 2014 02:36
No, we're still figuring out how to get there manually, but we did make a bit of progress building the fabfile as we went. Dan made it sound easier than I thought it'd be, but we'll probably have to ask him about it again...
I did make it through the fabric tutorial though.
Charlie
@charlieRode
Nov 21 2014 02:37
Hmm. Ill need to try again and see if I get the same error... Maybe you can show me where I went wrong tomorrow.
Ben Friedland
@BFriedland
Nov 21 2014 02:51
I'm not sure if this will help, but I noticed when I went to follow the tutorial's advice here: "Find your ssh-access security group and add a new TCP rule. Allow HTTP access via port 80 from any address."
that ssh-access had my SSH rule and had to be given a second HTTP rule, for a total of two rules.
If the problem you had involved a key or something, I'll have to check it out tomorrow.
Charlie
@charlieRode
Nov 21 2014 03:10
The problem was with the security group 'ssh-access', but I did add that second TCP rule as instructed in the tutorial. No matter, I'm currently trying to figure out S3 still.... Not super easy.
Ben Friedland
@BFriedland
Nov 21 2014 03:31
I don't know if it will help, but I uploaded my fabfile from the tutorial on my deployment_bf branch in the django-imagr repo. It's NOT the fabfile we need for the Imagr deployment assignment... but after seeing how Michelle and Jason did their fabfile, it looks like they included parts of the tutorial's fabfile, so I'll put it there for reference. We don't need to merge deployment_bf with master or anything like that, though.
Charlie
@charlieRode
Nov 21 2014 04:04
okay, thanks Ben
Charlie
@charlieRode
Nov 21 2014 05:14
wooot! I got image uploading to S3 working!
Charlie
@charlieRode
Nov 21 2014 08:08

So I'm going through your fabfile, alongside Chris' tutorial. The provision_instance() function is broken as well I can tell (Chris' originally, which was copied). I don't even feel the need to test it. I know it doesn't work. Two glaring errors:
1) (As I take it you noticed from the "# !" comment you left on the line) The "i" in:
running_instance.append(new_instances.pop(new_instances.index(i))) doesn't refer to anything. I'm guessing "each_instance" is what's meant to be referenced here because it is a line in a for-loop that is iterating over 'new_instances' with 'each_instance'.
2) Much more importantly, you can't pop() from a list as that list is being iterated over because the indicies being referenced get all fucked up. E.g, If i define mylist = [1, 2, 3, 4], and I say:
for item in mylist:
if item > 2:
mylist.pop(mylist.index(item))

mylist will now be = [1, 2, 4]. I assume that this is because 3 was at index 2, and the built-in 'for x in lst' construction keeps track of indicies to iterate over the list. So after it is determined that the current item satisfies the condition and is popped from the list, 4 is now at index 2. But since index 2 has already been checked, the loop moves on to index 3, which doesn't exist anymore and so the loop ends, leaving 4 (even though 4 > 2)

So I'm damned sure that Chris' code here does not work.
Ben Friedland
@BFriedland
Nov 21 2014 16:59
I was actually concerned about that too and completely forgot... but I started and terminated several instances using it; I checked on the AWS console every time. I'm going to ask Dan about it.
I was preparing to rewrite it but I couldn't figure out where he was getting the i from on that line.
I almost think the errors were left in intentionally to prevent code copying. Weird.
Ben Friedland
@BFriedland
Nov 21 2014 17:04
Wait, those errors are in the conditional on wait_for_running, which I never tested.
So I didn't actually run through that part of the code -- if I run 'fab provision_instance' it'll spin up a server I can see in the AWS console and when using both 'fab select_instance' and 'fab list_aws_instances:verbose=1'
Ben Friedland
@BFriedland
Nov 21 2014 19:49
Figured out that the mystery 'i' variable can be changed to each_instance in my version of the tutorial assignment and it will work as intended. It seems that the syntax 'some_list.index(some_object_in_the_list)' will return the index of that object, which pop() will then work with. It is incorrect in the tutorial, but that's all that would need to be changed...

And, as you said, the pop() part also doesn't work.
for item in list:
if item > 2:
list.pop(list.index(item))

will, as you said, fail to handle indices correctly after the first item has been removed.

Fortunately we only need to put up one instance at a time, so we don't have to spend a long time fixing that part of the tutorial, but I wouldn't publish the fabfile with that part in it as accessible code.
Charlie
@charlieRode
Nov 21 2014 20:02
Yeah i rewrote the code; i haven't tested it yet but its as it makes sense to me.
im coming in now. Had a late night but im omw
Charlie
@charlieRode
Nov 21 2014 21:10
Sorry, I've changed my mind. I'm going to work from home today. How are you guys coming along on deployment?
Charles Gust
@CharlesGust
Nov 21 2014 21:42
We are close. I'm having authentication and key pair problems, but we have just the pips and gunicorn to go, I think