c icon indicating copy to clipboard operation
c copied to clipboard

add support to load kubernetes configuration for memory buffer

Open DanyT opened this issue 1 year ago • 10 comments

  • existing api is not changed
    • load_kube_config works as before
  • extend kubeconfig_t to hold in memory buffer
  • make a common flow for file/buffer code
  • set fileName/buffer members accordingly
  • provide new api: load_kube_config_buffer

DanyT avatar Jul 01 '24 15:07 DanyT

Thanks for your PR. I will review it.

ityuhui avatar Jul 02 '24 13:07 ityuhui

Minor comments.

brendandburns avatar Jul 02 '24 18:07 brendandburns

This looks good to me. Thanks for the quick turn around. I'll wait for @ityuhui to take a look though in case there are additional comments.

brendandburns avatar Jul 03 '24 16:07 brendandburns

Thanks @brendandburns

@DanyT Can you please fix the issues reported by the code-static-check and code-sytle-check https://github.com/kubernetes-client/c/actions/runs/9781006686/job/27005098287?pr=242 in your code changes ? (Just update your code changes)

You can run the checks locally with

sh ./code-check/code-static-check.sh ./kubernetes/config/

and

find ./kubernetes/config/ -type f -regextype posix-extended -regex ".*\.(c|h)" -exec sh ./code-check/code-style-check.sh {} \;

ityuhui avatar Jul 05 '24 00:07 ityuhui

@DanyT Could you please write an example that uses your new function so we can add it to the automated tests in case your functions are broken by future code changes. We also have memory leak testing in automated testing.

FYI https://github.com/kubernetes-client/c/blob/dc7d67098361c3579e3dd8153ccc6c4c30ddfedb/examples/Makefile#L33

ityuhui avatar Jul 05 '24 00:07 ityuhui

@ityuhui I have added:

  • example for load_kube_config_buffer: ./example/list_pod_buffer
  • fixed static and style code checks.

Let me know if there is something that i missed.

DanyT avatar Jul 05 '24 06:07 DanyT

@DanyT

It seems that the build failed

cd list_pod_buffer; make test
make[1]: Entering directory '/home/runner/work/c/c/examples/list_pod_buffer'
./list_pod_buffer_bin
Cannot get kubernetes configuration from file.
make[1]: *** [Makefile:11: test] Error 255
make[1]: Leaving directory '/home/runner/work/c/c/examples/list_pod_buffer'
make: *** [Makefile:40: test] Error 2
Error: Process completed with exit code 2.

ityuhui avatar Jul 05 '24 13:07 ityuhui

Interesting... it is not the build itself that fails but at runtime it cannot find/load the kube config file. I will look into it. Is there a special location where the kube config file is delivered in this test environment? @ityuhui

DanyT avatar Jul 05 '24 14:07 DanyT

Nothing special, the configuration is located in $HOME/.kube/config

FYI https://github.com/kubernetes-client/c/blob/dc7d67098361c3579e3dd8153ccc6c4c30ddfedb/kubernetes/config/kube_config.c#L130

ityuhui avatar Jul 06 '24 13:07 ityuhui

@ityuhui Sorry for the delay. This should fix the issue.

DanyT avatar Jul 22 '24 11:07 DanyT

Thank you @DanyT

Can you add your example to the memory leak test ?Sorry for not reminding you earlier.

https://github.com/kubernetes-client/c/blob/dc7d67098361c3579e3dd8153ccc6c4c30ddfedb/examples/Makefile#L53

ityuhui avatar Jul 22 '24 12:07 ityuhui

Done

DanyT avatar Jul 22 '24 13:07 DanyT

I have no question about this PR. Thanks to @DanyT for the contribution !

@brendandburns I'm OK with the changes.

ityuhui avatar Jul 22 '24 13:07 ityuhui

/lgtm /approve

brendandburns avatar Jul 22 '24 16:07 brendandburns

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, DanyT, ityuhui

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:
  • ~~OWNERS~~ [brendandburns,ityuhui]

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Jul 22 '24 16:07 k8s-ci-robot