Skip to content

EnvironmentDetail.GetDeviceName check for EC2 environment always runs #152

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

Open
kfsit opened this issue Jun 27, 2024 · 2 comments · Fixed by #153
Open

EnvironmentDetail.GetDeviceName check for EC2 environment always runs #152

kfsit opened this issue Jun 27, 2024 · 2 comments · Fixed by #153

Comments

@kfsit
Copy link

kfsit commented Jun 27, 2024

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

@kfsit kfsit changed the title EnvironmentDetail.GetDeviceName check for EC2 environment wrong EnvironmentDetail.GetDeviceName check for EC2 environment always runs Jun 28, 2024
@t-lair
Copy link
Collaborator

t-lair commented Jun 28, 2024

@kfsit can you confirm this PR addresses your concerns? #153

@homiedopie
Copy link
Contributor

@kfsit - The package is already available as 2.2.15-beta - Let me know if you have questions

Link: https://www.nuget.org/packages/StackifyLib/2.2.15-beta

@homiedopie homiedopie reopened this Jul 3, 2024
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

Successfully merging a pull request may close this issue.

3 participants