Remove check that hostID is a uuid.

Immediately afterward we hash the ID, so it does not need to be a uuid anymore.
This commit is contained in:
Daniel Nephin 2020-08-10 11:49:46 -04:00
parent 875d8bde42
commit e07554500e
1 changed files with 2 additions and 14 deletions

View File

@ -79,23 +79,11 @@ func makeNodeID(logger hclog.Logger, disableHostNodeID bool) (string, error) {
return uuid.GenerateUUID() return uuid.GenerateUUID()
} }
// Make sure the host ID parses as a UUID, since we don't have complete
// control over this process.
id := strings.ToLower(info.HostID)
// TODO: why do we care if HostID is a uuid, if we are about to hash it?
if _, err := uuid.ParseUUID(id); err != nil {
logger.Debug("Unique ID from host isn't formatted as a UUID",
"id", id,
"error", err,
)
return uuid.GenerateUUID()
}
// Hash the input to make it well distributed. The reported Host UUID may be // Hash the input to make it well distributed. The reported Host UUID may be
// similar across nodes if they are on a cloud provider or on motherboards // similar across nodes if they are on a cloud provider or on motherboards
// created from the same batch. // created from the same batch.
buf := sha512.Sum512([]byte(id)) buf := sha512.Sum512([]byte(strings.ToLower(info.HostID)))
id = fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", id := fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
buf[0:4], buf[0:4],
buf[4:6], buf[4:6],
buf[6:8], buf[6:8],