Skip to content

Conversation

@lib0xidium
Copy link

  • added error handling to avoid panics

@lib0xidium
Copy link
Author

lib0xidium commented Oct 10, 2024

Hello @mattfarina,

Due to this line: https://github.com/Masterminds/sprig/blob/master/network.go#L11 Helm is failing when getHostByName returns nothing (e.g: due to NXDOMAIN).

The error looks like this:

error calling getHostByName: invalid argument to Intn

because rand.Intn() is called with 0 as an argument.

We should handle this case and return a more descriptive error, both in sprig and helm packages.

Also, returning a random entry from the resolved addresses might introduce confusion. I would prefer/propose to return the whole list of results.

- changed getHostByName
- added unit-test
@lib0xidium lib0xidium force-pushed the bugfix/gethostbyname-error-handling branch from e7c443f to 65d69fd Compare October 10, 2024 09:49
@lib0xidium
Copy link
Author

Hey @mattfarina - just a heads up.

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 this pull request may close these issues.

1 participant