Skip to content

Clean up bindConfigServices function #25

@MaxwellBoecker

Description

@MaxwellBoecker

Description:
The current implementation of the bindConfigServices function could create outputs and/or errors that would be confusing to debug.

Issue:
Looking at the https://github.com/taubyte/dreamland/blob/main/cli/new/helpers.go file, it seems that if the conditional check on line 78 fails, then we will end up with a port of 0 and a sub of "" for any given service. Apparently it is possible to use port 0 to bind to a random available port, however this could cause problems with the use of TCP as 0 is a reserved port not intended to be used. In any case, a sub of "" is not in the list of ValidSubBinds found in the file https://github.com/taubyte/dreamland/blob/main/cli/common/vars.go. We see sub being validated on line 86, but not if the conditional check on line 78 fails. So this seems like a contradiction of logic: likely it should be validated both times.

Also, if it is possible for any service to bind to port 0, I would expect the conditional on line 112 to fail from time to time, in which case we would get an error for two services having duplicate port bindings. And the reason they are duplicate is just that they ended up taking on a default value after the conditional on line 78 failed. This gives the appearance that the code is written assuming the conditional on 78 will not fail.

Possible Solution:
It would likely be better to save the confusion by just creating a requirement that the result of strings.Split(bind, "@") on line 63 have a length == 2, instead of letting the inputs fall all the way through to the validation of duplicate ports to fail. This could save some debugging efforts insofar as we would not have to read all the times that port gets initialized, reassigned, or accessed on the binds map.

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