-
Notifications
You must be signed in to change notification settings - Fork 274
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
Consistent Use of Context #642
Comments
Thanks @devigned for reporting the issue and sharing the ideas to provide better observability. Would you like to contribute the OpenTelemetry support? |
Definitely a possibility. I'm discussing this with @ritazh. First thing I wanted to do is open the issue and start the discussion. I'd suspect an enhancement doc would be proper for such a change. The major items that would need to be changed:
wdyt? |
@devigned thanks, LGTM |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
@devigned are you still available to work on this? |
Yes, but it there are a couple things ahead of this. I think I'll be able to start it toward the end of the month. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Is your feature request related to a problem?/Why is this needed
Much of the context usage in the project is ineffectual. For example, the Azure DiskClient.Get uses a context, but the context provided to the method is largely ineffectual. As you can see here, a call to AttachDisk first calls
getContextWithCancel
, which simply constructs acontext.Background
with cancelation. The cancellation is only called in a defer when callingAzureDisk.Get
. The cancellation provides no benefit as a way of cancelling processing further down the tree of execution.Describe the solution you'd like in detail
Context should be used to time bound execution hierarchies, and are best when they start from the root of execution. Perhaps, having a context started at the CLI entry point where OS signals are used to establish the initial lifespan of the root context.
Further, context should be exposed upward from any I/O dependent task. If a network request or any other long running activity is called, the context should be required and passed in from higher up in the call hierarchy.
Additional context
By setting a consistent approach to passing context, the application will also be able to be more easily instrumented with tracing. For example, Cluster API Provider Azure uses OpenTelemetry to create a distributed trace of the entire reconciliation loop for all resources, https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/8a44c6d6f7b394b7929c3ae5b0e79730609c6cf1/controllers/azurecluster_controller.go#L114-L120. This makes it super easy to observe what the operator is doing and provides insight when trying to diagnosis issues. In fact, in CAPZ, we are exporting the traces to Application Insights to visualize the running operator. We'd love to be able to something similar in Cloud Provider Azure.
/cc @craiglpeters
The text was updated successfully, but these errors were encountered: