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

Add hubble list namespaces command #1086

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Conversation

chancez
Copy link
Contributor

@chancez chancez commented Jun 14, 2023

Now that the Hubble Observer API supports GetNamespaces, implement it in Hubble CLI.

Relates to

@chancez chancez added ⌨️ area/cli Impacts the command line interface of any command in the repository. 🌟 kind/feature This introduces new functionality. labels Jun 14, 2023
@chancez chancez requested review from a team as code owners June 14, 2023 16:25
@chancez chancez self-assigned this Jun 14, 2023
@chancez chancez requested review from sayboras and tklauser and removed request for a team June 14, 2023 16:25
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label PR is blocked until the release note is set label Jun 14, 2023
@chancez chancez requested review from kaworu, glibsm, rolinh and a team June 14, 2023 16:25
@glibsm
Copy link
Member

glibsm commented Jun 14, 2023

static check is acting starnge. It doesn't appear to pick up your function rename 🤔

@chancez
Copy link
Contributor Author

chancez commented Jun 14, 2023

static check is acting starnge. It doesn't appear to pick up your function rename 🤔

Oh I forgot to update the tests after changing the name of a function.

@chancez chancez force-pushed the pr/chancez/get_namespaces branch 2 times, most recently from 1f20eb4 to 2b110dc Compare June 14, 2023 18:09
@chancez chancez added the release-note/major This PR introduces major new functionality to Hubble. label Jun 14, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label PR is blocked until the release note is set label Jun 14, 2023
Copy link
Member

@sayboras sayboras left a comment

Choose a reason for hiding this comment

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

LGTM ✔️

The release note label is major, but I leave it to Hubble team to decide 🤔

Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks @chancez! Tested the patch and LGTM.

One thing I noticed that bugged me:

% ./hubble list namespaces -o wide
NAMESPACE            CLUSTER
kube-system          N/A
local-path-storage   N/A

Here my cluster name is "default", but I see N/A. I wonder if we should consider removing this guard and consistently output "default" instead of empty string, although on the other hand it will go against this CFP.

@@ -55,6 +55,11 @@ func (o *IOReaderObserver) GetNodes(_ context.Context, _ *observerpb.GetNodesReq
return nil, status.Errorf(codes.Unimplemented, "GetNodes not implemented")
}

// GetNamespaces is not implemented, and will throw an error if used.
Copy link
Member

Choose a reason for hiding this comment

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

"throw" 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the existing comments 😂

@chancez
Copy link
Contributor Author

chancez commented Jun 15, 2023

@kaworu I thought about this too, but I wasn't sure if the client should be doing that or not. I kinda feel like perhaps I should be extracting the cluster name from the flows inside hubble server, and configuring the cluster name there. What do you think?

if err != nil {
return err
}
_, err = fmt.Fprintln(buf, string(bs))
Copy link
Member

Choose a reason for hiding this comment

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

it's a minor nit, but i think w.Write() here is more typical without string() conversion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was how it was already written, I just moved which file this function was in. I believe the goal is to get a newline at the end so that when it's logged it's not on the same line as the prompt.

@kaworu kaworu added the :basecamp: needs-rebase This PR needs to be rebased because it has merge conflicts. label Jun 16, 2023
@kaworu
Copy link
Member

kaworu commented Jun 16, 2023

I wasn't sure if the client should be doing that or not.

Can the client disambiguate between "" and "default"?

I kinda feel like perhaps I should be extracting the cluster name from the flows inside hubble server, and configuring the cluster name there. What do you think?

I don't understand what you are suggesting, could you clarify?

@chancez
Copy link
Contributor Author

chancez commented Jun 16, 2023

Can the client disambiguate between "" and "default"?

We don't really define anywhere how they should be treated, so it's hard to say.

In the NodeNameFilter we basically treat empty as "default" for filtering purposes. But in the node_name we field we return in GetFlows doesn't get updated from "" to "default" IIRC. So basically, in the server, we always leave the flow alone, but when querying, we support treating "default" as "".

After writing that out, it makes me think the best option then is to just return "" instead of "N/A". What do you think?

I don't understand what you are suggesting, could you clarify?

Right now, the clusterName for a flow is determined by using nodeTypes.GetClusterName() which uses configuration to determine the cluster_name.

I was thinking that we could use the value from the flow itself (which is part of the node_name field), but I realize now it's not much better. I had thought we were adding "default/" to the node_name of flows so it would make sense to use the node_name field to figure out cluster_name, but I believe the node_name is just left alone unless cluster_name is configured explicitly.

@chancez chancez removed the :basecamp: needs-rebase This PR needs to be rebased because it has merge conflicts. label Jun 20, 2023
@chancez chancez requested a review from kaworu June 20, 2023 17:49
@chancez
Copy link
Contributor Author

chancez commented Jun 20, 2023

Rebased and removed N/A in favor of leaving cluster empty if not set.

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
@chancez chancez merged commit 212f54b into master Jun 21, 2023
5 checks passed
@chancez chancez deleted the pr/chancez/get_namespaces branch June 21, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌨️ area/cli Impacts the command line interface of any command in the repository. 🌟 kind/feature This introduces new functionality. release-note/major This PR introduces major new functionality to Hubble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants