Skip to content

Fixes #28467: Resolve Databricks service principal owners - #28466

Merged
ulixius9 merged 10 commits into
mainfrom
implement-action-4
Jun 5, 2026
Merged

ulixius9 merged 10 commits into
mainfrom
implement-action-4

Conversation

@ulixius9

@ulixius9 ulixius9 commented May 27, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #28467

I worked on Databricks and Unity Catalog owner resolution so service-principal application IDs and workspace groups can resolve to display names before OpenMetadata owner lookup.

Type of change:

  • Improvement

High-level design:

Added a shared Databricks owner resolver backed by bounded LRU caches, SCIM pagination helpers on the Databricks client, and connector wiring for both Databricks and Unity Catalog metadata extraction.

Tests:

Use cases covered

  • Databricks service-principal application IDs resolve to display names.
  • Workspace group IDs and display names are treated as Team owners.
  • SCIM failures fall back to raw owner lookup without failing ingestion.
  • Unity Catalog owners returned as raw service-principal application IDs resolve correctly.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ingestion/tests/unit/topology/database/test_databricks_ownership.py
  • Coverage %: Not measured.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • I added/updated ingestion integration tests for connector changes.
  • Files added/updated: Unit coverage added for connector owner resolution.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Ran make py_format and make py_format_check from ingestion/.
  2. Ran PYTHONPATH=ingestion/src python -m pytest ingestion/tests/unit/topology/database/test_databricks_ownership.py ingestion/tests/unit/topology/database/test_unity_catalog.py ingestion/tests/unit/topology/database/test_databricks_query_reduction.py -q.
  3. Verified against a live Databricks Unity Catalog table that owner e20b14dc-a28d-4e62-9caf-b28e88c2461e resolves to service principal display name test_collate_om, then cleaned up the scratch schema.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added tests around the new logic.
  • For connector/ingestion changes: I updated the documentation.

Copilot AI review requested due to automatic review settings May 27, 2026 10:30
@ulixius9
ulixius9 requested a review from a team as a code owner May 27, 2026 10:30
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels May 27, 2026
@ulixius9 ulixius9 changed the title Resolve Databricks service principal owners Fixes #28467: Resolve Databricks service principal owners May 27, 2026

Copilot AI 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.

Pull request overview

This PR improves owner resolution for Databricks and Unity Catalog ingestion by resolving workspace service principals and groups (via SCIM) to stable display names before performing OpenMetadata owner lookup.

Changes:

  • Added a shared DatabricksOwnerResolver with bounded LRU caches to map service principal application IDs and group IDs/names to display names, then resolve to OM owners.
  • Extended DatabricksClient with SCIM pagination helpers and exposed SCIM endpoint paths.
  • Wired the resolver into both Databricks and Unity Catalog sources, and added unit tests covering SCIM pagination + resolver behaviors.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ingestion/tests/unit/topology/database/test_databricks_ownership.py Adds unit tests for SCIM pagination and owner resolution behavior for service principals, groups, emails, and fallbacks.
ingestion/src/metadata/ingestion/source/database/unitycatalog/metadata.py Uses the shared DatabricksOwnerResolver for Unity Catalog owner resolution.
ingestion/src/metadata/ingestion/source/database/databricks/ownership.py Introduces the shared resolver and caching/identity-map loading logic.
ingestion/src/metadata/ingestion/source/database/databricks/metadata.py Wires the resolver into Databricks source owner resolution.
ingestion/src/metadata/ingestion/source/database/databricks/client.py Adds SCIM listing (with pagination), SCIM path constants, and broadens auth handling for Databricks/UC connections.

Copilot AI review requested due to automatic review settings May 28, 2026 09:38

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

@github-actions

github-actions Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (11 flaky)

✅ 4269 passed · ❌ 0 failed · 🟡 11 flaky · ⏭️ 88 skipped

Shard Passed Failed Flaky Skipped
✅ Shard 1 301 0 0 4
🟡 Shard 2 800 0 4 9
🟡 Shard 3 803 0 2 8
🟡 Shard 4 854 0 1 12
✅ Shard 5 721 0 0 47
🟡 Shard 6 790 0 4 8
🟡 11 flaky test(s) (passed on retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Keyboard Delete selection (shard 2, 1 retry)
  • Features/DataQuality/TableLevelTests.spec.ts › Table Column To Match Set (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should display correct status badge color and icon (shard 2, 2 retries)
  • Features/Tasks/TaskNavigation.spec.ts › navigating to /table/TASK-XXXXX should show 404 (invalid URL pattern) (shard 3, 2 retries)
  • Flow/FrequentlyJoined.spec.ts › should display frequently joined columns (shard 3, 1 retry)
  • Pages/CustomProperties.spec.ts › Time Interval (shard 4, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/Lineage/PlatformLineage.spec.ts › Verify domain platform view (shard 6, 1 retry)
  • Pages/ServiceListing.spec.ts › should render the service listing page (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

ulixius9 and others added 2 commits June 2, 2026 17:26
… guard

- Guard SCIM pagination against non-positive itemsPerPage values
- Replace bulk identity-map loading with per-owner filtered SCIM lookups
- Verify SCIM results match the requested owner and escape filter values

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	ingestion/src/metadata/ingestion/source/database/unitycatalog/metadata.py
Copilot AI review requested due to automatic review settings June 4, 2026 17:19

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

The merge with main restored main's version of the test which only patches
get_connection; the owner resolver now constructs a DatabricksClient in
__init__, so the test must patch it too.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@ulixius9
ulixius9 merged commit 63a22d5 into main Jun 5, 2026
49 of 50 checks passed
@ulixius9
ulixius9 deleted the implement-action-4 branch June 5, 2026 09:56
@gitar-bot

gitar-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 resolved / 4 findings

Implements a Databricks and Unity Catalog owner resolver with bounded LRU caching to correctly map service principals and groups. Resolved issues regarding stale OAuth tokens, unsafe Pydantic API usage, and inefficient SCIM lookups.

✅ 4 resolved
✅ Quality: Fragile self.__dict__.get("owner_resolver") instead of attribute access

📄 ingestion/src/metadata/ingestion/source/database/databricks/metadata.py:1327-1329
Line 1327 uses self.__dict__.get("owner_resolver") to check for the resolver. Since owner_resolver is unconditionally set in DatabricksSource.__init__ (line 851-856), this attribute will always exist on any properly constructed instance. Using __dict__.get is non-idiomatic, hides the dependency from static analysis tools, and suggests the attribute might not always be present when it actually always is. If the intent is defensive coding for subclasses, getattr(self, 'owner_resolver', None) is the standard Python pattern.

✅ Bug: OAuth/AzureAD token cached at init will go stale in long jobs

📄 ingestion/src/metadata/ingestion/source/database/databricks/client.py:86-89 📄 ingestion/src/metadata/ingestion/source/database/databricks/client.py:104-118
The _get_auth_header() method is called once during __init__ (line 86-87) and the result is stored in self.headers. For OAuth and Azure AD flows (new in this PR), the returned token has a limited lifetime (typically 1 hour). During long-running ingestion jobs, subsequent API calls (including SCIM pagination) will fail with 401 errors once the token expires. Before this PR, only static PATs were used, so staleness wasn't an issue. Consider calling _get_auth_header() per-request or implementing a token-refresh mechanism.

✅ Quality: Using private Pydantic API EmailStr._validate may break on upgrades

📄 ingestion/src/metadata/ingestion/source/database/databricks/ownership.py:141 📄 ingestion/src/metadata/ingestion/source/database/databricks/ownership.py:153
The _validate method on EmailStr is a private/internal Pydantic API (underscore-prefixed). This is used in both ownership.py (lines 141, 153) and the existing metadata.py code. While it works today, Pydantic could change or remove this in a minor release. Consider using a public validation pattern instead.

✅ Performance: Unnecessary SCIM group lookup for UUID owners that fail SP resolution

📄 ingestion/src/metadata/ingestion/source/database/databricks/ownership.py:98 📄 ingestion/src/metadata/ingestion/source/database/databricks/ownership.py:118-120
When _resolve_service_principal returns None for a UUID-formatted owner (i.e., the UUID doesn't match any service principal), _resolve_group is still called. Since owner.isdigit() is False for UUIDs, it queries SCIM with displayName eq "<uuid>", which will virtually never match a real group. This is a wasted API call per unresolved UUID (though only once per owner due to the outer _owner_cache).

Consider adding an early return in _resolve_group for UUID-formatted owners, or restructuring so that UUID owners only attempt the service principal path before falling back directly to the raw owner.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

akashverma0786 added a commit that referenced this pull request Nov 15, 2026
…er resolution as on main

- The stale-database cleanup now lists the catalogs before it checks for a failed
  listing. With a configured catalog that listing is the run's only catalog listing,
  and a failure there used to soft-delete every Database it did not return.
- Restore the Databricks owner resolver and its tests to main. Its email local-part
  fallback was added on purpose in #28466; changing it is out of scope here.
- Keep the base "No Database found in the context" guard in the table cleanup, and
  annotate the mark_schemas/mark_databases overrides.
- Test the full-mode table cleanup by the scopes it sends, and make the failed
  table page test fail on main.
- Prune the two G004 baseline entries for the logger calls this branch removed.

This branch was previously deployed

1 inactive deployment
test — 84ccfd83 Deployed Jun 5, 2026 by ulixius9 via playwright-ci-postgresql (6, 6) #49914
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Databricks owners show service principal application IDs

3 participants