-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fixed the default namespace issue #150
Fixed the default namespace issue #150
Conversation
Hi @Bharadwajshivam28. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/service/init.go
Outdated
@@ -323,6 +323,12 @@ func RunE2E(clientset *kubernetes.Clientset) { | |||
// Cleanup removes all resources created during E2E tests. | |||
func Cleanup(clientset *kubernetes.Clientset) { | |||
namespace := viper.GetString("namespace") | |||
|
|||
if namespace == "" { |
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.
@Bharadwajshivam28 A cleaner solution would be to reuse the ValidateArgs method https://github.com/kubernetes-sigs/hydrophone/blob/main/pkg/common/args.go#L52. its currently validating multiple things. maybe we can introduce a new method for validating namespace?
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.
Okay works for me... let me change it @reetasingh
@reetasingh I have made some changes.. |
pkg/common/args.go
Outdated
viper.Set("namespace", DefaultNamespace) | ||
} | ||
} | ||
|
||
func ValidateArgs() error { | ||
if viper.Get("namespace") == "" { |
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.
reuse SetDefaultNamespace() here too.
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.
Okay...
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.
reuse SetDefaultNamespace() here too.
can you please elaborate this one? sorry but i not understood it..
@@ -48,6 +48,12 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { | |||
// ValidateArgs validates the arguments passed to the program | |||
// and creates the output directory if it doesn't exist | |||
|
|||
func SetDefaultNamespace() { |
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.
@Bharadwajshivam28 if possible can you add unit test for this?
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.
@Bharadwajshivam28 if possible can you add unit test for this?
I have implemented unit test but can you please elaborate this?
I will be happy to make the changes @reetasingh
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.
you can add the unit test for this in args_test.go
pkg/common/args.go
Outdated
@@ -48,6 +48,12 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { | |||
// ValidateArgs validates the arguments passed to the program |
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.
above comment is for ValidateArgs() method. I think you have not added it in right place
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.
Oh I missed it... Let me take a look at it..
Will push the changes soon..
pkg/service/init.go
Outdated
namespace := viper.GetString("namespace") | ||
fmt.Println("using namespace:", namespace) |
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.
use log instead of fmt see https://github.com/kubernetes-sigs/hydrophone/blob/main/pkg/common/args.go#L76 for example
pkg/service/init.go
Outdated
@@ -322,7 +322,9 @@ func RunE2E(clientset *kubernetes.Clientset) { | |||
|
|||
// Cleanup removes all resources created during E2E tests. | |||
func Cleanup(clientset *kubernetes.Clientset) { | |||
common.SetDefaultNamespace() |
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.
@Bharadwajshivam28 I think we can call this from cmd/root.go before calling Cleanup
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.
can you please make me understand this? I think you are saying to call this common.SetDefaultNamespace()
from the root.go?
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.
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.
oh.. you are saying to remove the line common.SetDefaultNamespace()
from init.go
and call it from here ?
if cleanup {
common.SetDefaultNamespace()
service.Cleanup(client.ClientSet)
from root.go
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.
yes
/ok-to-test |
Signed-off-by: shivam <shivambharadwaj822@gmail.com>
@reetasingh I moved |
@reetasingh Just a small review i need that for the unit test what i understand for the function SetDefaultNamespace is- Case 1
Case 2
I saw the Pre declared test in args_test.go file. Is this way we are looking? as the function SetDefaultNamespace just checks and sets namespace. |
@Bharadwajshivam28 Its easier to review if you write the test case itself. and yes, right for each of the test case above do viper.get("namespace") and check the value of namespace matches what is expected |
I see the presumbit job is failing
can you run make test locally to see everything passes? |
ya let me check it |
Just a question @reetasingh our default namespace is conformance which will be set if namespace is not passed and if user passes the namespace then we just need to skip the test. like we dont need to do any action if users passes the namespace we just need to take actions in when users don't pass namespace.. Like we can log the namespace in both cases |
Signed-off-by: shivam <shivambharadwaj822@gmail.com>
Please run |
Signed-off-by: shivam <shivambharadwaj822@gmail.com>
/lgtm |
Is there any more changes to be done mam @reetasingh |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Bharadwajshivam28, rjsadow The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Currently if namespace is not passed and we run the command
bin/hydrophone --cleanup
then the command breaks so we can pass a default namespace it users run the commandbin/hydrophone --cleanup
then also the default namespace will be taken.fixes #149
Previous behaviour-
Current behaviour-