Skip to content

Commit

Permalink
Add missing context to agent's updatestatus (#2990)
Browse files Browse the repository at this point in the history
Code should not use context.Background.
  • Loading branch information
manno authored Oct 24, 2024
1 parent 3784b8c commit 5d12f75
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/cmd/agent/deployer/monitor/updatestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (m *Monitor) updateFromResources(ctx context.Context, logger logr.Logger, b
}

bd.Status.NonReadyStatus = nonReady(logger, plan, bd.Spec.Options.IgnoreOptions)
bd.Status.ModifiedStatus = modified(m.client, logger, plan, resourcesPreviousRelease)
bd.Status.ModifiedStatus = modified(ctx, m.client, logger, plan, resourcesPreviousRelease)
bd.Status.Ready = false
bd.Status.NonModified = false

Expand Down Expand Up @@ -249,7 +249,7 @@ func nonReady(logger logr.Logger, plan desiredset.Plan, ignoreOptions fleet.Igno
// The function iterates through the plan's create, delete, and update actions and constructs a modified status
// for each resource.
// If the number of modified statuses exceeds 10, the function stops and returns the current result.
func modified(c client.Client, logger logr.Logger, plan desiredset.Plan, resourcesPreviousRelease *helmdeployer.Resources) (result []fleet.ModifiedStatus) {
func modified(ctx context.Context, c client.Client, logger logr.Logger, plan desiredset.Plan, resourcesPreviousRelease *helmdeployer.Resources) (result []fleet.ModifiedStatus) {
defer func() {
sort.Slice(result, func(i, j int) bool {
return sortKey(result[i]) < sortKey(result[j])
Expand All @@ -269,7 +269,7 @@ func modified(c client.Client, logger logr.Logger, plan desiredset.Plan, resourc
Namespace: key.Namespace,
Name: key.Name,
}
err := c.Get(context.Background(), key, obj)
err := c.Get(ctx, key, obj)

exists := !apierrors.IsNotFound(err)

Expand Down

0 comments on commit 5d12f75

Please sign in to comment.