-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The OpensearchSnapshotPolicy
CRD has a bug where the deletion schedule incorrectly uses the creation schedule values instead of the deletion schedule values.
Environment
- OpenSearch K8s Operator version: Latest (after PR Snapshot policy support #1018)
- Kubernetes version: Any
- OpenSearch version: Any
Steps to Reproduce
- Create an
OpensearchSnapshotPolicy
with different creation and deletion schedules:
apiVersion: opensearch.opster.io/v1
kind: OpensearchSnapshotPolicy
metadata:
name: test-policy
namespace: default
spec:
opensearchCluster:
name: test-cluster
policyName: test-policy
creation:
schedule:
cron:
expression: "0 6 * * *" # 6:00 AM
timezone: "UTC"
timeLimit: "2h"
deletion:
schedule:
cron:
expression: "0 8 * * *" # 8:00 AM (different from creation)
timezone: "UTC"
timeLimit: "2h"
deleteCondition:
maxAge: "180d"
minCount: 1
- Apply the policy and check the actual OpenSearch snapshot policy via Dev Tools:
GET _plugins/_sm/policies/test-policy
Expected Behavior
The deletion schedule should be 0 8 * * *
(8:00 AM) as specified in the CRD.
Actual Behavior
The deletion schedule is 0 6 * * *
(6:00 AM), which matches the creation schedule.
Root Cause
In opensearch-operator/pkg/reconcilers/snapshotpolicy.go
at lines 311-312, the code incorrectly uses:
Expression: r.instance.Spec.Creation.Schedule.Cron.Expression,
Timezone: r.instance.Spec.Creation.Schedule.Cron.Timezone,
Instead of:
Expression: r.instance.Spec.Deletion.Schedule.Cron.Expression,
Timezone: r.instance.Spec.Deletion.Schedule.Cron.Timezone,
Impact
- Snapshot deletion may occur at the wrong time
- Users cannot properly schedule deletion to occur after creation completion
- This defeats the purpose of having separate creation and deletion schedules
Proposed Solution
I can provide a PR with:
- Correct the deletion schedule to use
r.instance.Spec.Deletion.Schedule
instead ofr.instance.Spec.Creation.Schedule
- Add nil check for
r.instance.Spec.Deletion.Schedule
to prevent panic - Add unit tests to prevent regression
Additional Context
This bug was introduced in PR #1018 which added snapshot policy support. The deletion schedule logic was incorrectly copied from the creation schedule logic.
skileton, asmbk, lesha-sign, vitalii-morvaniuk-airslate, sychevsky and 10 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
✅ Done