Skip to content

feat(models): add soft deletion to Kubernetes resources - #617

Merged
pontusringblom merged 1 commit into
meshery:masterfrom
Prayas-35:feat/soft-delete-resources
Nov 14, 2026
Merged

pontusringblom merged 1 commit into
meshery:masterfrom
Prayas-35:feat/soft-delete-resources

Conversation

@Prayas-35

@Prayas-35 Prayas-35 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds GORM soft-deletion support to KubernetesResource by introducing an indexed DeletedAt field.

The field uses json:"-", ensuring that persistence metadata is not included in MeshSync broker messages or snapshot output.

Related to meshery/meshery#6458.

This is the first part of the cross-repository implementation. After this change is merged and a new MeshSync version is published, the dependency and server deletion behavior will be updated in meshery/meshery.

Tests

The new model test verifies that:

  • normal queries exclude tombstoned resources;
  • Unscoped() queries retain access to tombstoned resources;
  • the deletion timestamp is populated;
  • deletion metadata is excluded from JSON.

Validation

  • go test ./pkg/model -run '^TestKubernetesResourceSoftDelete$' -count=1
  • go test --short ./... -count=1
  • make build

Contributor Checklist

  • I have signed off my commits with git commit -s.

Summary by CodeRabbit

  • New Features
    • Deleted Kubernetes resources are now marked as deleted rather than immediately removed. They no longer appear in ordinary resource queries, while their deletion status remains available internally.
    • Deletion metadata is excluded from JSON output, preserving the existing response format for resource data.

Signed-off-by: Prayas-35 <prayaspal04@gmail.com>
@github-actions github-actions Bot added the language/go Golang related label Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

KubernetesResource now has an indexed GORM soft-delete field that is excluded from JSON. A SQLite-backed test checks deletion, query behavior, and JSON output.

Changes: KubernetesResource soft deletion

Layer / File(s) Summary
Add and verify soft deletion
pkg/model/model.go, go.mod, pkg/model/model_test.go
KubernetesResource gains an indexed DeletedAt field excluded from JSON. The SQLite driver becomes a direct dependency. Tests check the deletion timestamp, default query exclusion, unscoped retrieval, and JSON omission.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: Minimal · up to 4a8fb

This adds a soft-delete field to the Kubernetes resource model without changing its JSON output. No concrete defect is established in this repository. The consuming server must handle existing tables and resource recreation when it adopts the new version.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: adding soft deletion to Kubernetes resources. The changeset adds a GORM DeletedAt field to KubernetesResource, a test for soft deletion, and the go.mod dependency on g…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: adding soft deletion to Kubernetes resources. The changeset adds a GORM DeletedAt field to KubernetesResource, a test for soft deletion, and the go.mod dependency on gorm.io/driver/sqlite. The title is concise and specific, and the commit message matches it.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1270a454-35cd-4ac7-aa24-cac1fb199eed
Commits

Reviewing files that changed from the base of the PR and between adba91e and 4a8fb19.

Files selected for processing: 3

  • go.mod
  • pkg/model/model.go
  • pkg/model/model_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Prayas-35 Prayas-35 changed the title [Models] Add soft deletion to Kubernetes resources feat(models): Add soft deletion to Kubernetes resources Nov 14, 2026
@Prayas-35 Prayas-35 changed the title feat(models): Add soft deletion to Kubernetes resources feat(models): add soft deletion to Kubernetes resources Nov 14, 2026

@pontusringblom pontusringblom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a clean, well-scoped first step: the indexed DeletedAt field with json:"-" keeps tombstone metadata out of broker messages and snapshot output, and the new test covers the three behaviors that matter. One thing to confirm in the meshery-side follow-up is the re-created resource case: since SetID derives the ID deterministically, a deleted-then-recreated resource gets the same ID, so the tombstoned row could block a plain Create unless the upsert path handles it.

Please consider and reply to each comment in this review. For every suggestion, state how you've incorporated it or explain your reasoning for not doing so.

Comment thread pkg/model/model.go Resolved
Comment thread pkg/model/model_test.go Resolved
@leecalcote
leecalcote removed the request for review from michaelvance092 November 14, 2026 12:20

@pontusringblom pontusringblom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick replies, both points are addressed well. The deterministic-ID re-create case will be handled in the meshery-side follow-up with an unscoped query, restore, and a regression test, and the Postgres migration path gets covered through the AutoMigrateSystemTables check there. I verified the new test locally: go test ./pkg/model -run TestKubernetesResourceSoftDelete passes.

This is a clean, well-scoped first step. Please consider and respond to every feedback point in this review, showing how you incorporated it or explaining why you rejected it.

@pontusringblom
pontusringblom merged commit 39bbd51 into meshery:master Nov 14, 2026
3 checks passed
@welcome

welcome Bot commented Nov 14, 2026

Copy link
Copy Markdown

Thanks for your contribution to Meshery! 🎉

Meshery Logo
        Join the community, if you haven't yet and please leave a ⭐ star on the project. 😄

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

Labels

language/go Golang related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants