Skip to content

feat: add k8sObjMeta for lua and python - #4380

Open
zreigz wants to merge 5 commits into
masterfrom
lukasz/prod-5231-k8sobjmeta-luapython-function
Open

zreigz wants to merge 5 commits into
masterfrom
lukasz/prod-5231-k8sobjmeta-luapython-function

Conversation

@zreigz

@zreigz zreigz commented Sep 21, 2026

Copy link
Copy Markdown
Member

Test Plan

Test environment: https://console.your-env.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

@zreigz
zreigz requested a review from a team as a code owner September 21, 2026 10:58
@linear

linear Bot commented Sep 21, 2026

Copy link
Copy Markdown

PROD-5231

@soffi-ai

soffi-ai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Soffi AI Summary

This PR introduces a new k8sObjMeta / k8s_object_meta built-in function available in both Lua and Python scripting contexts within Helm value generation. The function allows templating scripts to look up live Kubernetes object metadata (name, namespace, UID, labels, etc.) directly from the in-cluster resource cache (SQLite store), enabling use cases like reading the kube-system namespace UID for cluster identity without external API calls.

To support this, the SQLite component store was extended with a labels column (added via a safe ALTER TABLE migration for backward compatibility), a new label serialization/deserialization layer, and a global store accessor used by the lookup function. The Python pool was wired to accept an injectable ObjectMetaLookup function, and the Lua template layer received an analogous k8sObjMeta binding. Documentation was added covering the new function for both Lua and Python Helm scripts.

Changes

k8sObjMeta / k8s_object_meta built-in for Lua and Python Helm scripts

  • Added k8sObjMeta binding to the Lua scripting layer for Helm value generation, allowing scripts to look up Kubernetes object metadata (name, namespace, UID, labels) from the in-cluster resource cache. (92cdf31)
  • Introduced k8s_object_meta as a built-in Python function in the Helm Python scripting pool, wired to a pluggable ObjectMetaLookup backed by the global SQLite component store. Also extended the store with a labels column (via a backward-compatible ALTER TABLE migration) and added label serialization helpers so label data is available to lookup callers. (bef43e2)
  • Wired the Python k8s_object_meta function into the agent startup path and added a global store accessor (streamline.LookupObjectMeta) used as the default lookup implementation. (204d725)
  • Addressed review comments: cleaned up label encoding/decoding, refactored the store upsert path into a dedicated helper, added missing test coverage for cache-hit and cache-miss scenarios in both Lua and Python, and replaced ad-hoc new() helper calls in tests with lo.ToPtr. (502aea2)
  • Merge commit syncing the feature branch with origin/master before final integration. (204a1c5)

Updated: 2026-09-22 07:19 UTC

Deploy in Soffi

@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

The PR is not safe to merge until the metadata lookup is exposed to both scripting runtimes and labels are persisted through the normal resource-apply lifecycle.

Findings

  1. P1 Lookup Missing From Runtimes
  2. P1 Applied Labels Stay Empty
  3. P2 Module Cache State Committed

Summary

This PR extends the streamline component cache with persisted Kubernetes labels, migrates existing SQLite stores, and adds a Go metadata lookup returning object identity and labels. However:

  • The lookup is not registered with either the Lua or Python runtime, leaving the headline scripting feature unavailable.
  • The standard resource-apply path can mark cache entries applied without ever storing their labels.
  • Two unrelated Go checksum-database cache snapshots were committed.

Reviews (1) · Last reviewed commit: "add k8sObjMeta for lua and python"

Comment thread go/deployment-operator/pkg/streamline/global.go
Comment thread go/deployment-operator/pkg/streamline/global.go
Comment thread .go/pkg/sumdb/sum.golang.org/latest Outdated
@zreigz zreigz added backend Changes related to the backend enhancement New feature or request and removed backend Changes related to the backend labels Sep 21, 2026
@zreigz
zreigz requested a review from a team as a code owner September 21, 2026 14:36
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.

1 participant