kubernetes-sigs / cli-utils

This repo contains binaries that built from libraries in cli-runtime.
Apache License 2.0
154 stars 77 forks source link

Avoid reporting context cancellation or deadline expiration as resource error #533

Closed mortent closed 2 years ago

mortent commented 2 years ago

This updates the kstatus framework to better handle context.Canceled and context.DeadlineExceeded. Currently, if the context is canceled or the deadline expires while calling the Get or List functions on the controller-runtime client, a context error is returned, but the status readers or the polling functionality doesn't handle this properly. The error is returned for every resource and the polling doesn't immediately stop. With this change, if the error returned from the ClusterReader is either context.Canceled or context.DeadlineExceeded, the status reader will return those as a separate error instead of including it in the *event.ResourceStatus. This is then handled appropriately by the poller to immediately stop work and return. This should address the issue referenced in https://github.com/fluxcd/pkg/blob/main/ssa/manager_wait.go#L89

BREAKING CHANGE: The ReadStatus and ReadStatusForObject functions on the StatusReader interface updated to return an error in addition to *event.ResourceStatus

cblecker commented 2 years ago

/check-cla

mortent commented 2 years ago

/test cli-utils-presubmit-master

It seems like the TestApplier/apply_resource_with_existing_object_belonging_to_different_inventory test is flaking at times. I have created an issue for this and we can try to address that separately: https://github.com/kubernetes-sigs/cli-utils/issues/534

k8s-ci-robot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: karlkfi, mortent

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-sigs/cli-utils/blob/master/OWNERS)~~ [mortent] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment