Skip to content

fix: Resolve operator namespace dynamically (#5823) - #6477

Open
uberstoic wants to merge 3 commits into
feast-dev:masterfrom
uberstoic:fix/5823-operator-namespace
Open

uberstoic wants to merge 3 commits into
feast-dev:masterfrom
uberstoic:fix/5823-operator-namespace

Conversation

@uberstoic

Copy link
Copy Markdown

What this PR does / why we need it:

When the Feast Operator is deployed to a custom namespace (not feast-operator-system), it fails to reconcile FeatureStore CRs because [getNamespaceRegistryNamespace()] returned a hardcoded feast-operator-system on non-OpenShift clusters.

This PR fixes the namespace resolution logic to dynamically determine the operator's actual namespace using a priority chain:

  1. FEAST_OPERATOR_NAMESPACE env var (explicit override)
  2. ServiceAccount namespace file /var/run/secrets/kubernetes.io/serviceaccount/namespace (works on both K8s and OpenShift)
  3. POD_NAMESPACE env var (Downward API)
  4. Fallback to feast-operator-system (unit tests only)

The isOpenShift guard was removed from the SA file check since this file is available on both Kubernetes and OpenShift. The function signature was simplified from (string, error) to string so it now always returns a usable namespace.

Which issue(s) this PR fixes:

Fixes #5823

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

Added 6 unit tests in namespace_registry_test.go covering the env var priority chain and fallback behavior.

P.S.
My first contribution to open-source, sorry if I do something wrong.

@shuchu

shuchu commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@uberstoic Hi, can you update the PR? it's a little bit out-of-date and has conflicts. I will review it soon once you update it.

@uberstoic
uberstoic force-pushed the fix/5823-operator-namespace branch from e07eff2 to 7157c4b Compare November 4, 2026 09:08
@uberstoic

Copy link
Copy Markdown
Author

@shuchu hi!
rebased PR so you can review it

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +237 to +240
if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
if ns := strings.TrimSpace(string(data)); ns != "" {
logger.V(1).Info("Using operator namespace from serviceaccount namespace file", "namespace", ns)
return ns, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Stale discovery entries after upgrade

After a custom-namespace Kubernetes upgrade, getNamespaceRegistryNamespace redirects writes and cleanup away from the existing discovery ConfigMaps. Clients still reading feast-operator-system miss new stores and keep seeing deleted stores and OpenLineage endpoints.

Learn more

The namespace registry and OpenLineage discovery ConfigMaps tell clients which stores and endpoints exist. Before this change, Kubernetes installs wrote both to feast-operator-system, even when the operator ran elsewhere. On upgrade, deployNamespaceRegistry and deployOpenLineageDiscovery start writing to the pod namespace. The shared ConfigMaps have no owner references, and RemoveFromNamespaceRegistry and RemoveFromOpenLineageDiscovery only clean up the newly resolved namespace. Clients following the namespace registry lookup can therefore keep reading a valid but stale ConfigMap for as long as the old namespace remains.

Example: An operator in ml-platform previously registered fraud in an existing feast-operator-system namespace. Upgrade the operator without an explicit namespace override, then delete fraud. The old ConfigMap still advertises fraud, and a dashboard reading there does not see stores created after the upgrade.

Recommended fix: Provide an upgrade path for both discovery ConfigMaps. Preserve the old target with FEAST_OPERATOR_NAMESPACE=feast-operator-system until readers are migrated, or migrate readers and retire the old ConfigMaps explicitly. Do not delete shared ConfigMaps blindly when another operator may still use them. Add an upgrade test covering a custom operator namespace with pre-existing discovery entries.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@uberstoic uberstoic Nov 25, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added a compatibility path for existing Kubernetes installs: when a legacy discovery ConfigMap exists in feast-operator-system, the operator now keeps this FeatureStore’s entry in sync there as well as in its current namespace, for both the namespace registry and OpenLineage discovery.
Cleanup only removes this FeatureStore’s entry; shared ConfigMaps and unrelated entries are preserved. I also added upgrade tests and documented the legacy namespace behavior

Separate commit for this fix is in the last commit

@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.10%. Comparing base (a291a0f) to head (0597c7a).
⚠️ Report is 1 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6477      +/-   ##
==========================================
- Coverage   54.10%   54.10%   -0.01%     
==========================================
  Files         467      467              
  Lines       58940    58940              
  Branches     8688     8688              
==========================================
- Hits        31890    31889       -1     
  Misses      24892    24892              
- Partials     2158     2159       +1     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.70% <ø> (-0.01%) ⬇️
see 1 file with indirect coverage changes

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a291a0f...0597c7a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

uberstoic and others added 2 commits November 25, 2026 15:05
…east-operator-system

Resolves feast-dev#5823

Signed-off-by: Serj <serjpvlv@gmail.com>
Signed-off-by: Sergej Pavloff <sergejpavloff@MacBook-Air-Sergej.local>
@uberstoic uberstoic changed the title fix: resolve operator namespace dynamically (#5823) fix: Resolve operator namespace dynamically (#5823) Nov 25, 2026
@uberstoic
uberstoic force-pushed the fix/5823-operator-namespace branch from 3ba6988 to 2fc42d1 Compare November 25, 2026 12:16
Signed-off-by: Serj <107816087+uberstoic@users.noreply.github.com>
@uberstoic

Copy link
Copy Markdown
Author

Hi! I fixed the errcheck lint issues in the operator tests, rebased the PR onto the latest master, and updated the PR title to satisfy the title check + fixed what devin-ai mentioned (see above)
Could you please rerun the failed CI checks? Thanks!

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feast Operator fails when deployed to custom namespace - requires "feast-operator-system" to exist

4 participants