-
Notifications
You must be signed in to change notification settings - Fork 45
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes whitespaces and newline in nova conf template #842
Closed
auniyal61
wants to merge
1
commit into
openstack-k8s-operators:main
from
auniyal61:remove-extra-newlines-from-conf
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This can work and it's what i originally tried and abandoned last year but I'm not sure we want to commit to doing this.
the other option that we briefly discussed was post-processing the template and removing any instance of multiple newlines with a single new line.
if we make this change using the template timing feature then i want an env test tests for this to assert we do not have multiple consecutive new lines to catch any template changes that may miss the trimming and reintroduce this issue.
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.
yeah I tried that earlier, replaice "\n\n\n+" with "\n".
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.
but I tried it in inside a test,
@SeanMooney can you please suggest if we go with this approach, at what place should we make final changes .
i.e once we are sure, final nova.conf(s) are ready to format.
I think the foratting is dones here, but not sure at what point/place nova-operator can update this.
https://github.com/openstack-k8s-operators/lib-common/blob/bd202c880706adfbcc64ee4a57e877503a274a69/modules/common/util/template_util.go#L138
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.
As the current output still has plenty of whitespace even after the template tunining I would suggest to try to reduce that as a post processing step as discussed here.
The utils.Template type we use to pass the template to lib-common already has optional flags like https://github.com/openstack-k8s-operators/lib-common/blob/0ae9f7f9e059a903b1c47119ed05aa509f8afb77/modules/common/util/template_util.go#L58 So I think it would be OK to add an optional postProcessing function callback to that type that gets the rendered text and return a new text. The default can be a simple identity that returns the text unchanged. Then nova-operator can hook into the lib-common code and do the whitespace reduction on the rendered text. (It would be even better to split up the monolithic secret.EnsureSecrets lib-common function that the template rendering and the secret creation can be composed on the client side.)
@auniyal61 you can put replace line into go.mod to depend on an unmerged lib-common patch to be able to show that the lib-common change works with nova-operator and to show how the config would look.