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

[DSIP-19] Support k8s connections in the connection center, as well as external connections to the connection center in k8s tasks #14977

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

xdu-chenrj
Copy link
Contributor

issue: #14338

Related issues: [DSIP-19][Feature] Add connection center feature for DS #10283

Mail: https://lists.apache.org/thread/xl6pb3sbrt0ffrf1fltcph39s9w1pjlx

@github-actions github-actions bot added UI ui and front end related backend e2e e2e test labels Sep 28, 2023
@mergeable mergeable bot removed UI ui and front end related backend e2e e2e test labels Sep 28, 2023
@github-actions github-actions bot added UI ui and front end related backend e2e e2e test labels Oct 12, 2023

import com.fasterxml.jackson.annotation.JsonInclude;

@Data

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
ConnectionParam.setPassword
; it is advisable to add an Override annotation.

protected String username;

protected String password;

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
ConnectionParam.getPassword
; it is advisable to add an Override annotation.
@EricGao888
Copy link
Member

@xdu-chenrj The commit history seems not correct.

@xdu-chenrj
Copy link
Contributor Author

@xdu-chenrj The commit history seems not correct.

yes

EricGao888
EricGao888 previously approved these changes Oct 31, 2023
Copy link
Member

@EricGao888 EricGao888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for CI to pass

@EricGao888 EricGao888 added feature new feature and removed feature new feature labels Oct 31, 2023
@EricGao888
Copy link
Member

@xdu-chenrj
image
Commit history seems still incorrect.

@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2023

Codecov Report

Merging #14977 (bf7a5b5) into dev (5a3827e) will increase coverage by 0.01%.
The diff coverage is 52.17%.

❗ Current head bf7a5b5 differs from pull request most recent head de8c741. Consider uploading reports for the commit de8c741 to get more accurate results

@@             Coverage Diff              @@
##                dev   #14977      +/-   ##
============================================
+ Coverage     38.19%   38.21%   +0.01%     
- Complexity     4684     4693       +9     
============================================
  Files          1275     1280       +5     
  Lines         45329    45410      +81     
  Branches       4949     4953       +4     
============================================
+ Hits          17315    17354      +39     
- Misses        26121    26163      +42     
  Partials       1893     1893              
Files Coverage Δ
...ache/dolphinscheduler/plugin/task/k8s/K8sTask.java 84.90% <100.00%> (+2.68%) ⬆️
...inscheduler/plugin/task/zeppelin/ZeppelinTask.java 55.33% <100.00%> (ø)
...in/datasource/k8s/param/K8sDataSourceParamDTO.java 0.00% <0.00%> (ø)
...lphinscheduler/plugin/task/k8s/K8sTaskChannel.java 0.00% <0.00%> (ø)
.../org/apache/dolphinscheduler/spi/enums/DbType.java 0.00% <0.00%> (ø)
...duler/plugin/task/api/K8sTaskExecutionContext.java 0.00% <0.00%> (ø)
...ugin/task/api/am/KubernetesApplicationManager.java 5.33% <0.00%> (-0.15%) ⬇️
...er/plugin/datasource/k8s/K8sDataSourceChannel.java 0.00% <0.00%> (ø)
...in/datasource/k8s/K8sDataSourceChannelFactory.java 0.00% <0.00%> (ø)
...uler/plugin/task/api/k8s/impl/K8sTaskExecutor.java 36.12% <0.00%> (-0.33%) ⬇️
... and 3 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sonarcloud
Copy link

sonarcloud bot commented Oct 31, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

50.5% 50.5% Coverage
2.3% 2.3% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@EricGao888 EricGao888 merged commit c532fea into apache:dev Oct 31, 2023
53 of 56 checks passed
Comment on lines +135 to +136
k8sTaskExecutionContext
.setConfigYaml(JSONUtils.getNodeString(k8sTaskExecutionContext.getConnectionParams(), "kubeConfig"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can not directly change this. For normal task, like spark on k8s, K8sTaskExecutionContext is constructed by TaskExecutionContextFactory, when they call getClient, connectionParams is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion

@Radeity
Copy link
Member

Radeity commented Oct 31, 2023

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj
Copy link
Contributor Author

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

ok

@EricGao888
Copy link
Member

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj I suggest submitting a patch to fix it instead of reverting the whole PR. BTW, as the PR passed the CI, it seems the UT hadn't covered this case. I think it will be better to add related UT to cover this scenario for those tasks using k8s connection.

@xdu-chenrj
Copy link
Contributor Author

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj I suggest submitting a patch to fix it instead of reverting the whole PR. BTW, as the PR passed the CI, it seems the UT hadn't covered this case. I think it will be better to add related UT to cover this scenario for those tasks using k8s connection.

Yes, thank you for your suggestion

@Radeity
Copy link
Member

Radeity commented Oct 31, 2023

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj I suggest submitting a patch to fix it instead of reverting the whole PR. BTW, as the PR passed the CI, it seems the UT hadn't covered this case. I think it will be better to add related UT to cover this scenario for those tasks using k8s connection.

Yes, thank you for your suggestion

You can see TaskExecutionContextFactory.setK8sTaskRelation, there are several types of task which already construct K8sTaskExecutionContext in Master. Anyway, you can ping me anytime if you need help with this patch :D

@EricGao888
Copy link
Member

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj I suggest submitting a patch to fix it instead of reverting the whole PR. BTW, as the PR passed the CI, it seems the UT hadn't covered this case. I think it will be better to add related UT to cover this scenario for those tasks using k8s connection.

Yes, thank you for your suggestion

You can see TaskExecutionContextFactory.setK8sTaskRelation, there are several types of task which already construct K8sTaskExecutionContext in Master. Anyway, you can ping me anytime if you need help with this patch :D

pretty cool

@xdu-chenrj
Copy link
Contributor Author

You can see TaskExecutionContextFactory.setK8sTaskRelation, there are several types of task which already construct K8sTaskExecutionContext in Master. Anyway, you can ping me anytime if you need help with this patch :D

Thank you very much for your suggestion :D

@xdu-chenrj
Copy link
Contributor Author

Hi @xdu-chenrj, non-K8S task should better be refactored and use k8s connection together with k8s task, maybe we have to revert this PR, or to fix this bug (refactor) ASAP. cc @EricGao888

@xdu-chenrj I suggest submitting a patch to fix it instead of reverting the whole PR. BTW, as the PR passed the CI, it seems the UT hadn't covered this case. I think it will be better to add related UT to cover this scenario for those tasks using k8s connection.

Yes, thank you for your suggestion

You can see TaskExecutionContextFactory.setK8sTaskRelation, there are several types of task which already construct K8sTaskExecutionContext in Master. Anyway, you can ping me anytime if you need help with this patch :D

    private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance taskInstance) {
        K8sTaskExecutionContext k8sTaskExecutionContext = null;
        String namespace = "", kubeConfig = "";
        log.info("getTaskParams {}", taskInstance.getTaskParams());
        switch (taskInstance.getTaskType()) {
            case "K8S":
            case "KUBEFLOW":
                K8sTaskParameters k8sTaskParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), K8sTaskParameters.class);
                namespace = k8sTaskParameters.getNamespace();
                kubeConfig = k8sTaskParameters.getKubeConfig();
                break;
            case "SPARK":
                SparkParameters sparkParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), SparkParameters.class);
                if (StringUtils.isNotEmpty(sparkParameters.getNamespace())) {
                    namespace = sparkParameters.getNamespace();
                }
                break;
            default:
                break;
        }

        if (StringUtils.isNotEmpty(namespace)) {
            String configYaml = kubeConfig;
            log.info("String configYaml {}", configYaml);
            if (configYaml != null) {
                k8sTaskExecutionContext =
                        new K8sTaskExecutionContext(configYaml, JSONUtils.toMap(namespace).get(NAMESPACE_NAME));
            }
        }
        return k8sTaskExecutionContext;
    } 

hi, I want to assign the value configYaml to k8sTaskExecutionContext through this method, but taskInstance. getTaskParams() lacks the kubeConfig required in K8sTaskParameters. I would like to receive your specific advice

@Radeity
Copy link
Member

Radeity commented Oct 31, 2023

    private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance taskInstance) {
        K8sTaskExecutionContext k8sTaskExecutionContext = null;
        String namespace = "", kubeConfig = "";
        log.info("getTaskParams {}", taskInstance.getTaskParams());
        switch (taskInstance.getTaskType()) {
            case "K8S":
            case "KUBEFLOW":
                K8sTaskParameters k8sTaskParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), K8sTaskParameters.class);
                namespace = k8sTaskParameters.getNamespace();
                kubeConfig = k8sTaskParameters.getKubeConfig();
                break;
            case "SPARK":
                SparkParameters sparkParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), SparkParameters.class);
                if (StringUtils.isNotEmpty(sparkParameters.getNamespace())) {
                    namespace = sparkParameters.getNamespace();
                }
                break;
            default:
                break;
        }

        if (StringUtils.isNotEmpty(namespace)) {
            String configYaml = kubeConfig;
            log.info("String configYaml {}", configYaml);
            if (configYaml != null) {
                k8sTaskExecutionContext =
                        new K8sTaskExecutionContext(configYaml, JSONUtils.toMap(namespace).get(NAMESPACE_NAME));
            }
        }
        return k8sTaskExecutionContext;
    } 

hi, I want to assign the value configYaml to k8sTaskExecutionContext through this method, but taskInstance. getTaskParams() lacks the kubeConfig required in K8sTaskParameters. I would like to receive your specific advice

Can we move method K8sTaskParameters .generateExtendedContext to AbstractParameters and name it generateK8sTaskExecutionContext. Then, for KUBEFLOW, Kubernetes, Spark task, call generateK8sTaskExecutionContext to construct K8sTaskExecutionContext inside their parameters' construction function. In this way, we don't have to setK8sTaskRelation in Master, WDYT?

@xdu-chenrj
Copy link
Contributor Author

    private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance taskInstance) {
        K8sTaskExecutionContext k8sTaskExecutionContext = null;
        String namespace = "", kubeConfig = "";
        log.info("getTaskParams {}", taskInstance.getTaskParams());
        switch (taskInstance.getTaskType()) {
            case "K8S":
            case "KUBEFLOW":
                K8sTaskParameters k8sTaskParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), K8sTaskParameters.class);
                namespace = k8sTaskParameters.getNamespace();
                kubeConfig = k8sTaskParameters.getKubeConfig();
                break;
            case "SPARK":
                SparkParameters sparkParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), SparkParameters.class);
                if (StringUtils.isNotEmpty(sparkParameters.getNamespace())) {
                    namespace = sparkParameters.getNamespace();
                }
                break;
            default:
                break;
        }

        if (StringUtils.isNotEmpty(namespace)) {
            String configYaml = kubeConfig;
            log.info("String configYaml {}", configYaml);
            if (configYaml != null) {
                k8sTaskExecutionContext =
                        new K8sTaskExecutionContext(configYaml, JSONUtils.toMap(namespace).get(NAMESPACE_NAME));
            }
        }
        return k8sTaskExecutionContext;
    } 

hi, I want to assign the value configYaml to k8sTaskExecutionContext through this method, but taskInstance. getTaskParams() lacks the kubeConfig required in K8sTaskParameters. I would like to receive your specific advice

Can we move method K8sTaskParameters .generateExtendedContext to AbstractParameters and name it generateK8sTaskExecutionContext. Then, for KUBEFLOW, Kubernetes, Spark task, call generateK8sTaskExecutionContext to construct K8sTaskExecutionContext inside their parameters' construction function. In this way, we don't have to setK8sTaskRelation in Master, WDYT?

I fixed this issue, and then I will create an issue and PR

@xdu-chenrj
Copy link
Contributor Author

    private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance taskInstance) {
        K8sTaskExecutionContext k8sTaskExecutionContext = null;
        String namespace = "", kubeConfig = "";
        log.info("getTaskParams {}", taskInstance.getTaskParams());
        switch (taskInstance.getTaskType()) {
            case "K8S":
            case "KUBEFLOW":
                K8sTaskParameters k8sTaskParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), K8sTaskParameters.class);
                namespace = k8sTaskParameters.getNamespace();
                kubeConfig = k8sTaskParameters.getKubeConfig();
                break;
            case "SPARK":
                SparkParameters sparkParameters =
                        JSONUtils.parseObject(taskInstance.getTaskParams(), SparkParameters.class);
                if (StringUtils.isNotEmpty(sparkParameters.getNamespace())) {
                    namespace = sparkParameters.getNamespace();
                }
                break;
            default:
                break;
        }

        if (StringUtils.isNotEmpty(namespace)) {
            String configYaml = kubeConfig;
            log.info("String configYaml {}", configYaml);
            if (configYaml != null) {
                k8sTaskExecutionContext =
                        new K8sTaskExecutionContext(configYaml, JSONUtils.toMap(namespace).get(NAMESPACE_NAME));
            }
        }
        return k8sTaskExecutionContext;
    } 

hi, I want to assign the value configYaml to k8sTaskExecutionContext through this method, but taskInstance. getTaskParams() lacks the kubeConfig required in K8sTaskParameters. I would like to receive your specific advice

Can we move method K8sTaskParameters .generateExtendedContext to AbstractParameters and name it generateK8sTaskExecutionContext. Then, for KUBEFLOW, Kubernetes, Spark task, call generateK8sTaskExecutionContext to construct K8sTaskExecutionContext inside their parameters' construction function. In this way, we don't have to setK8sTaskRelation in Master, WDYT?

I fixed this issue, and then I will create an issue and PR

and I plan to submit a PR to fix the problem first, and then add UT. Is that okay?

@Radeity
Copy link
Member

Radeity commented Nov 2, 2023

I fixed this issue, and then I will create an issue and PR

Glad to hear that!

and I plan to submit a PR to fix the problem first, and then add UT. Is that okay?

Sure, you can. I think, for a single pr, sometimes, small is better :D

@xdu-chenrj
Copy link
Contributor Author

I fixed this issue, and then I will create an issue and PR

Glad to hear that!

and I plan to submit a PR to fix the problem first, and then add UT. Is that okay?

Sure, you can. I think, for a single pr, sometimes, small is better :D

issue: #15114
pr: #15116

zhongjiajie added a commit that referenced this pull request Feb 6, 2024
…naged in connection center (#14977)"

This reverts commit c532fea.
zhongjiajie added a commit to zhongjiajie/dolphinscheduler that referenced this pull request Feb 7, 2024
zhongjiajie added a commit that referenced this pull request Feb 7, 2024
* Revert "Fix k8sTaskExecutionContext setting configYaml (#15116)"

This reverts commit ce11674.

* Revert "[Improvement] Refactoring K8S task plugin with connections managed in connection center (#14977)"

This reverts commit c532fea.
@SbloodyS SbloodyS added the 3.3.0 label Jun 26, 2024
@SbloodyS SbloodyS added the DSIP label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.3.0 backend DSIP e2e e2e test improvement make more easy to user or prompt friendly ready-to-merge UI ui and front end related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants