-
Notifications
You must be signed in to change notification settings - Fork 10
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor sbd loading #145
Refactor sbd loading #145
Conversation
f740239
to
2a85a12
Compare
2a85a12
to
bc10572
Compare
bc10572
to
18e62da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this break something? sweat_smile
@nelsonkopliku I think that before considering changing this, this question should be answered by adding automated tests where needed
internal/cluster/sbd.go
Outdated
return nil, &SBDConfigLoadingError{ | ||
Type: SDBConfigDecodingError, | ||
inner: errors.Wrap(err, "could not read sbd config file"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case we could remove the extra entries so the output is the same to what we had with the regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this. I think we should return the empty values if they are configured
Imagine that you want to create a check to see if the configured value has an empty string.
Like Check SBD_OPTS has not additional values
and you see that it is not changed.
I don't know, this hides information.
Not having those values in the past shouldn't be a reason not to add them now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end I returned to my first proposal of not skipping empty values in config and covered in test.
If this is sorted out we need to agree on trento-project/web#996.
I made this change on trento web trento-project/web#996 and let e2e tests tell us if integration does not break 馃槄 Would that be enough? |
18e62da
to
b579719
Compare
@fabriziosestito made the change you suggested. This also means that if we do something like facts:
- name: sbd_opts
gatherer: sbd_config
argument: SBD_OPTS # or any other possibly empty entry We'll get a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folks, sorry for arriving late, but I think that the removal of empty values is a bad idea. We are hiding real configuration, that might be useful in the checks for example.
Senging a new field with an empty value shouldn't be a problem for the web, as most probably we don't use that field.
Besides that, I find the error handling way complicated
internal/cluster/sbd.go
Outdated
return nil, &SBDConfigLoadingError{ | ||
Type: SDBConfigDecodingError, | ||
inner: errors.Wrap(err, "could not read sbd config file"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this. I think we should return the empty values if they are configured
Imagine that you want to create a check to see if the configured value has an empty string.
Like Check SBD_OPTS has not additional values
and you see that it is not changed.
I don't know, this hides information.
Not having those values in the past shouldn't be a reason not to add them now.
434db46
to
ea8b0f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nelsonkopliku Green light from my side.
I commented 2 minor things that don't need an extra review.
1cbdecc
to
36a2400
Compare
Description
Sbd configuration gets read in the two major processes of the agent:
sbd_config
gatherer)This PR reduces some duplication of sbd configuration file loading and in discovery/facts gathering.
Notes:
utils.FindMatches('(?m)^(\w+)=(\S[^#\s]*)', sbdConfigRaw)
has been superseded byenvparse.Parse(sbdConfigFile)
.A subtle difference here is that
FindMatches
ignores empty values likeSBD_OPTS=
whileenvparse
decodes to empty string.This means that the cluster discovery would also have
"SBD_OPTS": ""
among the other configs.Would this break something? 馃槄I tried and it does not break things up.Should we make sure to skip empty entries when parsing?I believe we should return sbd config entries even if they're empty, see #145 (comment)