Skip to content
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

core: make rook version more readable #121

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

subhamkrai
Copy link
Collaborator

@subhamkrai subhamkrai commented Jun 14, 2023

core: make rook version more readable

during pre-validation check, rook version was
printed in multiple lines with golang version
which was making it difficult to read. Now, it
prints in one single like with the golang version.

core: print version info only once
there was extra fmt.Print() in method RunCommandInOperatorPod
due to which command output was printed two times.

fixes: #118
Signed-off-by: subhamkrai [email protected]

@subhamkrai subhamkrai force-pushed the make-rook-version-more-readable branch from 16bad81 to d696d1f Compare June 14, 2023 02:46
@subhamkrai
Copy link
Collaborator Author

earlier

Warning: rook version 'rook: v1.11.0-alpha.0.410.g97bf52d76
go: go1.19.7
' is running a pre-release version of Rook.

now

Info: CephCluster namespace: "rook-ceph"
Info: Rook operator namespace: "rook-ceph"
Warning: rook version 'rook: v1.11.0-alpha.0.420.gd9a17691c' is running a pre-release version of Rook.

@subhamkrai subhamkrai requested a review from travisn June 14, 2023 02:54
@@ -106,7 +107,11 @@ func PreValidationCheck(ctx context.Context, k8sclientset *k8sutil.Clientsets, o
}

rookVersion := exec.RunCommandInOperatorPod(ctx, k8sclientset, "rook", []string{"version"}, operatorNamespace, cephClusterNamespace, true, false)
re := regexp.MustCompile("(?m)[\r\n]+^.*go: go.*$") // remove the go version from the output
rookVersion = re.ReplaceAllString(rookVersion, "")
Copy link
Member

Choose a reason for hiding this comment

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

How about factoring out this string replacement to a small helper method, then add a unit test for it? Whenever there is a regular expression, a unit test is always helpful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added.

I want to add unit tests for all the methods but seems like that will take more time to release and require my bandwidth. XD

Copy link
Member

Choose a reason for hiding this comment

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

Unit tests for now can avoid the high level commands since they are covered by the integration tests, but for small things like this, unit tests will be perfect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

make sense

there was extra `fmt.Print()` in method `RunCommandInOperatorPod`
due to which command output was printed two times.

fixes: rook#118
Signed-off-by: subhamkrai <[email protected]>
during pre-validation check, rook version was
printed in multiple lines with golang version
which was making it difficult to read. Now, it
prints in one single like with the golang version.
Also, adding unit test for the  regular expression.

Signed-off-by: subhamkrai <[email protected]>
@subhamkrai subhamkrai force-pushed the make-rook-version-more-readable branch from b9a1cea to 8c63fee Compare June 14, 2023 15:00
@travisn travisn merged commit 4967a23 into rook:master Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Namespace information is printed every time unexpectedly
2 participants