Skip to content

events: migrate cronfederatedhpa to events.k8s.io recorder#7465

Draft
Tej-Katika wants to merge 4 commits into
karmada-io:masterfrom
Tej-Katika:feat/event-recorder-cronfederatedhpa
Draft

events: migrate cronfederatedhpa to events.k8s.io recorder#7465
Tej-Katika wants to merge 4 commits into
karmada-io:masterfrom
Tej-Katika:feat/event-recorder-cronfederatedhpa

Conversation

@Tej-Katika
Copy link
Copy Markdown
Contributor

@Tej-Katika Tej-Katika commented May 3, 2026

Part of #7527.

What this PR does

Proof-of-concept for the migration tracked in #7251. Moves one
controller — cronfederatedhpa — end-to-end from the deprecated
record.EventRecorder (core/v1 Events) to the new
events.EventRecorder (events.k8s.io/v1), and introduces the
EventAction* constant pattern in pkg/events that the remaining
controllers will follow.

The intent is to validate the design before opening per-controller
follow-ups. If reviewers approve the pattern here, subsequent PRs
become mechanical applications of it.

Why cronfederatedhpa

Smallest vertically self-contained slice in the codebase: 1
acquisition site in cmd/controller-manager, 1 in the controller
itself (via NewCronHandler), 5 emission sites across the controller
and the scaling job, no shared recorders with other controllers.

Design choices worth a look

Per-operation actions, not generic verbs. Four EventAction*
constants (StartCronFederatedHPARule, UpdateCronFederatedHPA,
ScaleCronFederatedHPA, UpdateCronFederatedHPAStatus) rather than
a small set of CRUD-style verbs. Matches upstream Kubernetes — see
staging/src/k8s.io/apiserver/pkg/server/dynamiccertificates/ where
actions are operation-specific (SNICertificateReload, etc.). Going
coarser would shrink the constant surface but lose information that
reportingController doesn't already carry.

Reason strings preserved byte-for-byte. "StartRuleFailed",
"UpdateCronFederatedHPAFailed", "ScaleFailed", "UpdateStatusFailed"
remain exactly as before. Constants are introduced for them so
future PRs can reference them, but no wire-format change for any
external consumer keyed on these strings. A new test
(TestEventConstantsPreserveWireFormat) guards against accidental
drift.

related is non-nil where it's meaningful, nil otherwise. The
ScaleFailed event now passes a synthetic *corev1.ObjectReference
built from cronFHPA.Spec.ScaleTargetRef so a consumer can link the
event to the workload that was being scaled. The other four
emissions (StartRuleFailed, UpdateCronFederatedHPAFailed twice,
UpdateStatusFailed) are about the CronFederatedHPA itself with no
meaningful secondary object, and consistently pass nil — matching
@XiShanYongYe-Chang's guidance in the issue thread.

No RBAC changes. No explicit ClusterRole in the deploy artifacts
grants karmada-controller-manager events permission against
karmada-apiserver — it authenticates via TLS and presumably has
broad access. Adding speculative events.k8s.io RBAC here would be
churn for an unverified problem. If events fail to emit at runtime
in a real deployment, RBAC files will be updated in the final
cleanup PR after all controllers have been migrated. Happy to add
an RBAC update here if reviewers prefer the conservative path.

Behavioral test coverage

cronfederatedhpa_events_test.go adds three focused tests:

  • TestTargetReferenceFor — verifies the related object is built
    correctly from ScaleTargetRef.
  • TestEventRecorderEmitsAllFields — captures every field passed
    to Eventf (including action and related, which the upstream
    events.FakeRecorder drops from its channel) using a custom
    recorder, and asserts the full contract end-to-end.
  • TestEventConstantsPreserveWireFormat — wire-format guard for
    the four reason strings.

Scope

 cmd/controller-manager/app/controllermanager.go     |   2 +-
 .../cronfederatedhpa_controller.go                  |  13 +-
 .../cronfederatedhpa/cronfederatedhpa_events_test.go| 140 +++++++++++++++++
 .../cronfederatedhpa/cronfederatedhpa_handler.go    |   6 +-
 .../cronfederatedhpa_handler_test.go                |  16 +-
 .../cronfederatedhpa/cronfederatedhpa_job.go        |  27 ++-
 .../cronfederatedhpa/cronfederatedhpa_job_test.go   |   4 +-
 pkg/events/events.go                                |  42 +++++

The other 37 GetEventRecorderFor sites and their
//nolint:staticcheck markers are intentionally untouched in this
PR.

Open questions for reviewers

  1. Per-operation action constants vs. a smaller set of generic
    verbs — does the per-operation choice match what you have in
    mind for the wider migration?
  2. RBAC: leave for the cleanup PR (current approach), or add the
    events.k8s.io permission in this PR even though I cannot point
    to a specific ClusterRole that needs it?
  3. Should success events (e.g. ScaleSucceeded) be added in
    follow-up PRs? Not added here because the existing scale paths
    return nil even on no-op (target replicas already match), which
    would surface false-positive events. Distinguishing actual-change
    from no-change is a separate refactor.

Verification

  • go build ./...
  • go vet ./...
  • go test ./pkg/controllers/cronfederatedhpa/... (3 new tests + all existing pass)
  • Full unit-test sweep clean apart from three pre-existing failures
    on master unrelated to this change
    (pkg/util/validation/TestValidateCrdsTarBall,
    operator/pkg/tasks/init/TestRunUnpack,
    pkg/karmadactl/cmdinit/utils/TestListFiles).
  • E2E suites not run (require a live cluster).

/kind cleanup

Switch the cronfederatedhpa controller, its handler, and its scaling
job from the deprecated record.EventRecorder to the events.k8s.io/v1
EventRecorder via Manager.GetEventRecorder, and establish the parallel
EventAction* / EventReason* constant convention in pkg/events for the
rest of the migration to follow.

Reason strings are kept byte-for-byte identical so consumers watching
for "StartRuleFailed", "UpdateCronFederatedHPAFailed", "ScaleFailed",
or "UpdateStatusFailed" continue to match. Action values are new and
operation-scoped, matching upstream Kubernetes where action describes
what the controller did to the regarding object.

The ScaleFailed event now passes a synthetic ObjectReference built
from cronFHPA.Spec.ScaleTargetRef as the related object, so consumers
can link the failure to the workload that was being scaled. The four
remaining emissions naturally have no secondary object and pass nil.

A behavioral test in cronfederatedhpa_events_test.go captures every
field passed to Eventf, including action and related which the
upstream events.FakeRecorder drops from its channel, and guards the
reason strings against accidental drift.

No RBAC changes are included; karmada-controller-manager has no
explicit ClusterRole granting events permission against
karmada-apiserver in the deploy artifacts. RBAC will be revisited in
the cleanup PR after all controllers are migrated.

Signed-off-by: Tejashwar Reddy Katika <tejashwar1029@gmail.com>
@karmada-bot karmada-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 3, 2026
@karmada-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign seanlaii for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request serves as a proof-of-concept for migrating controllers from the deprecated core/v1 EventRecorder to the events.k8s.io/v1 API. By focusing on the cronfederatedhpa controller, the changes establish a robust, reusable pattern for event emission that includes per-operation action constants and improved context for event consumers. The design ensures backward compatibility for existing event reason strings while providing a scalable framework for future controller migrations across the codebase.

Highlights

  • Event API Migration: Migrated the cronfederatedhpa controller from the deprecated core/v1 EventRecorder to the modern events.k8s.io/v1 recorder.
  • Standardized Event Pattern: Introduced a new pattern for event emission using operation-specific EventAction constants in pkg/events, ensuring consistency for future controller migrations.
  • Wire Format Preservation: Maintained byte-for-byte compatibility for existing event reason strings to prevent breaking external consumers, verified by a new unit test.
  • Enhanced Event Context: Improved event reporting by passing relevant object references (related) where applicable, specifically linking scaling failures to the target workload.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 3, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrated the CronFederatedHPA controller to the Kubernetes events.k8s.io/v1 API, replacing the deprecated EventRecorder and introducing structured event reasons and actions, supported by new unit tests. Feedback identified the unsafe use of err.Error() as a format string in Eventf calls, recommending the use of a literal "%v" instead to prevent potential formatting errors. Additionally, the reviewer pointed out style guide violations concerning the missing compile-time interface compliance check for the controller and the multi-line signature of the NewCronFederatedHPAJob function.

if !helper.IsCronFederatedHPARuleSuspend(rule) {
if err := c.CronHandler.CreateCronJobForExecutor(cronFHPA, rule); err != nil {
c.EventRecorder.Event(cronFHPA, corev1.EventTypeWarning, "StartRuleFailed", err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonStartCronFederatedHPARuleFailed, events.EventActionStartCronFederatedHPARule, err.Error())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using err.Error() directly as the format string in Eventf is unsafe because the error message might contain format specifiers (like %) which would cause fmt.Sprintf to fail or produce corrupted output. It is safer to use a literal format string like "%v" and pass the error as an argument.

Suggested change
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonStartCronFederatedHPARuleFailed, events.EventActionStartCronFederatedHPARule, err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonStartCronFederatedHPARuleFailed, events.EventActionStartCronFederatedHPARule, "%v", err)


if err := c.updateRuleHistory(ctx, cronFHPA, rule); err != nil {
c.EventRecorder.Event(cronFHPA, corev1.EventTypeWarning, "UpdateCronFederatedHPAFailed", err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, err.Error())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using err.Error() directly as the format string in Eventf is unsafe. Please use a literal format string and pass the error as an argument to avoid issues with unexpected format specifiers in the error message.

Suggested change
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, "%v", err)

}
if err := c.Client.Status().Update(ctx, cronFHPA); err != nil {
c.EventRecorder.Event(cronFHPA, corev1.EventTypeWarning, "UpdateCronFederatedHPAFailed", err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, err.Error())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using err.Error() directly as the format string in Eventf is unsafe. Please use a literal format string and pass the error as an argument.

Suggested change
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, err.Error())
c.EventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAFailed, events.EventActionUpdateCronFederatedHPA, "%v", err)

}
if err != nil {
c.eventRecorder.Event(cronFHPA, corev1.EventTypeWarning, "UpdateStatusFailed", err.Error())
c.eventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAStatusFailed, events.EventActionUpdateCronFederatedHPAStatus, err.Error())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using err.Error() directly as the format string in Eventf is unsafe. Please use a literal format string like "%v" and pass the error as an argument to ensure robust event message generation.

Suggested change
c.eventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAStatusFailed, events.EventActionUpdateCronFederatedHPAStatus, err.Error())
c.eventRecorder.Eventf(cronFHPA, nil, corev1.EventTypeWarning, events.EventReasonUpdateCronFederatedHPAStatusFailed, events.EventActionUpdateCronFederatedHPAStatus, "%v", err)

Comment on lines 47 to 48
// CronFHPAController is used to operate CronFederatedHPA.
type CronFHPAController struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, any struct that explicitly implements an interface must include a compile-time interface compliance check.

// Check if our CronFHPAController implements necessary interface
var _ controllerruntime.Reconciler = &CronFHPAController{}

// CronFHPAController is used to operate CronFederatedHPA.
References
  1. Any struct that explicitly implements an interface must include a compile-time interface compliance check using the pattern: var _ InterfaceName = &StructName{}. (link)

Comment on lines 70 to 71
func NewCronFederatedHPAJob(client client.Client, eventRecorder clientgoevents.EventRecorder, scheduler *gocron.Scheduler,
cronFHPA *autoscalingv1alpha1.CronFederatedHPA, rule autoscalingv1alpha1.CronFederatedHPARule) *ScalingJob {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The repository style guide specifies that function signatures should preferably be written on a single line, including the parameter list and return types.

func NewCronFederatedHPAJob(client client.Client, eventRecorder clientgoevents.EventRecorder, scheduler *gocron.Scheduler, cronFHPA *autoscalingv1alpha1.CronFederatedHPA, rule autoscalingv1alpha1.CronFederatedHPARule) *ScalingJob {
References
  1. Function signatures should preferably be written on a single line, including the parameter list and return types. (link)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 3, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.01%. Comparing base (9d87acb) to head (52f5437).
⚠️ Report is 42 commits behind head on master.

Files with missing lines Patch % Lines
...rs/cronfederatedhpa/cronfederatedhpa_controller.go 0.00% 4 Missing ⚠️
...ntrollers/cronfederatedhpa/cronfederatedhpa_job.go 63.63% 4 Missing ⚠️
cmd/controller-manager/app/controllermanager.go 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7465      +/-   ##
==========================================
+ Coverage   41.90%   42.01%   +0.10%     
==========================================
  Files         879      879              
  Lines       54326    54444     +118     
==========================================
+ Hits        22766    22872     +106     
- Misses      29833    29849      +16     
+ Partials     1727     1723       -4     
Flag Coverage Δ
unittests 42.01% <47.05%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace err.Error() passed as the 'note' format string with the safe
"%v", err pattern at the four Eventf call sites that emit a bare error
message. The new events.k8s.io/v1 Eventf signature treats 'note' as a
printf format string, unlike the deprecated record.EventRecorder.Event
where the message was used verbatim. An error containing format verbs
(e.g. %v from a wrapped error) or a raw % (e.g. URL-encoded path in an
HTTP error) would otherwise be reinterpreted by fmt.Sprintf and produce
garbled output. A new TestEventfFormatStringSafety regression test pins
this property using a hostile error message.

Also:
 - Add the compile-time interface compliance check
   var _ reconcile.Reconciler = &CronFHPAController{} per the repository
   style guide.
 - Collapse the NewCronFederatedHPAJob signature to a single line per
   the repository style guide.
Signed-off-by: Tejashwar Reddy Katika <tejashwar1029@gmail.com>
- reorder imports: clientgoevents before klog/v2
- use any instead of interface{} in capturingRecorder.Eventf

Signed-off-by: Tejashwar Reddy Katika <tejashwar1029@gmail.com>
- 34 action constants covering every current EventReason* site
- consolidated into one block at the end of events.go
- the 4 cronfederatedhpa actions added inline by 862e028 move here

Signed-off-by: Tejashwar Reddy Katika <tejashwar1029@gmail.com>
@Tej-Katika
Copy link
Copy Markdown
Contributor Author

Action table per the design discussed in #7251. The constants are in commit 52f543764.

Action namespace (34 constants)

Paired actions (cover Failed/Succeed reason pairs)

Action constant Value Paired reason(s) Emitting packages
EventActionCreateExecutionSpace CreateExecutionSpace CreateExecutionSpaceFailed/Succeed cluster
EventActionRemoveExecutionSpace RemoveExecutionSpace RemoveExecutionSpaceFailed/Succeed cluster
EventActionTaintCluster TaintCluster TaintClusterFailed/Succeed cluster, taint
EventActionSyncImpersonationConfig SyncImpersonationConfig SyncImpersonationConfigFailed/Succeed unifiedauth
EventActionReflectStatus ReflectStatus ReflectStatusFailed/Succeed status/work
EventActionInterpretHealth InterpretHealth InterpretHealthFailed/Succeed status/work
EventActionSyncWorkload SyncWorkload SyncWorkloadFailed/Succeed execution
EventActionCleanupWork CleanupWork CleanupWorkFailed (no paired success) binding
EventActionSyncScheduleResultToDependencies SyncScheduleResultToDependencies SyncScheduleResultToDependenciesFailed/Succeed dependenciesdistributor
EventActionSyncWork SyncWork SyncWorkFailed/Succeed binding (RB+CRB)
EventActionAggregateStatus AggregateStatus AggregateStatusFailed/Succeed status, helper/workstatus
EventActionScheduleBinding ScheduleBinding ScheduleBindingFailed/Succeed scheduler
EventActionDescheduleBinding DescheduleBinding DescheduleBindingFailed/Succeed descheduler
EventActionEvictWorkloadFromCluster EvictWorkloadFromCluster EvictWorkloadFromClusterFailed/Succeed helper/binding
EventActionSyncFederatedResourceQuota SyncFederatedResourceQuota SyncFederatedResourceQuotaFailed/Succeed federatedresourcequota/sync
EventActionCollectFederatedResourceQuotaStatus CollectFederatedResourceQuotaStatus CollectFederatedResourceQuotaStatusFailed/Succeed federatedresourcequota/status
EventActionCollectFederatedResourceQuotaOverallStatus CollectFederatedResourceQuotaOverallStatus CollectFederatedResourceQuotaOverallStatusFailed/Succeed federatedresourcequota/enforcement
EventActionApplyPolicy ApplyPolicy ApplyPolicyFailed/Succeed detector
EventActionApplyOverridePolicy ApplyOverridePolicy ApplyOverridePolicyFailed/Succeed overridemanager
EventActionPreemptPolicy PreemptPolicy PreemptPolicyFailed/Succeed detector/preemption
EventActionGetDependencies GetDependencies GetDependenciesFailed/Succeed dependenciesdistributor
EventActionGetComponents GetComponents GetComponentsFailed/Succeed detector
EventActionGetReplicas GetReplicas GetReplicasFailed/Succeed detector
EventActionSyncDerivedService SyncDerivedService SyncDerivedServiceFailed/Succeed mcs/service_import
EventActionSyncService SyncService SyncServiceFailed/Succeed multiclusterservice
EventActionDispatchEndpointSlice DispatchEndpointSlice DispatchEndpointSliceFailed/Succeed endpointslice_dispatch

Singleton actions (reasons with no paired success/failure variant)

Action constant Value Singleton reason Emitting package
EventActionDispatchWork DispatchWork WorkDispatching execution
EventActionResolveDependencyPolicy ResolveDependencyPolicy DependencyPolicyConflict dependenciesdistributor/policy_utils
EventActionResolveCluster ResolveCluster ClusterNotFound multiclusterservice
EventActionValidateClusterAPI ValidateClusterAPI APIIncompatible multiclusterservice

CronFederatedHPA (this PoC slice)

Action constant Value Paired reason Emitting package
EventActionStartCronFederatedHPARule StartCronFederatedHPARule StartRuleFailed cronfederatedhpa
EventActionUpdateCronFederatedHPA UpdateCronFederatedHPA UpdateCronFederatedHPAFailed cronfederatedhpa
EventActionScaleCronFederatedHPA ScaleCronFederatedHPA ScaleFailed cronfederatedhpa
EventActionUpdateCronFederatedHPAStatus UpdateCronFederatedHPAStatus UpdateStatusFailed cronfederatedhpa

Naming convention

  • Paired reasons (<Op>Failed/<Op>Succeed): action is <Op> — drop the suffix. E.g. EventReasonScheduleBindingFailed/SucceedEventActionScheduleBinding.
  • Singletons: action is named after the operation that emits the event, not after the outcome. E.g. EventReasonClusterNotFound is emitted while resolving a cluster, so action is ResolveCluster.
  • Operation-scoped (not controller-scoped), matching upstream Kubernetes — e.g. kube-apiserver's dynamiccertificates uses SNICertificateReload, CACertificateReload. The reportingController field already identifies the source, so the controller name doesn't repeat in the action.

Out of scope, flagged for follow-up

13 literal-string reasons are currently emitted without EventReason* constants. Constants for these will be added inside each per-controller migration PR, not here:

  • pkg/controllers/federatedhpa/federatedhpa_controller.go: FailedGetScale, FailedGetScaleTargetRef, FailedGetBindings, FailedGetTargetClusters, FailedComputeMetricsReplicas, FailedRescale, SuccessfulRescale, SelectorRequired, InvalidSelector, AmbiguousSelector, FailedUpdateStatus
  • pkg/servicenameresolutiondetector/coredns/detector.go: LoadCorednsConditionFailed, StoreCorednsConditionFailed
  • operator/pkg/controller/karmada/validating.go: validation-error literal reason

Two pre-existing reason-name vs reason-value mismatches in pkg/events/events.go:

  • EventReasonSyncFederatedResourceQuotaFailed = "SyncWorkFailed" clashes with EventReasonSyncWorkFailed
  • EventReasonCollectFederatedResourceQuotaStatusFailed = "AggregateStatusFailed" clashes with EventReasonAggregateStatusFailed

These emit identical wire strings across different operations. Worth a dedicated cleanup PR; not safe to change inside the events-API migration since the reason string is the externally-visible surface.

@Tej-Katika
Copy link
Copy Markdown
Contributor Author

cc @XiShanYongYe-Chang Please take a look. Thanks!

@XiShanYongYe-Chang
Copy link
Copy Markdown
Member

Thanks for your hard work @Tej-Katika
I might look at it later. I've been dealing with something else recently, but I'll handle it as soon as possible.

@XiShanYongYe-Chang
Copy link
Copy Markdown
Member

/assign

@XiShanYongYe-Chang
Copy link
Copy Markdown
Member

Thanks @Tej-Katika

Your analysis is very detailed, and I agree with your approach. Perhaps we could create a separate issue for this analysis, and track it to 7521, and then I will further invite other interested people to review it. What do you think?

@Tej-Katika
Copy link
Copy Markdown
Contributor Author

Thanks for taking a look @XiShanYongYe-Chang — happy the namespace shape works for you.

Splitting the analysis out into its own issue under #7251 makes sense to me. The action table will be referenced by every per-controller follow-up, so it's worth having a dedicated place rather than being buried in a PR comment. I'll open the issue today with:

  • The full 34-action table (paired + singleton + the 4 added in this PoC)
  • The naming convention (operation-scoped, drop the Failed/Succeed suffix, derive singleton actions from the emitting operation)
  • The two out-of-scope follow-ups already flagged — the 13 literal-string reasons and the 2 pre-existing reason-name/value mismatches

One question on sequencing: should I keep #7465 in draft until the design issue gets reviewer feedback, or move it out of draft now so the implementation review can run in parallel with the design discussion? Either works for me — happy to follow whichever you prefer.

@XiShanYongYe-Chang
Copy link
Copy Markdown
Member

The current PR should be a subtask of the split issue. We can start implementing it step by step once others have no objections.

@Tej-Katika
Copy link
Copy Markdown
Contributor Author

Sounds good. I'll keep #7465 in draft as a subtask of the new design issue and move it forward once the design lands without objections. Opening the issue today and will ping you when it's up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants