Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make generating NotScale events configurable; use logs when disabled #204

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

levipe01
Copy link
Collaborator

@levipe01 levipe01 commented Mar 8, 2024

What does this PR do?

Add skipNotScalingEvents config option in WPA to disable NotScaling Kubernetes events. When disabled this will generate a log instead and update the Status of the WPA.

Motivation

Eliminate WPA error logs that are the result of the Kubernetes API server rate limiting WPA event writes

Additional Notes

  • When updating the Status we use the ScalingActive Condition Type. This is initially set here and we override the condition & message to show that the replicas are correctly calculated, however we are choosing not to scale.
  • Leaving the default behavior to continue to write Kubernetes Events in the event that 3rd party users are currently monitoring on these.

Describe your test plan

  • Enabling this feature should result in the Kubernetes events with a message of Decided not to scale to appear as logs instead.
  • When describing the WPA object you should see the Status update with a message like the below when not scaling.
Status:
  Conditions:
    Last Transition Time:  2024-03-21T21:46:18Z
    Message:               the WPA was able to successfully calculate a replica count and decided not to scale Deployment/datadog/php-apache to 9 (last scale time was 2024-03-21 21:27:48 +0000 UTC )
    Reason:                NotScaling
    Status:                True
    Type:                  ScalingActive

@levipe01 levipe01 requested a review from a team as a code owner March 8, 2024 19:16
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: bug, enhancement, refactoring, documentation, tooling, dependencies

@levipe01 levipe01 added this to the 0.7.1 milestone Mar 8, 2024
@levipe01 levipe01 added the enhancement New feature or request label Mar 8, 2024
github-actions[bot]
github-actions bot previously approved these changes Mar 8, 2024
levan-m
levan-m previously approved these changes Mar 11, 2024
@levan-m levan-m requested a review from vboulineau March 13, 2024 14:53
@vboulineau
Copy link
Contributor

The code LGTM but I don't think we should emit an event ever. Either we emit a debug log or we just update the Status with last eval timestamp or we just produce a metric with 1 value every time we eval.

clamoriniere
clamoriniere previously approved these changes Mar 21, 2024
github-actions[bot]
github-actions bot previously approved these changes Mar 21, 2024
@levipe01 levipe01 changed the title Make generating NotScale events configurable; use logs when disabled Remove NotScale events; add option to log these decisions, otherwise update Status Mar 21, 2024
github-actions[bot]
github-actions bot previously approved these changes Mar 21, 2024
@levipe01 levipe01 changed the title Remove NotScale events; add option to log these decisions, otherwise update Status Make generating NotScale events configurable; use logs when disabled Mar 21, 2024
r.eventRecorder.Eventf(wpa, corev1.EventTypeNormal, datadoghqv1alpha1.ReasonNotScaling, fmt.Sprintf("Decided not to scale %s to %d (last scale time was %v )", reference, desiredReplicas, wpa.Status.LastScaleTime))
if r.Options.SkipNotScalingEvents {
setCondition(wpa, autoscalingv2.ScalingActive, corev1.ConditionTrue, datadoghqv1alpha1.ConditionReasonNotScaling, "the WPA was able to successfully calculate a replica count and decided not to scale %s to %d (last scale time was %v )", reference, desiredReplicas, wpa.Status.LastScaleTime)
logger.Info(fmt.Sprintf("Decided not to scale %s to %d (last scale time was %v )", reference, desiredReplicas, wpa.Status.LastScaleTime))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having the info once in the status is enough. The WPA is already a big logger, could be a debug log if you want to keep it.

@levipe01 levipe01 merged commit 9adcbcf into main Mar 22, 2024
23 checks passed
@levipe01 levipe01 deleted the levipe01/notscale-events-config-option branch March 22, 2024 16:44
levipe01 added a commit that referenced this pull request Mar 22, 2024
…204)

* Make generating NotScale events configurable; use logs when disabled

* Adding status update along w/ log line

* removed info level log line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants