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

CoreV1API_readNamespacedPodLog doesn't work and contains a segfault #222

Open
homer6 opened this issue Feb 26, 2024 · 8 comments
Open

CoreV1API_readNamespacedPodLog doesn't work and contains a segfault #222

homer6 opened this issue Feb 26, 2024 · 8 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@homer6
Copy link
Contributor

homer6 commented Feb 26, 2024

The text/plain header is being rejected:

{\n  \"kind\": \"Status\",\n  \"apiVersion\": \"v1\",\n  \"metadata\": {},\n  \"status\": \"Failure\",\n  \"message\": \"only the following media types are accepted: application/json, application/yaml, application/vnd.kubernetes.protobuf\",\n  \"reason\": \"NotAcceptable\",\n  \"code\": 406\n}

Commenting out that header makes it work again. However, when it proceeds it'll segfault on the strdup line if there aren't any pod logs (null pointer).

I moved the strdup into the null pointer guard and it works now for pods both with and without logs.

    char* elementToReturn = NULL;

    if (apiClient->dataReceived) {
        elementToReturn = strdup((char*)apiClient->dataReceived);
        free(apiClient->dataReceived);
        apiClient->dataReceived = NULL;
        apiClient->dataReceivedLen = 0;
    }
    list_freeList(localVarQueryParameters);
@brendandburns
Copy link
Contributor

read pod logs is a non-restful compliant API, I suspect that we will need to write custom code to correctly handle it.

@homer6
Copy link
Contributor Author

homer6 commented Feb 27, 2024

It works after the code change. I'll submit a PR.

I'm writing a c++ client that wraps this library: https://github.com/homer6/kubepp

@brendandburns
Copy link
Contributor

Unfortunately, that code is generated. If we want to make changes, we need to change the upstream generator (and validate that it doesn't break other API calls)

cc @ityuhui

@brendandburns
Copy link
Contributor

Also, for your C++ client, I would also recommend you take a code generation approach, since it is basically impossible to keep up with the breadth of the Kubernetes API without code generation.

@homer6
Copy link
Contributor Author

homer6 commented Feb 27, 2024

That makes sense. However, I'm finding that a number of function calls are not working as expected. By implementing each call individually, I'm able to validate that the calls are working as expected.

So far, I've only implemented a handful of methods and most of them have failed in different ways.

Sorry for the poor feedback. I'm actually really excited to keep going with wrapping this library.

@ityuhui
Copy link
Member

ityuhui commented Feb 28, 2024

As @brendandburns said, the code in this library is generated by openapi-generator/libcurl https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/C-libcurl

Code changes you commit to this repository will be removed on the next generating.

Feel free to submit your PR here and we can review the code changes and suggest changes to openapi-generator/libcurl.

Don't wait for all changes to be done to submit your PR as your PR is just for review. Only 1 or 2 changes are OK.

@homer6
Copy link
Contributor Author

homer6 commented Mar 5, 2024

Thanks @ityuhui, I've created #227 to review for changes. This change should allow pods logs to be retrieved again.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

5 participants