1 00:00:00,580 --> 00:00:01,413 - [Russ] When you sit down 2 00:00:01,413 --> 00:00:02,790 to write an automated deployment, 3 00:00:02,790 --> 00:00:05,810 it very, very rarely works first time. 4 00:00:05,810 --> 00:00:07,260 When I'm doing this, I generally test 5 00:00:07,260 --> 00:00:09,326 some deployment commands manually. 6 00:00:09,326 --> 00:00:11,950 I get confident the deploy is going to work how I planned. 7 00:00:11,950 --> 00:00:14,800 I start small, and gradually add to the build scripts. 8 00:00:14,800 --> 00:00:16,390 That way, I can isolate debugging 9 00:00:16,390 --> 00:00:20,400 down to just the changes I made in my small updates. 10 00:00:20,400 --> 00:00:23,460 When I do hit an error in a CodeDeploy deployment, 11 00:00:23,460 --> 00:00:25,680 where do I start with my debugging? 12 00:00:25,680 --> 00:00:28,010 Number one, I can see all the deployment details 13 00:00:28,010 --> 00:00:29,240 via the console. 14 00:00:29,240 --> 00:00:32,170 I'm looking at a failed deployment in the console right now, 15 00:00:32,170 --> 00:00:33,687 and I'm seeing the message: 16 00:00:33,687 --> 00:00:36,250 "some instances in your deployment group 17 00:00:36,250 --> 00:00:38,260 are experiencing problems." 18 00:00:38,260 --> 00:00:39,440 I can further drill down 19 00:00:39,440 --> 00:00:42,013 into the instance details down here, 20 00:00:44,140 --> 00:00:45,560 and I see the deploy failed 21 00:00:45,560 --> 00:00:48,243 at the very first event, ApplicationStop. 22 00:00:49,160 --> 00:00:51,630 I'm thinking that I don't have the CodeDeploy agent running 23 00:00:51,630 --> 00:00:52,740 on the instance. 24 00:00:52,740 --> 00:00:55,700 We need the CodeDeploy agent to be installed in the instance 25 00:00:55,700 --> 00:00:57,440 for any deployments to work. 26 00:00:57,440 --> 00:00:59,440 Maybe you are installing this 27 00:00:59,440 --> 00:01:02,010 with your user data scripts on your instances, 28 00:01:02,010 --> 00:01:05,800 or maybe you use AWS Systems Manager to do this for you. 29 00:01:05,800 --> 00:01:07,550 I'll include some links in the course readings 30 00:01:07,550 --> 00:01:11,223 with details on how to install the CodeDeploy agent. 31 00:01:12,530 --> 00:01:15,310 I've connected to the instance via Session Manager. 32 00:01:15,310 --> 00:01:17,730 I can check the status of the CodeDeploy agent 33 00:01:17,730 --> 00:01:18,955 with this command: 34 00:01:18,955 --> 00:01:23,955 sudo service codedeploy-agent status. 35 00:01:26,830 --> 00:01:31,220 And that is telling me the service cannot be found. 36 00:01:31,220 --> 00:01:33,813 That's a sign I need to get the agent installed. 37 00:01:35,230 --> 00:01:38,910 What other types of errors can occur in our deployments? 38 00:01:38,910 --> 00:01:41,790 I have fixed my CodeDeploy agent on my instance, 39 00:01:41,790 --> 00:01:43,430 I've re attempted the deployment, 40 00:01:43,430 --> 00:01:44,800 and I see a failure. 41 00:01:44,800 --> 00:01:46,090 Again, in the console, 42 00:01:46,090 --> 00:01:48,590 I can see the details of the deployment. 43 00:01:48,590 --> 00:01:51,463 If I view the instance details down here, 44 00:01:53,640 --> 00:01:54,547 I'm being told: 45 00:01:54,547 --> 00:01:59,547 "scripts/start_server run as root failed with exit code 5." 46 00:02:00,750 --> 00:02:05,480 If I view more on this, there is the output of the script. 47 00:02:05,480 --> 00:02:09,800 It looks like I have a typo in there. 48 00:02:09,800 --> 00:02:12,300 CodeDeploy makes the log tail available to me 49 00:02:12,300 --> 00:02:14,923 via the console and via the APIs. 50 00:02:16,090 --> 00:02:17,720 What if all my scripts ran, 51 00:02:17,720 --> 00:02:20,420 nothing returned an error back to CodeDeploy, 52 00:02:20,420 --> 00:02:22,740 but there is something wrong in my deployment logic, 53 00:02:22,740 --> 00:02:25,232 and I don't see my application working? 54 00:02:25,232 --> 00:02:28,343 Now, I would look at the logs on the instance itself. 55 00:02:29,730 --> 00:02:32,550 Again, in a Session Manager connection to my instance, 56 00:02:32,550 --> 00:02:36,127 I can see the deployment log at this location: 57 00:02:36,127 --> 00:02:37,660 (typing) 58 00:02:37,660 --> 00:02:42,660 opt/codedeploy-agent/deployment-root/deployment-logs 59 00:02:45,120 --> 00:02:48,733 and there is a codedeploy-agent-deployments.log. 60 00:02:51,070 --> 00:02:52,870 At the very end here, 61 00:02:52,870 --> 00:02:55,950 I can see the same error that I was seeing in the console. 62 00:02:55,950 --> 00:02:59,997 I have a typo there in "service httpd start." 63 00:03:02,660 --> 00:03:04,830 There is also a deployment archive on the instance 64 00:03:04,830 --> 00:03:06,420 at this location. 65 00:03:06,420 --> 00:03:11,420 It is in opt/codedeploy-agent/deployment-root. 66 00:03:13,140 --> 00:03:17,552 In here is the ID of my deployment group ID, 67 00:03:17,552 --> 00:03:18,385 (typing) 68 00:03:19,290 --> 00:03:23,000 and under that is all of the deployment IDs 69 00:03:23,000 --> 00:03:24,833 that have occurred on this instance. 70 00:03:25,770 --> 00:03:27,770 Let's choose one of them. 71 00:03:27,770 --> 00:03:30,261 And if I look here, I will see the deployment archive 72 00:03:30,261 --> 00:03:32,370 that was downloaded to my instance, 73 00:03:32,370 --> 00:03:35,750 and a scripts.log for this particular deploy. 74 00:03:35,750 --> 00:03:37,700 The script logs are going to capture the output 75 00:03:37,700 --> 00:03:39,900 of my commands in my deployment scripts, 76 00:03:39,900 --> 00:03:41,950 and any logging I've included. 77 00:03:41,950 --> 00:03:43,790 This should point me to some clues 78 00:03:43,790 --> 00:03:47,090 of why my deployment isn't going to plan. 79 00:03:47,090 --> 00:03:48,130 So, where are you going 80 00:03:48,130 --> 00:03:50,470 to start your deployment detective work? 81 00:03:50,470 --> 00:03:53,010 We can see a lot of information in the console. 82 00:03:53,010 --> 00:03:55,360 Do you need some extra debugging details? 83 00:03:55,360 --> 00:03:57,200 We can always retrieve CodeDeploy logs 84 00:03:57,200 --> 00:03:59,173 from our deployment instances.