Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync beta with master #3983

Merged
merged 18 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
init commit - Added flag for one time check in authRemoveRelation if …
…request is from WF.
hr2904 committed Jan 14, 2025
commit 298470af652e610a20ecb02cd4cf3bb63ede5484
Original file line number Diff line number Diff line change
@@ -514,6 +514,9 @@ public List<AtlasVertex> addTagPropagation(AtlasVertex classificationVertex, Lis

public void authorizeRemoveRelation(AtlasEdge edge) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("authoriseRemoveRelation");
if(isRequestFromWF()){
RequestContext.get().setAuthorisedRemoveRelation(true);
}
AtlasEntityHeader end1Entity, end2Entity;
String relationShipType = getTypeName(edge);
AtlasRelationshipDef relationshipDef = typeRegistry.getRelationshipDefByName(relationShipType);
@@ -529,6 +532,15 @@ public void authorizeRemoveRelation(AtlasEdge edge) throws AtlasBaseException {
RequestContext.get().endMetricRecord(metric);
}

private boolean isRequestFromWF() {
String workflowID = RequestContext.get().getRequestContextHeaders().getOrDefault("x-atlan-agent-workflow-id", "");
boolean ret = workflowID.isEmpty();
if(ret){
LOG.info("Authorised one time request for workflow with id : {} ", workflowID);
}
return ret;
}

public Map<AtlasVertex, List<AtlasVertex>> removeTagPropagation(AtlasEdge edge) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("removeTagPropagationEdge");

Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@

package org.apache.atlas.repository.store.graph.v1;

import org.apache.atlas.RequestContext;
import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.repository.graph.GraphHelper;
@@ -56,7 +57,9 @@ protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseExcepti
}
boolean isRelationshipEdge = isRelationshipEdge(edge);

authorizeRemoveRelation(edge);
if(!RequestContext.get().isAuthorisedRemoveRelation()) {
authorizeRemoveRelation(edge);
}

if (DEFERRED_ACTION_ENABLED) {
createAndQueueClassificationRefreshPropagationTask(edge);
Original file line number Diff line number Diff line change
@@ -73,8 +73,9 @@ protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseExcepti
LOG.debug("==> SoftDeleteHandlerV1.deleteEdge({}, {})", GraphHelper.string(edge), force);
}
boolean isRelationshipEdge = isRelationshipEdge(edge);

authorizeRemoveRelation(edge);
if(!RequestContext.get().isAuthorisedRemoveRelation()) {
authorizeRemoveRelation(edge);
}

if (DEFERRED_ACTION_ENABLED && RequestContext.get().getCurrentTask() == null) {
if (CollectionUtils.isNotEmpty(getPropagatableClassifications(edge))) {
10 changes: 10 additions & 0 deletions server-api/src/main/java/org/apache/atlas/RequestContext.java
Original file line number Diff line number Diff line change
@@ -87,6 +87,9 @@ public class RequestContext {
private int attemptCount = 1;
private boolean isImportInProgress = false;
private boolean isInNotificationProcessing = false;


private boolean authorisedRemoveRelation = false;
private boolean isInTypePatching = false;
private boolean createShellEntityForNonExistingReference = false;
private boolean skipFailedEntities = false;
@@ -204,6 +207,13 @@ public void clearEntityCache() {
this.entityCache.clear();
}

public boolean isAuthorisedRemoveRelation() {
return authorisedRemoveRelation;
}

public void setAuthorisedRemoveRelation(boolean authorisedRemoveRelation) {
this.authorisedRemoveRelation = authorisedRemoveRelation;
}
public Set<String> getRelationAttrsForSearch() {
return relationAttrsForSearch;
}