Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: feature

# Change summary; a 80ish characters long description of the change.
summary: Clear agent.upgrade_attempts when upgrade is complete.

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
description: |
The new AutomaticAgentUpgradeTask Kibana task sets the upgrade_attempts property in agents it upgrades.
This property is used to track upgrade retries and should therefore be cleared when the upgrade is complete.
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: fleet-server

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
pr: https://github.com/elastic/fleet-server/pull/4528

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
issue: https://github.com/elastic/ingest-dev/issues/4720
1 change: 1 addition & 0 deletions internal/pkg/api/handleAck.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ func (ack *AckT) handleUpgrade(ctx context.Context, zlog zerolog.Logger, agent *
dl.FieldUpgradeStartedAt: nil,
dl.FieldUpgradeStatus: nil,
dl.FieldUpgradedAt: now,
dl.FieldUpgradeAttempts: nil,
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/api/handleCheckin.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (ct *CheckinT) validateRequest(zlog zerolog.Logger, w http.ResponseWriter,
}

wTime := pollDuration + time.Minute
rc := http.NewResponseController(w) //nolint:bodyclose // we are working with a ResponseWriter not a Respons
rc := http.NewResponseController(w)
if err := rc.SetWriteDeadline(start.Add(wTime)); err != nil {
zlog.Warn().Err(err).Time("write_deadline", start.Add(wTime)).Msg("Unable to set checkin write deadline.")
} else {
Expand Down Expand Up @@ -521,6 +521,7 @@ func (ct *CheckinT) markUpgradeComplete(ctx context.Context, agent *model.Agent)
dl.FieldUpgradeStartedAt: nil,
dl.FieldUpgradeStatus: nil,
dl.FieldUpgradedAt: time.Now().UTC().Format(time.RFC3339),
dl.FieldUpgradeAttempts: nil,
}
body, err := doc.Marshal()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/dl/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
FieldUpgradeStartedAt = "upgrade_started_at"
FieldUpgradeStatus = "upgrade_status"
FieldUpgradeDetails = "upgrade_details"
FieldUpgradeAttempts = "upgrade_attempts"

FieldAuditUnenrolledTime = "audit_unenrolled_time"
FieldAuditUnenrolledReason = "audit_unenrolled_reason"
Expand Down