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

implement helm get values with sysdump #1889

Conversation

liyihuang
Copy link
Contributor

@liyihuang liyihuang commented Aug 2, 2023

include the helm get values in the sysdump collecting, and it will try to grab the user provide value and write to a file. when users provides a sysdump file, we don't have to ask the user to submit a separate helm value file.

in this implementation, we just grab the latest value and user provide values for cilium. in the future, there can be more enhancement for this.

  1. we can provide more options to collect previous version or the rendered helm values for everything.

btw, this is my first golang/OSS PR. feel free to let me know what I can do to make this better

@liyihuang liyihuang requested review from a team as code owners August 2, 2023 19:03
@liyihuang liyihuang requested a review from sayboras August 2, 2023 19:03
@maintainer-s-little-helper
Copy link

Commit bfc2d79 does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@liyihuang liyihuang requested a review from asauber August 2, 2023 19:03
@liyihuang liyihuang temporarily deployed to ci August 2, 2023 19:03 — with GitHub Actions Inactive
@liyihuang liyihuang force-pushed the pr/liyihuang/include-helm-get-values-in-sysdump branch from bfc2d79 to 8c99872 Compare August 2, 2023 19:38
@liyihuang liyihuang temporarily deployed to ci August 2, 2023 19:38 — with GitHub Actions Inactive
@liyihuang liyihuang temporarily deployed to ci August 2, 2023 20:46 — with GitHub Actions Inactive
Copy link
Member

@asauber asauber left a comment

Choose a reason for hiding this comment

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

This looks great overall. I have a few comments regarding names and error messages.

Please re-request my review if you end up waiting on me!

internal/cli/cmd/sysdump.go Outdated Show resolved Hide resolved
k8s/client.go Outdated Show resolved Hide resolved
k8s/client.go Outdated Show resolved Hide resolved
k8s/client.go Outdated Show resolved Hide resolved
@liyihuang liyihuang temporarily deployed to ci August 3, 2023 13:48 — with GitHub Actions Inactive
@mtt0
Copy link

mtt0 commented Aug 5, 2023

If we want hornor --cilium-namespace sysdump flag ranther than the global flag -n, workaround:

Add:

helmDriver := ""
logger := func(format string, v ...interface{}) {}
k8sClient.RESTClientGetter.Namespace = sysdumpOptions.CiliumNamespace
if err := k8sClient.HelmActionConfig.Init(&k8sClient.RESTClientGetter, sysdumpOptions.CiliumNamespace, helmDriver, logger); err != nil {
  return fmt.Errorf("failed to init helm action config: %w", err)
}

below

// Honor --namespace global flag in case it is set and --cilium-namespace is not set
if sysdumpOptions.CiliumNamespace == "" && cmd.Flags().Changed("namespace") {
sysdumpOptions.CiliumNamespace = namespace
}

  • If -n present and --cilium-namespace not, then -n tack effect
  • If --cilium-namespace present, then --cilium-namespace tack effect and override -nk8sClient.RESTClientGetter.Namespace and k8sClient.HelmActionConfig changed)

Not sure if there are other side effects, whether it will affect other commands, because I know nothing about cilium-cli, sorry😣

@liyihuang
Copy link
Contributor Author

liyihuang commented Aug 5, 2023

If we want hornor --cilium-namespace sysdump flag ranther than the global flag -n, workaround:

Add:

helmDriver := ""
logger := func(format string, v ...interface{}) {}
k8sClient.RESTClientGetter.Namespace = sysdumpOptions.CiliumNamespace
if err := k8sClient.HelmActionConfig.Init(&k8sClient.RESTClientGetter, sysdumpOptions.CiliumNamespace, helmDriver, logger); err != nil {
  return fmt.Errorf("failed to init helm action config: %w", err)
}

below

// Honor --namespace global flag in case it is set and --cilium-namespace is not set
if sysdumpOptions.CiliumNamespace == "" && cmd.Flags().Changed("namespace") {
sysdumpOptions.CiliumNamespace = namespace
}

  • If -n present and --cilium-namespace not, then -n tack effect
  • If --cilium-namespace present, then --cilium-namespace tack effect and override -nk8sClient.RESTClientGetter.Namespace and k8sClient.HelmActionConfig changed)

Not sure if there are other side effects, whether it will affect other commands, because I know nothing about cilium-cli, sorry😣

thanks for the reply.

I don't quite understand why we need init the NS twice here and I see we dont need to worry about NS in the RESTClientGetter here

cilium-cli/k8s/client.go

Lines 125 to 130 in b98ada8

helmDriver := ""
actionConfig := action.Configuration{}
logger := func(format string, v ...interface{}) {}
if err := actionConfig.Init(&restClientGetter, ciliumNamespace, helmDriver, logger); err != nil {
return nil, err
}

By the way, RESTClientGetter is the interface, and I don't think I can access the underlying struct directly. It seems like I may need to initialize another Kubernetes client specifically for sysdump to handle the --cilium-namespace flag. However, if we need to support --tetragon-namespace in the future, this approach could become problematic.

@mtt0
Copy link

mtt0 commented Aug 5, 2023

Copy link
Member

@asauber asauber left a comment

Choose a reason for hiding this comment

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

Looks great for the most part.

Can you squash the commits down to 1 or 2 commits? Maybe with supporting the additional namespace flag as the second commit.

It's also important that the CLI is fully usable after each commit, which might be one reason to squash down to 1.

k8s/client.go Outdated Show resolved Hide resolved
k8s/client.go Outdated Show resolved Hide resolved
@liyihuang liyihuang force-pushed the pr/liyihuang/include-helm-get-values-in-sysdump branch from a1fc630 to 045aec4 Compare August 22, 2023 16:51
@liyihuang liyihuang temporarily deployed to ci August 22, 2023 16:51 — with GitHub Actions Inactive
@liyihuang liyihuang requested a review from asauber August 22, 2023 16:52
Copy link
Member

@asauber asauber left a comment

Choose a reason for hiding this comment

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

One style comment, otherwise LGTM

include the helm get values in the sysdump collecting, and it will try
to grab the user provide value and write to a file. when users provides
a sysdump file, we don't have to ask the user to submit a separate helm
value file.

in this implementation, we just grab the latest value and user provide
values for cilium. in the future, there can be more enhancement for
this.

we can provide more options to collect previous version or the rendered
helm values for everything.

Signed-off-by: liyi huang <liyi.huang@isovalent.com>
@liyihuang liyihuang force-pushed the pr/liyihuang/include-helm-get-values-in-sysdump branch from 045aec4 to 0ae0bf1 Compare August 22, 2023 18:38
@liyihuang liyihuang temporarily deployed to ci August 22, 2023 18:38 — with GitHub Actions Inactive
@asauber asauber self-requested a review August 22, 2023 18:47
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 ✅

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Aug 22, 2023
@sayboras sayboras merged commit ca7ea27 into cilium:main Aug 22, 2023
19 checks passed
@liyihuang liyihuang deleted the pr/liyihuang/include-helm-get-values-in-sysdump branch April 18, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants