feat: add status.resourcesCount field to appset and change limit default (#24698)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
This commit is contained in:
Alexander Matyushentsev 2025-09-23 09:11:36 -07:00 committed by GitHub
parent 598dbcb61d
commit f6f1a42492
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 842 additions and 777 deletions

View file

@ -1435,12 +1435,13 @@ func (r *ApplicationSetReconciler) updateResourcesStatus(ctx context.Context, lo
sort.Slice(statuses, func(i, j int) bool {
return statuses[i].Name < statuses[j].Name
})
resourcesCount := int64(len(statuses))
if r.MaxResourcesStatusCount > 0 && len(statuses) > r.MaxResourcesStatusCount {
logCtx.Warnf("Truncating ApplicationSet %s resource status from %d to max allowed %d entries", appset.Name, len(statuses), r.MaxResourcesStatusCount)
statuses = statuses[:r.MaxResourcesStatusCount]
}
appset.Status.Resources = statuses
appset.Status.ResourcesCount = resourcesCount
// DefaultRetry will retry 5 times with a backoff factor of 1, jitter of 0.1 and a duration of 10ms
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
namespacedName := types.NamespacedName{Namespace: appset.Namespace, Name: appset.Name}
@ -1453,6 +1454,7 @@ func (r *ApplicationSetReconciler) updateResourcesStatus(ctx context.Context, lo
}
updatedAppset.Status.Resources = appset.Status.Resources
updatedAppset.Status.ResourcesCount = resourcesCount
// Update the newly fetched object with new status resources
err := r.Client.Status().Update(ctx, updatedAppset)

5
assets/swagger.json generated
View file

@ -7322,6 +7322,11 @@
"items": {
"$ref": "#/definitions/applicationv1alpha1ResourceStatus"
}
},
"resourcesCount": {
"description": "ResourcesCount is the total number of resources managed by this application set. The count may be higher than actual number of items in the Resources field when\nthe number of managed resources exceeds the limit imposed by the controller (to avoid making the status field too large).",
"type": "integer",
"format": "int64"
}
}
},

View file

@ -88,3 +88,9 @@ If you do not want your CronJob to affect the Application's aggregated Health, y
Due to security reasons ([GHSA-786q-9hcg-v9ff](https://github.com/argoproj/argo-cd/security/advisories/GHSA-786q-9hcg-v9ff)),
the project API response was sanitized to remove sensitive information. This includes
credentials of project-scoped repositories and clusters.
## ApplicationSet `resources` field of `status` resource is limited to 5000 elements by default
The `resources` field of the `status` resource of an ApplicationSet is now limited to 5000 elements by default. This is
to prevent status bloat and exceeding etcd limits. The limit can be configured by setting the `applicationsetcontroller.status.max.resources.count`
field in the `argocd-cmd-params-cm` ConfigMap.

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -17823,6 +17823,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -23737,6 +23737,9 @@ spec:
type: string
type: object
type: array
resourcesCount:
format: int64
type: integer
type: object
required:
- metadata

View file

@ -805,6 +805,9 @@ type ApplicationSetStatus struct {
ApplicationStatus []ApplicationSetApplicationStatus `json:"applicationStatus,omitempty" protobuf:"bytes,2,name=applicationStatus"`
// Resources is a list of Applications resources managed by this application set.
Resources []ResourceStatus `json:"resources,omitempty" protobuf:"bytes,3,opt,name=resources"`
// ResourcesCount is the total number of resources managed by this application set. The count may be higher than actual number of items in the Resources field when
// the number of managed resources exceeds the limit imposed by the controller (to avoid making the status field too large).
ResourcesCount int64 `json:"resourcesCount,omitempty" protobuf:"varint,4,opt,name=resourcesCount"`
}
// ApplicationSetCondition contains details about an applicationset condition, which is usually an error or warning

File diff suppressed because it is too large Load diff

View file

@ -369,6 +369,10 @@ message ApplicationSetStatus {
// Resources is a list of Applications resources managed by this application set.
repeated ResourceStatus resources = 3;
// ResourcesCount is the total number of resources managed by this application set. The count may be higher than actual number of items in the Resources field when
// the number of managed resources exceeds the limit imposed by the controller (to avoid making the status field too large).
optional int64 resourcesCount = 4;
}
// ApplicationSetStrategy configures how generated Applications are updated in sequence.