소스 검색

Merge pull request #10633 from RussWhitehead/roxieFix

HPCC-18706 Sometimes file access calls to Dali don't provide creds

Reviewed-By: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 년 전
부모
커밋
2957b5b34b
6개의 변경된 파일58개의 추가작업 그리고 9개의 파일을 삭제
  1. 19 3
      roxie/ccd/ccdcontext.cpp
  2. 5 0
      roxie/ccd/ccddali.cpp
  3. 1 0
      roxie/ccd/ccddali.hpp
  4. 11 1
      roxie/ccd/ccdfile.cpp
  5. 14 4
      roxie/ccd/ccdserver.cpp
  6. 8 1
      roxie/ccd/ccdstate.cpp

+ 19 - 3
roxie/ccd/ccdcontext.cpp

@@ -429,7 +429,7 @@ private:
 
     inline bool fileExists(const char *lfn)
     {
-        Owned<IDistributedFile> f = queryDistributedFileDirectory().lookup(lfn, NULL);  // MORE - need a userdescriptor from workunit
+        Owned<IDistributedFile> f = queryDistributedFileDirectory().lookup(lfn, queryUserDescriptor());
         if (f)
             return true;
         return false;
@@ -437,7 +437,15 @@ private:
 
     inline IUserDescriptor *queryUserDescriptor()
     {
-        return workunit->queryUserDescriptor();
+        if (workunit)
+            return workunit->queryUserDescriptor();//ad-hoc mode
+        else
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     bool checkPersistUptoDate(IRuntimeWorkflowItem & item, const char * logicalName, unsigned eclCRC, unsigned __int64 allCRC, bool isFile, StringBuffer &errText)
@@ -3666,7 +3674,15 @@ public:
     }
     IUserDescriptor *queryUserDescriptor()
     {
-        return NULL; // TBD - Richard, where do user credentials for a roxie query come from
+        if (workUnit)
+            return workUnit->queryUserDescriptor();//ad-hoc mode
+        else
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     virtual bool isResult(const char * name, unsigned sequence)

+ 5 - 0
roxie/ccd/ccddali.cpp

@@ -431,6 +431,11 @@ public:
             initMyNode(1); // Hack
     }
 
+    virtual IUserDescriptor *queryUserDescriptor()
+    {
+        return userdesc;
+    }
+
     static const char *getQuerySetPath(StringBuffer &buf, const char *id)
     {
         buf.appendf("QuerySets/QuerySet[@id='%s']", id);

+ 1 - 0
roxie/ccd/ccddali.hpp

@@ -56,6 +56,7 @@ interface IRoxieDaliHelper : extends IInterface
     virtual void noteQueuesRunning(const char *queueNames) = 0;
     virtual void noteWorkunitRunning(const char *wu, bool running) = 0;
     virtual StringBuffer &getDaliIp(StringBuffer &ip) const = 0;
+    virtual IUserDescriptor *queryUserDescriptor() = 0;
 };
 
 

+ 11 - 1
roxie/ccd/ccdfile.cpp

@@ -2646,7 +2646,17 @@ private:
 
             Owned<IDistributedFile> publishFile = queryDistributedFileDirectory().createNew(desc); // MORE - we'll create this earlier if we change the locking paradigm
             publishFile->setAccessedTime(modifiedTime);
-            publishFile->attach(dFile->queryLogicalName(), activity ? activity->queryUserDescriptor() : UNKNOWN_USER);
+            IUserDescriptor * userdesc = NULL;
+            if (activity)
+                userdesc = activity->queryUserDescriptor();
+            else
+            {
+                Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+                if (daliHelper)
+                    userdesc = daliHelper->queryUserDescriptor();//predeployed query mode
+            }
+
+            publishFile->attach(dFile->queryLogicalName(), userdesc);
             // MORE should probably write to the roxielocalstate too in case Dali is down next time I look...
         }
     }

+ 14 - 4
roxie/ccd/ccdserver.cpp

@@ -11625,9 +11625,14 @@ public:
     {
         IConstWorkUnit *workUnit = ctx->queryWorkUnit();
         if (workUnit)
-            return workUnit->queryUserDescriptor();
+            return workUnit->queryUserDescriptor();//ad-hoc mode
         else
-            return NULL;
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     virtual bool isOutputTransformed() const { return false; }
@@ -12168,9 +12173,14 @@ public:
     {
         IConstWorkUnit *workUnit = ctx->queryWorkUnit();
         if (workUnit)
-            return workUnit->queryUserDescriptor();
+            return workUnit->queryUserDescriptor();//ad-hoc mode
         else
-            return NULL;
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 };
 

+ 8 - 1
roxie/ccd/ccdstate.cpp

@@ -724,7 +724,14 @@ public:
         Owned<IRoxieDaliHelper> daliHelper = connectToDali();
         bool onlyLocal = fileNameServiceDali.isEmpty();
         bool onlyDFS = !resolveLocally() && !onlyLocal;
-        Owned<ILocalOrDistributedFile> ldFile = createLocalOrDistributedFile(fileName, NULL, onlyLocal, onlyDFS, true);
+
+        IUserDescriptor *user = NULL;
+        if (wu)
+            user = wu->queryUserDescriptor();//ad-hoc mode
+        else if (daliHelper)
+            user = daliHelper->queryUserDescriptor();//predeployed query mode
+
+        Owned<ILocalOrDistributedFile> ldFile = createLocalOrDistributedFile(fileName, user, onlyLocal, onlyDFS, true);
         if (!ldFile)
             throw MakeStringException(ROXIE_FILE_ERROR, "Cannot write %s", fileName.str());
         return createRoxieWriteHandler(daliHelper, ldFile.getClear(), clusters);