kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
148 stars 47 forks source link

Draft implementation for watch support #28

Closed ityuhui closed 4 years ago

ityuhui commented 4 years ago

Hi @brendandburns

This is a draft implementation for watch support. We can discuss the design here.

This PR should not be merged because a part of code should be merged to generator repo https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/C-libcurl

ityuhui commented 4 years ago

Hi @clearday4

Cloud you please review the design (especially for the examples/watch_list_pod) too?

ityuhui commented 4 years ago

Append the output of examples/watch_list_pod

watch event raw string:
{"type":"ADDED","object":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test-p5","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/test-p5","uid":"4a59346d-4351-4a94-b5b0-5c93afb74d3e","resourceVersion":"36874225","creationTimestamp":"2020-03-18T09:21:54Z"},"spec":{"volumes":[{"name":"default-token-8p4h4","secret":{"secretName":"default-token-8p4h4","defaultMode":420}}],"containers":[{"name":"my-container","image":"ubuntu:16.04","command":["sleep"],"args":["3600"],"resources":{},"volumeMounts":[{"name":"default-token-8p4h4","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","serviceAccountName":"default","serviceAccount":"default","nodeName":"yhu1a","securityContext":{},"schedulerName":"default-scheduler","tolerations":[{"key":"node.kubernetes.io/not-ready","operator":"Exists","effect":"NoExecute","tolerationSeconds":300},{"key":"node.kubernetes.io/unreachable","operator":"Exists","effect":"NoExecute","tolerationSeconds":300}],"priority":0,"enableServiceLinks":true},"status":{"phase":"Running","conditions":[{"type":"Initialized","status":"True","lastProbeTime":null,"lastTransitionTime":"2020-03-18T09:21:54Z"},{"type":"Ready","status":"True","lastProbeTime":null,"lastTransitionTime":"2020-09-09T10:08:52Z"},{"type":"ContainersReady","status":"True","lastProbeTime":null,"lastTransitionTime":"2020-09-09T10:08:52Z"},{"type":"PodScheduled","status":"True","lastProbeTime":null,"lastTransitionTime":"2020-03-18T09:21:54Z"}],"hostIP":"9.111.254.254","podIP":"10.244.0.5","podIPs":[{"ip":"10.244.0.5"}],"startTime":"2020-03-18T09:21:54Z","containerStatuses":[{"name":"my-container","state":{"running":{"startedAt":"2020-09-09T10:08:52Z"}},"lastState":{"terminated":{"exitCode":0,"reason":"Completed","startedAt":"2020-09-09T09:08:51Z","finishedAt":"2020-09-09T10:08:51Z","containerID":"docker://23702d68fda5f98a2035f03139692e32ebb4c9968f2997a5c83a4904b8e59776"}},"ready":true,"restartCount":4054,"image":"ubuntu:16.04","imageID":"docker-pullable://ubuntu@sha256:bb5b48c7750a6a8775c74bcb601f7e5399135d0a06de004d000e05fd25c1a71c","containerID":"docker://b81c2afbd7cb0549d8cd5fe175c83778eef64450252bb44be36ce3d4140e8f8e","started":true}],"qosClass":"BestEffort"}}}

type: ADDED
pod:
        name: test-p5
clearday4 commented 4 years ago

Hi @clearday4

Cloud you please review the design (especially for the examples/watch_list_pod) too?

Sure. I'm pleased to review this function. I will add a comment after review.

ityuhui commented 4 years ago

The callback function pointer data_callback_func will be added to api client by this PR https://github.com/OpenAPITools/openapi-generator/pull/7467

brendandburns commented 4 years ago

Great, let's wait for that to merge and then we can get this PR merged too.

ityuhui commented 4 years ago

Hi @brendandburns

The code is updated after data_callback_func is merged from openapi-generator. Could you please review the new code change ? Thanks

brendandburns commented 4 years ago

One small nit and then it's ready to merge.

ityuhui commented 4 years ago

The code change is updated.

brendandburns commented 4 years ago

/lgtm /approve

Cool!

k8s-ci-robot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, 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](https://github.com/kubernetes-client/c/blob/master/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