question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Travis failure in master: EC2 instance failed to create

See original GitHub issue

Not clear if this was one-off or likely to re-occur.

https://travis-ci.com/pulumi/pulumi-cloud/builds/58711465

It looks like one of the two VMs that was created never responded that it was ready (presumably never fired the cfn-signal in it’s userdata script?).

The VM that never responded doesn’t show anything too unusual happening - it was running for the full 15 minute period:

https://us-east-2.console.aws.amazon.com/ec2/v2/home?region=us-east-2#Instances:sort=instanceState

Unfortunately we don’t have logging for the EC2 VM boot process so it’s hard to see what might have gone wrong on the VM.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:45 (45 by maintainers)

github_iconTop GitHub Comments

1reaction
mmdrileycommented, Jan 16, 2018

Here’s one way we can get logs from these instances, if we catch this within an hour of the failure:

  1. Go to the list of EC2 instances in the pulumi-testing account in us-east-2 (Ohio). Look for terminated instances. https://us-east-2.console.aws.amazon.com/ec2/v2/home?region=us-east-2#Instances:instanceState=terminated;sort=instanceId

  2. Right-click each terminated instance and select “Get System Log” under “Instance Settings”.

The CloudFormation event log will show us the instance that successfully came up, e.g.: image so we can look at the other one.

If there are a lot of instances, we can filter them to the appropriate autoscaling group. Looking at the CloudFormation stack will give you the physical ID of the autoscaling group. From there you can filter the EC2 instances that have a matching aws:autoscaling:groupName tag.

0reactions
mmdrileycommented, Jan 27, 2018

I tore down the termination-watcher, but here’s the code for posterity:

import * as pulumi from "pulumi";
import * as aws from "@pulumi/aws";

import * as awssdk from "aws-sdk";

const terminatedInstanceEventFilter = {
    "source": [ "aws.ec2" ],
    "detail-type": [ "EC2 Instance State-change Notification" ],
    "detail": {
        "state": [ "terminated" ],
    },
};

function onTerminate(ev: any, ctx: aws.serverless.Context, cb: (error: any, result: any) => void) {
    let ec2 = new awssdk.EC2();
    let instanceId = ev["detail"]["instance-id"];

    ec2.getConsoleOutput({ InstanceId: instanceId }, (err, data) => {
        if (err) {
            console.error(err);
            cb(null, null);
            return;
        }

        let output = Buffer.from(data.Output!, 'base64');

        console.log(data.InstanceId);
        console.log(output.toString());
        cb(null, null);
    });
}

let handlerFunction = new aws.serverless.Function("handlerFunction", {
    policies: [
        aws.iam.AWSLambdaFullAccess,

        // EC2ReadOnlyAccess can't use ec2:GetConsoleOutput
        aws.iam.AmazonEC2FullAccess,
    ],
}, onTerminate);

let eventRule = new aws.cloudwatch.EventRule("eventRule", {
    eventPattern: JSON.stringify(terminatedInstanceEventFilter),
});

let eventTarget = new aws.cloudwatch.EventTarget("eventTarget", {
    rule: eventRule.name,
    arn: handlerFunction.lambda.arn,
});

let callPermission = new aws.lambda.Permission("callPermission", {
    action: "lambda:InvokeFunction",
    function: handlerFunction.lambda,
    principal: "events.amazonaws.com",
    sourceArn: eventRule.arn,
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Build Problems - Travis CI Docs
One possible cause for builds failing unexpectedly can be calling set -e (also known as set errexit ), either directly in your .travis.yml...
Read more >
Failure in build using Travis, AWS Elasticbeanstalk and Docker
A couple things you could try: Your script command needs to set the environment var CI=true. So script: - docker run heet1996/my-profile npm ......
Read more >
Troubleshoot instances with failed status checks
The following information can help you troubleshoot issues if your instance fails a status check. First determine whether your applications are exhibiting ...
Read more >
Travis failures and other CI solutions - cockpit-devel - Fedora ...
We've run into an issue with travis where adding new make files causes the tests to fail with an "write error" when running...
Read more >
Deal with certain travis CI failures - makandra cards
Your travis-ci builds might have started failing on the usual psql -c 'create database active_type_test;' -U postgres. with an error
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found