Skip to content

Commit

Permalink
Merge branch 'master' into graph-filter-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
asikowitz authored Sep 27, 2023
2 parents 6738e35 + 2e2cd87 commit e162349
Show file tree
Hide file tree
Showing 181 changed files with 4,168 additions and 704 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/docker-unified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
echo "full_tag=$(get_tag)-full" >> $GITHUB_OUTPUT
echo "unique_tag=$(get_unique_tag)" >> $GITHUB_OUTPUT
echo "unique_slim_tag=$(get_unique_tag)-slim" >> $GITHUB_OUTPUT
echo "unique_full_tag=$(get_unique_tag)-full" >> $GITHUB_OUTPUT
echo "unique_full_tag=$(get_unique_tag)" >> $GITHUB_OUTPUT
echo "python_release_version=$(get_python_docker_release_v)" >> $GITHUB_OUTPUT
- name: Check whether publishing enabled
id: publish
Expand Down Expand Up @@ -501,7 +501,7 @@ jobs:
platforms: linux/amd64,linux/arm64/v8
- name: Compute DataHub Ingestion (Base-Slim) Tag
id: tag
run: echo "tag=${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head' }}" >> $GITHUB_OUTPUT
run: echo "tag=${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head-slim' }}" >> $GITHUB_OUTPUT
datahub_ingestion_base_full_build:
name: Build and Push DataHub Ingestion (Base-Full) Docker Image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -567,13 +567,13 @@ jobs:
datahub-ingestion:
- 'docker/datahub-ingestion/**'
- name: Build codegen
if: ${{ steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true' }}
if: ${{ steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true' || needs.setup.outputs.publish }}
run: ./gradlew :metadata-ingestion:codegen
- name: Download Base Image
uses: ishworkh/docker-image-artifact-download@v1
if: ${{ needs.setup.outputs.publish != 'true' && steps.filter.outputs.datahub-ingestion-base == 'true' }}
with:
image: ${{ env.DATAHUB_INGESTION_BASE_IMAGE }}:${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head' }}
image: ${{ env.DATAHUB_INGESTION_BASE_IMAGE }}:${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head-slim' }}
- name: Build and push Slim Image
if: ${{ steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true' || needs.setup.outputs.publish }}
uses: ./.github/actions/docker-custom-build-and-push
Expand All @@ -583,7 +583,7 @@ jobs:
${{ env.DATAHUB_INGESTION_IMAGE }}
build-args: |
BASE_IMAGE=${{ env.DATAHUB_INGESTION_BASE_IMAGE }}
DOCKER_VERSION=${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head' }}
DOCKER_VERSION=${{ steps.filter.outputs.datahub-ingestion-base == 'true' && needs.setup.outputs.unique_slim_tag || 'head-slim' }}
RELEASE_VERSION=${{ needs.setup.outputs.python_release_version }}
APP_ENV=slim
tags: ${{ needs.setup.outputs.slim_tag }}
Expand All @@ -595,7 +595,7 @@ jobs:
platforms: linux/amd64,linux/arm64/v8
- name: Compute Tag
id: tag
run: echo "tag=${{ (steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true') && needs.setup.outputs.unique_slim_tag || 'head' }}" >> $GITHUB_OUTPUT
run: echo "tag=${{ (steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true') && needs.setup.outputs.unique_slim_tag || 'head-slim' }}" >> $GITHUB_OUTPUT
datahub_ingestion_slim_scan:
permissions:
contents: read # for actions/checkout to fetch code
Expand Down Expand Up @@ -650,7 +650,7 @@ jobs:
datahub-ingestion:
- 'docker/datahub-ingestion/**'
- name: Build codegen
if: ${{ steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true' }}
if: ${{ steps.filter.outputs.datahub-ingestion-base == 'true' || steps.filter.outputs.datahub-ingestion == 'true' || needs.setup.outputs.publish }}
run: ./gradlew :metadata-ingestion:codegen
- name: Download Base Image
uses: ishworkh/docker-image-artifact-download@v1
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ subprojects {
}
// https://docs.gradle.org/current/userguide/performance.html
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1

if (project.configurations.getByName("testImplementation").getDependencies()
.any{ it.getName() == "testng" }) {
useTestNG()
}
}

afterEvaluate {
Expand Down
25 changes: 19 additions & 6 deletions datahub-frontend/app/auth/AuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.entity.client.RestliEntityClient;
import com.linkedin.entity.client.SystemEntityClient;
import com.linkedin.entity.client.SystemRestliEntityClient;
import com.linkedin.metadata.restli.DefaultRestliClientFactory;
import com.linkedin.parseq.retry.backoff.ExponentialBackoff;
import com.linkedin.util.Configuration;
import config.ConfigurationProvider;
import controllers.SsoCallbackController;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
Expand All @@ -34,6 +37,7 @@
import org.pac4j.play.store.PlayCookieSessionStore;
import org.pac4j.play.store.PlaySessionStore;
import org.pac4j.play.store.ShiroAesDataEncrypter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import play.Environment;
import play.cache.SyncCacheApi;
import utils.ConfigUtil;
Expand Down Expand Up @@ -104,7 +108,7 @@ protected void configure() {
bind(SsoCallbackController.class).toConstructor(SsoCallbackController.class.getConstructor(
SsoManager.class,
Authentication.class,
EntityClient.class,
SystemEntityClient.class,
AuthServiceClient.class,
com.typesafe.config.Config.class));
} catch (NoSuchMethodException | SecurityException e) {
Expand Down Expand Up @@ -161,10 +165,19 @@ protected Authentication provideSystemAuthentication() {

@Provides
@Singleton
protected EntityClient provideEntityClient() {
return new RestliEntityClient(buildRestliClient(),
protected ConfigurationProvider provideConfigurationProvider() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigurationProvider.class);
return context.getBean(ConfigurationProvider.class);
}

@Provides
@Singleton
protected SystemEntityClient provideEntityClient(final Authentication systemAuthentication,
final ConfigurationProvider configurationProvider) {
return new SystemRestliEntityClient(buildRestliClient(),
new ExponentialBackoff(_configs.getInt(ENTITY_CLIENT_RETRY_INTERVAL)),
_configs.getInt(ENTITY_CLIENT_NUM_RETRIES));
_configs.getInt(ENTITY_CLIENT_NUM_RETRIES), systemAuthentication,
configurationProvider.getCache().getClient().getEntityClient());
}

@Provides
Expand Down
7 changes: 4 additions & 3 deletions datahub-frontend/app/auth/sso/oidc/OidcCallbackLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.linkedin.common.urn.Urn;
import com.linkedin.data.template.SetMode;
import com.linkedin.entity.Entity;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.entity.client.SystemEntityClient;
import com.linkedin.events.metadata.ChangeType;
import com.linkedin.identity.CorpGroupInfo;
import com.linkedin.identity.CorpUserEditableInfo;
Expand Down Expand Up @@ -78,13 +78,14 @@
public class OidcCallbackLogic extends DefaultCallbackLogic<Result, PlayWebContext> {

private final SsoManager _ssoManager;
private final EntityClient _entityClient;
private final SystemEntityClient _entityClient;
private final Authentication _systemAuthentication;
private final AuthServiceClient _authClient;
private final CookieConfigs _cookieConfigs;

public OidcCallbackLogic(final SsoManager ssoManager, final Authentication systemAuthentication,
final EntityClient entityClient, final AuthServiceClient authClient, final CookieConfigs cookieConfigs) {
final SystemEntityClient entityClient, final AuthServiceClient authClient,
final CookieConfigs cookieConfigs) {
_ssoManager = ssoManager;
_systemAuthentication = systemAuthentication;
_entityClient = entityClient;
Expand Down
27 changes: 27 additions & 0 deletions datahub-frontend/app/config/ConfigurationProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package config;

import com.linkedin.metadata.config.cache.CacheConfiguration;
import com.linkedin.metadata.spring.YamlPropertySourceFactory;
import lombok.Data;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.PropertySource;


/**
* Minimal sharing between metadata-service and frontend
* Initially for use of client caching configuration.
* Does not use the factories module to avoid transitive dependencies.
*/
@EnableConfigurationProperties
@PropertySource(value = "application.yml", factory = YamlPropertySourceFactory.class)
@ConfigurationProperties
@Data
public class ConfigurationProvider {

/**
* Configuration for caching
*/
private CacheConfiguration cache;
}
6 changes: 3 additions & 3 deletions datahub-frontend/app/controllers/SsoCallbackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import auth.CookieConfigs;
import client.AuthServiceClient;
import com.datahub.authentication.Authentication;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.entity.client.SystemEntityClient;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -40,7 +40,7 @@ public class SsoCallbackController extends CallbackController {
public SsoCallbackController(
@Nonnull SsoManager ssoManager,
@Nonnull Authentication systemAuthentication,
@Nonnull EntityClient entityClient,
@Nonnull SystemEntityClient entityClient,
@Nonnull AuthServiceClient authClient,
@Nonnull com.typesafe.config.Config configs) {
_ssoManager = ssoManager;
Expand Down Expand Up @@ -79,7 +79,7 @@ public class SsoCallbackLogic implements CallbackLogic<Result, PlayWebContext> {
private final OidcCallbackLogic _oidcCallbackLogic;

SsoCallbackLogic(final SsoManager ssoManager, final Authentication systemAuthentication,
final EntityClient entityClient, final AuthServiceClient authClient, final CookieConfigs cookieConfigs) {
final SystemEntityClient entityClient, final AuthServiceClient authClient, final CookieConfigs cookieConfigs) {
_oidcCallbackLogic = new OidcCallbackLogic(ssoManager, systemAuthentication, entityClient, authClient, cookieConfigs);
}

Expand Down
8 changes: 5 additions & 3 deletions datahub-frontend/play.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ dependencies {
implementation project(':datahub-web-react')

constraints {
play(externalDependency.springCore)
play(externalDependency.springBeans)
play(externalDependency.springContext)
play(externalDependency.jacksonDataBind)
play('com.nimbusds:oauth2-oidc-sdk:8.36.2')
play('com.nimbusds:nimbus-jose-jwt:8.18')
Expand All @@ -35,7 +32,12 @@ dependencies {

implementation project(":metadata-service:restli-client")
implementation project(":metadata-service:auth-config")
implementation project(":metadata-service:configuration")

implementation externalDependency.springCore
implementation externalDependency.springBeans
implementation externalDependency.springContext
implementation externalDependency.springBootAutoconfigure
implementation externalDependency.jettyJaas
implementation externalDependency.graphqlJava
implementation externalDependency.antlr4Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
import com.linkedin.datahub.graphql.types.test.TestType;
import com.linkedin.datahub.graphql.types.view.DataHubViewType;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.entity.client.SystemEntityClient;
import com.linkedin.metadata.config.DataHubConfiguration;
import com.linkedin.metadata.config.IngestionConfiguration;
import com.linkedin.metadata.config.TestsConfiguration;
Expand Down Expand Up @@ -364,6 +365,7 @@
public class GmsGraphQLEngine {

private final EntityClient entityClient;
private final SystemEntityClient systemEntityClient;
private final GraphClient graphClient;
private final UsageClient usageClient;
private final SiblingGraphService siblingGraphService;
Expand Down Expand Up @@ -476,6 +478,7 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
this.graphQLPlugins.forEach(plugin -> plugin.init(args));

this.entityClient = args.entityClient;
this.systemEntityClient = args.systemEntityClient;
this.graphClient = args.graphClient;
this.usageClient = args.usageClient;
this.siblingGraphService = args.siblingGraphService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.linkedin.datahub.graphql.analytics.service.AnalyticsService;
import com.linkedin.datahub.graphql.featureflags.FeatureFlags;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.entity.client.SystemEntityClient;
import com.linkedin.metadata.config.DataHubConfiguration;
import com.linkedin.metadata.config.IngestionConfiguration;
import com.linkedin.metadata.config.TestsConfiguration;
Expand Down Expand Up @@ -38,6 +39,7 @@
@Data
public class GmsGraphQLEngineArgs {
EntityClient entityClient;
SystemEntityClient systemEntityClient;
GraphClient graphClient;
UsageClient usageClient;
AnalyticsService analyticsService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package com.linkedin.datahub.graphql.resolvers.dataset;

import com.datahub.authorization.ResourceSpec;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.linkedin.common.urn.Urn;
import com.linkedin.common.urn.UrnUtils;
import com.linkedin.datahub.graphql.QueryContext;
import com.linkedin.datahub.graphql.authorization.AuthorizationUtils;
import com.linkedin.datahub.graphql.generated.CorpUser;
import com.linkedin.datahub.graphql.generated.DatasetStatsSummary;
import com.linkedin.datahub.graphql.generated.Entity;
import com.linkedin.metadata.authorization.PoliciesConfig;
import com.linkedin.usage.UsageClient;
import com.linkedin.usage.UsageTimeRange;
import com.linkedin.usage.UserUsageCounts;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -55,8 +59,15 @@ public CompletableFuture<DatasetStatsSummary> get(DataFetchingEnvironment enviro

try {

if (!isAuthorized(resourceUrn, context)) {
log.debug("User {} is not authorized to view profile information for dataset {}",
context.getActorUrn(),
resourceUrn.toString());
return null;
}

com.linkedin.usage.UsageQueryResult
usageQueryResult = usageClient.getUsageStats(resourceUrn.toString(), UsageTimeRange.MONTH, context.getAuthentication());
usageQueryResult = usageClient.getUsageStats(resourceUrn.toString(), UsageTimeRange.MONTH);

final DatasetStatsSummary result = new DatasetStatsSummary();
result.setQueryCountLast30Days(usageQueryResult.getAggregations().getTotalSqlQueries());
Expand Down Expand Up @@ -90,4 +101,10 @@ private CorpUser createPartialUser(final Urn userUrn) {
result.setUrn(userUrn.toString());
return result;
}

private boolean isAuthorized(final Urn resourceUrn, final QueryContext context) {
return AuthorizationUtils.isAuthorized(context,
Optional.of(new ResourceSpec(resourceUrn.getEntityType(), resourceUrn.toString())),
PoliciesConfig.VIEW_DATASET_USAGE_PRIVILEGE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import com.linkedin.datahub.graphql.generated.UsageQueryResult;
import com.linkedin.datahub.graphql.types.usage.UsageQueryResultMapper;
import com.linkedin.metadata.authorization.PoliciesConfig;
import com.linkedin.r2.RemoteInvocationException;
import com.linkedin.usage.UsageClient;
import com.linkedin.usage.UsageTimeRange;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.net.URISyntaxException;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -44,10 +42,10 @@ public CompletableFuture<UsageQueryResult> get(DataFetchingEnvironment environme
}
try {
com.linkedin.usage.UsageQueryResult
usageQueryResult = usageClient.getUsageStats(resourceUrn.toString(), range, context.getAuthentication());
usageQueryResult = usageClient.getUsageStats(resourceUrn.toString(), range);
return UsageQueryResultMapper.map(usageQueryResult);
} catch (RemoteInvocationException | URISyntaxException e) {
throw new RuntimeException(String.format("Failed to load Usage Stats for resource %s", resourceUrn.toString()), e);
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to load Usage Stats for resource %s", resourceUrn), e);
}
});
}
Expand Down
Loading

0 comments on commit e162349

Please sign in to comment.