Comments (13)
I think the best way is setting a timetout in the parameter of watch function, after timeouts, free up the resource same with non-watch example.
e.g.
CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
NULL, /* pretty */
0, /* allowWatchBookmarks */
NULL, /* continue */
NULL, /* fieldSelector */
NULL, /* labelSelector */
0, /* limit */
NULL, /* resourceVersion */
30, /* timeoutSeconds */ <------------------ Set the timeout
1 /* watch */
);
from c.
I think the best way is setting a timetout in the parameter of watch function, after timeouts, free up the resource same with non-watch example.
e.g.
CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */ NULL, /* pretty */ 0, /* allowWatchBookmarks */ NULL, /* continue */ NULL, /* fieldSelector */ NULL, /* labelSelector */ 0, /* limit */ NULL, /* resourceVersion */ 30, /* timeoutSeconds */ <------------------ Set the timeout 1 /* watch */ );
Application want to watch the events util they stop watching.
They want to receive the state of the only changed object.
But if we set the timeout, application should watch again and get the entire status of object again.
what is the difference from get function?
from c.
When timeout
is set, watch function will not return even though it receives the state change.
The watch function returns only the timeout is reached.
from c.
It doesn't meet our requirement.
application wants to know immediately if pod is scaled in or out or deleted or modified.
from c.
Suppose setting timeout
as 3600 seconds (1 hour),
Watch function can receive events such as pod deletion/modification (your callback function will be called) immediately but Watch function will not stop watching. After 3600 seconds, the watch function will return and stop watching.
from c.
But After 1 hour,
if application call watch function again, K8s API server send the all pod state again,
Therefore, if application wants to know the pod status has changed, compare to previous status and the previous information should be stored to db.
There is no different from GET that we need to store the previous state.
from c.
I think you can set a longer timeout.
Or run watch function forever in a thread. After the program ends, allocated memory will be released.
And I see you have tried pthread_cancel()
, then when will you call pthread_cancel()
?
from c.
If I kill the watch thread with pthread_cancel, resource leak occurs.
Since watch thread is blocked on curl_easy_perform, curl handle, curl mime, apiClient and cJSON_Parse are leak
from c.
Could you please run watch function forever in a thread ?
After the program ends, allocated memory will be released.
from c.
right. so application can't stop watching until now.
from c.
Can't you use pthread_cleanup_push
to register a cleanup handler for the watch pthread
?
https://man7.org/linux/man-pages/man3/pthread_cleanup_push.3.html
from c.
I'm closing this since I think that the issue issue is resolved via the Libcurl progress functions.
from c.
Please use /reopen
if there is further assistance needed.
from c.
Related Issues (20)
- `sendInitialEvents` error HOT 14
- v0.8.0 release plan HOT 2
- CoreV1API_listPodForAllNamespaces/CoreV1API_listNamespacedPod API return 422 error HOT 19
- Is it possible to change the cURL HTTP accpet header? HOT 1
- Creating Deployment Patch using the AppsV1API_patchNamespacedDeployment HOT 3
- doc: Some parameter types of functions in the API documentation are wrong
- How to get label key and value? HOT 3
- v0.9.0 release plan HOT 2
- libwebsockets make fails with error: conflicting types for ‘lws_tls_server_abort_connection HOT 4
- How to compile as static .a file? HOT 7
- v1_pod_list_parseFromJSON does not parse pod statuses HOT 7
- CoreV1API_readNamespacedPodLog doesn't work and contains a segfault HOT 9
- Both Custom Resource Definitions and Custom Resources strip the spec from their object. HOT 1
- Feature Request: Decoupling parsing from network message passing HOT 5
- Remove printf from internal function HOT 1
- Issue with Running list_pod_incluster Example Code - HTTP 422 HOT 5
- Conan support HOT 2
- Using the operating system provided websockets library HOT 2
- Need bump actions/checkout@v3 HOT 1
- v0.10.0 release plan HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c.