Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

cmd/scollector+bosun: get vsphere mounted datastores and expose via h… #1515

Merged
merged 1 commit into from
Dec 14, 2015

Conversation

kylebrandt
Copy link
Member

…ost api

dataStores := []string{}
err = json.Unmarshal([]byte(val), &dataStores)
if err != nil {
slog.Errorf("error unmarshalling datastores for host %s while generating host api: %s", host.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue or return here. Don't keep going.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@captncraig Since the host API generates a lot of information, I don't want single errors preventing the rest of the information from being returned

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, then we chould continue the metadata loop. Should not iterate over dataStores if we just failed to deserialize it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@captncraig My assumption was that in we fail to deserialize it, the array will be empty, so the range is a no-op.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible it has a few partial objects already created there. I'd rather skip it to be safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@captncraig The code makes it sounds like it checks for this first, see https://golang.org/src/encoding/json/decode.go?s=2621:2669#L64

"""
// Check for well-formedness.
// Avoids filling out half a data structure
// before discovering a JSON syntax error.
"""

@kylebrandt kylebrandt merged commit 8ab1958 into master Dec 14, 2015
@gbrayut gbrayut deleted the vDataStoreInfo branch December 30, 2015 01:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants