Skip to content

EnvironmentDetail.GetDeviceName check for EC2 environment always runs #152

Closed
@kfsit

Description

@kfsit

There is a logical error with the check to see if the environment is an EC2 machine. Because of this, on first run it tries to ping a non existent EC2 server which causes a delay of 30 seconds while waiting for the check to complete.

In the code snippet below, any one of the conditions will allow checking of EC2

  1. Config.IsEc2 == null
  2. Config.IsEc2 == true
  3. isDefaultDeviceNameEc2

Condition 1 is checking if the variable is null - e.g. no value is set. On loading our configuration, IsEc2 is null, in which case it meets the condition and calls GetEC2InstanceId(). This call will eventually fail but require waiting for 20-30 seconds while it tries to connect to Ec2.

The condition could be written as if ((Config.IsEc2.HasValue && Config.IsEc2) || isDefaultDeviceNameEc2)

Note, that after the first run the values are cached so no further attempts at connecting with Ec2 is made.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions