mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
cri: allow GetContainerEvents
to pass a context
The context can be used for timeout purposes for example, not really for Kubernetes but other consumers like cri-tools. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
parent
d729af9446
commit
ae8f6f002d
@ -335,11 +335,11 @@ func (in instrumentedRuntimeService) CheckpointContainer(ctx context.Context, op
|
||||
return err
|
||||
}
|
||||
|
||||
func (in instrumentedRuntimeService) GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
func (in instrumentedRuntimeService) GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
const operation = "get_container_events"
|
||||
defer recordOperation(operation, time.Now())
|
||||
|
||||
err := in.service.GetContainerEvents(containerEventsCh, connectionEstablishedCallback)
|
||||
err := in.service.GetContainerEvents(ctx, containerEventsCh, connectionEstablishedCallback)
|
||||
recordError(operation, err)
|
||||
return err
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package pleg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@ -192,7 +193,7 @@ func (e *EventedPLEG) watchEventsChannel() {
|
||||
}
|
||||
}
|
||||
|
||||
err := e.runtimeService.GetContainerEvents(containerEventsResponseCh, func(runtimeapi.RuntimeService_GetContainerEventsClient) {
|
||||
err := e.runtimeService.GetContainerEvents(context.Background(), containerEventsResponseCh, func(runtimeapi.RuntimeService_GetContainerEventsClient) {
|
||||
metrics.EventedPLEGConn.Inc()
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -61,7 +61,7 @@ type ContainerManager interface {
|
||||
// CheckpointContainer checkpoints a container
|
||||
CheckpointContainer(ctx context.Context, options *runtimeapi.CheckpointContainerRequest) error
|
||||
// GetContainerEvents gets container events from the CRI runtime
|
||||
GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error
|
||||
GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error
|
||||
}
|
||||
|
||||
// PodSandboxManager contains methods for operating on PodSandboxes. The methods
|
||||
|
@ -716,7 +716,7 @@ func (r *FakeRuntimeService) CheckpointContainer(_ context.Context, options *run
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *FakeRuntimeService) GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
func (f *FakeRuntimeService) GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -822,8 +822,8 @@ func (r *remoteRuntimeService) CheckpointContainer(ctx context.Context, options
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *remoteRuntimeService) GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
containerEventsStreamingClient, err := r.runtimeClient.GetContainerEvents(context.Background(), &runtimeapi.GetEventsRequest{})
|
||||
func (r *remoteRuntimeService) GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error {
|
||||
containerEventsStreamingClient, err := r.runtimeClient.GetContainerEvents(ctx, &runtimeapi.GetEventsRequest{})
|
||||
if err != nil {
|
||||
r.logErr(err, "GetContainerEvents failed to get streaming client")
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user