apache/dolphinscheduler

[Bug] [seatunnel] buildOptions with getResourceName may be error

Closed this issue · 2 comments

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

this code may be error when get ResourceName:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                args.add(resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

should be change to below to resolve:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                // args.add(resourceInfo.getResourceName().substring(1));
                String path = resourceInfo.getResourceName();

                String absolutePath= taskExecutionContext.getResourceContext().getResourceItem(path)
                        .getResourceAbsolutePathInLocal();
                args.add(absolutePath);                
                // args.add("/" + resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

What you expected to happen

this code may be error when get ResourceName:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                args.add(resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

should be change to below to resolve:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                // args.add(resourceInfo.getResourceName().substring(1));
                String path = resourceInfo.getResourceName();

                String absolutePath= taskExecutionContext.getResourceContext().getResourceItem(path)
                        .getResourceAbsolutePathInLocal();
                args.add(absolutePath);                
                // args.add("/" + resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

How to reproduce

this code may be error when get ResourceName:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                args.add(resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

should be change to below to resolve:

 protected List<String> buildOptions() throws Exception {
        List<String> args = new ArrayList<>();
        if (BooleanUtils.isTrue(seatunnelParameters.getUseCustom())) {
            args.add(CONFIG_OPTIONS);
            args.add(buildCustomConfigCommand());
        } else {
            seatunnelParameters.getResourceList().forEach(resourceInfo -> {
                args.add(CONFIG_OPTIONS);
                // TODO: Need further check for refactored resource center
                // TODO Currently resourceName is `/xxx.sh`, it has more `/` and needs to be optimized
                // args.add(resourceInfo.getResourceName().substring(1));
                String path = resourceInfo.getResourceName();

                String absolutePath= taskExecutionContext.getResourceContext().getResourceItem(path)
                        .getResourceAbsolutePathInLocal();
                args.add(absolutePath);                
                // args.add("/" + resourceInfo.getResourceName().replaceFirst(".*:", ""));
            });
        }
        return args;
    }

Anything else

my env is docker with minio as resourcemanager to get resource

Version

3.2.x

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.