You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/03/31 12:47:05 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a change in pull request #9303: [Feature][Task] K8s namespace auth manager

caishunfeng commented on a change in pull request #9303:
URL: https://github.com/apache/dolphinscheduler/pull/9303#discussion_r839550788



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java
##########
@@ -154,13 +155,15 @@ public Result queryListPaging(User loginUser, String searchVal, Integer pageNo,
         k8sNamespaceObj.setCreateTime(now);
         k8sNamespaceObj.setUpdateTime(now);
 
-        try {
-            String yamlStr = genDefaultResourceYaml(k8sNamespaceObj);
-            k8sClientService.upsertNamespaceAndResourceToK8s(k8sNamespaceObj, yamlStr);
-        } catch (Exception e) {
-            logger.error("namespace create to k8s error", e);
-            putMsg(result, Status.K8S_CLIENT_OPS_ERROR, e.getMessage());
-            return result;
+        if (!"ds_null_k8s".equals(k8sNamespaceObj.getK8s())) {

Review comment:
       It's better to use constant.

##########
File path: dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/K8sNamespaceMapper.xml
##########
@@ -45,4 +50,38 @@
         </if>
     </select>
 
+    <select id="queryNamespaceExceptUserId" resultType="org.apache.dolphinscheduler.dao.entity.K8sNamespace">
+        select
+        <include refid="baseSql"/>
+        from t_ds_k8s_namespace
+        where user_id <![CDATA[ <> ]]> #{userId}
+    </select>
+
+    <select id="queryAuthedNamespaceListByUserId" resultType="org.apache.dolphinscheduler.dao.entity.K8sNamespace">
+        select
+        <include refid="baseSqlV2">
+            <property name="alias" value="p"/>
+        </include>
+        from t_ds_k8s_namespace p,t_ds_relation_namespace_user rel
+        where p.id = rel.namespace_id and rel.user_id= #{userId}
+    </select>
+
+    <select id="queryNamespaceAvailable" resultType="org.apache.dolphinscheduler.dao.entity.K8sNamespace">

Review comment:
       ```suggestion
   select 
   <include refid="baseSqlV2">
      <property name="alias" value="b"/>
   </include>
   from t_ds_k8s_namespace ns 
   left join t_ds_relation_namespace_user u on u.namespace_id = ns.id
   where 1 = 1 and 
   <if "userId !=null and userId != ''>
      u.user_id = #{userId}
   </if>
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org