Skip to content

Fix CronWorkflow CR not being updated on target ChaosInfrastructure#5524

Draft
xorjnox wants to merge 3 commits into
litmuschaos:masterfrom
xorjnox:ranjan/litmus-cronworkflow-fix
Draft

Fix CronWorkflow CR not being updated on target ChaosInfrastructure#5524
xorjnox wants to merge 3 commits into
litmuschaos:masterfrom
xorjnox:ranjan/litmus-cronworkflow-fix

Conversation

@xorjnox

@xorjnox xorjnox commented May 26, 2026

Copy link
Copy Markdown
Contributor
The docker-build-graphql-server Trivy scan failure is pre-existing and unrelated to these changes. The vulnerabilities reported (krb5-libs, libcap, go-billy/v5, go-git/v5) exist in the current master build and are not introduced by this PR.     

Proposed changes

Fix CronWorkflow CR not being updated on target ChaosInfrastructure when a ChaosExperiment is edited in ChaosCenter.

Root cause

SaveChaosExperiment in handler.go called ProcessExperimentUpdate with a hardcoded nil for StateData. In ops/service.go, the subscriber dispatch (SendExperimentToSubscriber) is gated on r != nil — so every save/edit via the UI silently updated MongoDB but never sent any message to the in-cluster subscriber. The CronWorkflow CR remained stale until manually deleted.

Fix

  • Added r *store.StateData parameter to SaveChaosExperiment and passed data_store.Store from the resolver, matching the pattern already used by UpdateChaosExperiment and DeleteChaosExperiment.
  • For CronWorkflow experiments: instead of a plain update, the handler now sends a delete of the old CR followed by a create with the new manifest. This guarantees the Argo CronWorkflow controller picks up all changes (schedule,
    spec.workflowSpec, metadata). The delete payload uses the previous revision's manifest to ensure the correct CR name is targeted even if the experiment was renamed.
  • For non-cron experiments: ProcessExperimentUpdate now correctly dispatches an update action to the subscriber (was previously a no-op due to nil).
  • First-time saves (ProcessExperimentCreation) also now pass r so the CR is created immediately on active infra.

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

None.

Special notes for your reviewer:

The subscriber already supports delete and create request types (subscriber/pkg/k8s/operations.go) — no subscriber
changes were needed. The subscriber's delete path returns nil on IsNotFound, so a missing CR (e.g. infra was offline
during original creation) is handled gracefully. If the infra is inactive, SendRequestToSubscriber is a no-op (no
observer in ConnectedInfra), which is consistent with existing behaviour across all other mutations.

The StateData (r) parameter is nil in unit tests and the fuzz test — this is intentional and matches how all other
handler tests are written (subscriber dispatch is not tested at the handler layer).

xorjnox added 3 commits May 26, 2026 15:14
Signed-off-by: xorjnox <ranjan.s.1227@gmail.com>
Signed-off-by: xorjnox <ranjan.s.1227@gmail.com>
Signed-off-by: xorjnox <ranjan.s.1227@gmail.com>
@xorjnox xorjnox changed the title Ranjan/litmus cronworkflow fix Fix CronWorkflow CR not being updated on target ChaosInfrastructure May 26, 2026
@PriteshKiri

Copy link
Copy Markdown
Contributor

@xorjnox are you still wokring on this issue?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants