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

Digdag push validation on the server side. #1026

Merged

Conversation

hiroyuki-sato
Copy link
Contributor

Hello, @muga , @yoyama

Could you advise me how to implement a validation?

digdag push requires validation on the server side.
It requires two things at least. And this issue will Fix two issues.

I implement the first one. Second schedule validation seems to require SchedulerManager class.
hiroyuki-sato@5004fb6#diff-84a9dc43263ac1f78fa3b2aca8234f6fR576

I'm not familiar with Google Guice. I'm not sure how to instantiate it. Do you have any idea for that?

This code almost copies of digdag check code.
https://github.com/treasure-data/digdag/blob/master/digdag-cli/src/main/java/io/digdag/cli/Check.java

Best regards.

@muga
Copy link
Member

muga commented Feb 26, 2019

Hi @hiroyuki-sato, thank you for taking this improvement.

I'm not familiar with Google Guice. I'm not sure how to instantiate it. Do you have any idea for that?

ScheduleManager is already injected in digdag-server ServerModule. Please add the ScheduleManager parameter to the constructor in ProjectResource like WorkflowCompiler. Then, we can use the object in the class without the object creation explicitly. Your code change basically sounds good to me.

@hiroyuki-sato
Copy link
Contributor Author

@muga Thank you for the advice.

I implement it. I'll add integration tests later.

validate tasks.

digdag push hoge
2019-02-26 16:39:41 +0900: Digdag v0.9.33
Creating .digdag/tmp/archive-5515688681553749096.tar.gz...
  Archiving fuga.dig
  Archiving scripts/myscript.sh
Workflows:
  fuga.dig
error: Status code 400: {"message":"io.digdag.core.repository.ModelValidationException: Validating workflow failed\n+fuga+setup contains invalid keys: 'sh': \"{\"sh\":\"echo start ${session_time}\"}\"","status":400}

validate schedule.

2019-02-26 16:42:19 +0900: Digdag v0.9.33
Creating .digdag/tmp/archive-6443414997521903051.tar.gz...
  Archiving fuga.dig
  Archiving scripts/myscript.sh
Workflows:
  fuga.dig
error: Status code 400: {"message":"hourly>: scheduler requires mm:ss format: test","status":400}

@muga
Copy link
Member

muga commented Feb 26, 2019

@hiroyuki-sato it's cool. thanks!

@hiroyuki-sato
Copy link
Contributor Author

@muga. Please take a look when you have time.

I created ValidateProjectIT.java for testing this PR.
Is it better to place those tests in another class?

Those comment part doesn't need to this class. I will just remove it.
What do you think?. I'm not sure it possible to validate more.

                        // validate workflow and schedule
//                        Set<String> required = new HashSet<>();
                        for (WorkflowTask task : wf.getTasks()) {
                            // raise an exception if task doesn't valid.
                            task.getConfig();
//                            String require = config.getOptional("require>", String.class).orNull();
//                            if (require != null && required.add(require)) {
//                                f.ln("  -> %s", require);
//                            }

@yoyama yoyama added this to the 0.9.35 milestone Feb 27, 2019
@yoyama yoyama modified the milestones: 0.9.35, 0.9.36 Mar 11, 2019
@muga muga self-requested a review March 12, 2019 03:01
Copy link
Member

@muga muga left a comment

Choose a reason for hiding this comment

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

@hiroyuki-sato sorry to be late response.

I created ValidateProjectIT.java for testing this PR. Is it better to place those tests in another class?

Good for me to keep this class. Thank you for adding the test.

Those comment part doesn't need to this class. I will just remove it. What do you think?. I'm not sure it possible to validate more.

I believe this is good as first validation. We will be able to refine it later. so, please remove those comment lines.

srm.tryGetScheduler(rev, def);

}

Copy link
Member

Choose a reason for hiding this comment

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

To keep the logic of putProject method simple, can you separate your validation logic from this method and copy the logic to another private method that you will create?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated validation method.

@hiroyuki-sato
Copy link
Contributor Author

@muga Thank you for the comment. I removed unnecessary comments and moved validation into a separate method. Please take a look when you have time.

@muga muga changed the title [WIP] Digdag push validation on the server side. Digdag push validation on the server side. Mar 12, 2019
Copy link
Member

@muga muga left a comment

Choose a reason for hiding this comment

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

@hiroyuki-sato thank you for improving! Looks good to me. @yoyama what do you think this change??

@yoyama yoyama self-requested a review March 12, 2019 06:59
@yoyama
Copy link
Contributor

yoyama commented Mar 12, 2019

@hiroyuki-sato I added a few comments. Could you fix them? Then LGTM.

@hiroyuki-sato
Copy link
Contributor Author

@yoyama Thank you for the comment. There is still a much-unused import statement. That's why I can't use Optimize imports feature in IntelliJ. 😢
Anyway, I removed those imports which I added.
Please take a look when you have time.

Copy link
Contributor

@yoyama yoyama left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@muga muga merged commit eb44c91 into treasure-data:master Mar 16, 2019
@muga
Copy link
Member

muga commented Mar 16, 2019

merged..

@hiroyuki-sato
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants