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

[feature] tasks #196

Merged
merged 26 commits into from
Jun 2, 2020
Merged

[feature] tasks #196

merged 26 commits into from
Jun 2, 2020

Conversation

henriblancke
Copy link
Contributor

@henriblancke henriblancke commented May 19, 2020

Attempt to add task support.

Couple of notes:

  • There is no support for the copy grants option on tasks as we're never cloning or replacing an existing task
  • after only supports tasks that are in the same schema (as per the docs)
  • This PR doesn't implement task grants but we could make it part of it?
  • The task is automatically started after creation

Travis build

@henriblancke henriblancke requested a review from a team as a code owner May 19, 2020 21:14
@henriblancke henriblancke requested review from kuannie1 and removed request for a team May 19, 2020 21:14
pkg/resources/task_test.go Outdated Show resolved Hide resolved
pkg/snowflake/task.go Outdated Show resolved Hide resolved
pkg/resources/task.go Outdated Show resolved Hide resolved
pkg/resources/task.go Show resolved Hide resolved
Copy link
Contributor

@ryanking ryanking left a comment

Choose a reason for hiding this comment

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

One thing I forgot on the previous review - can you add an acceptance test for this resource? Ideally one that exercises some of the update logic.

@chriskuchin chriskuchin mentioned this pull request May 20, 2020
1 task
@ryanking
Copy link
Contributor

@henriblancke it appears there is another PR covering this -> #198

Can you all work together on this?

@chriskuchin
Copy link
Contributor

chriskuchin commented May 20, 2020

@henriblancke @ryanking Happy to collaborate here the core of our 2 MRs seems very similar minus a few cosmetic differences. The biggest difference seems to be in mine I handle temporarily suspending the root task of a tree so that the child tasks can be altered and then resume it after the fact.

From the docs:

Modifying a standalone task requires that the task is suspended.

Modifying any task in a tree of tasks requires that the root task is suspended.

Another difference is that in my PR i directly expose the state (Suspended|Started) via an enabled flag.

Anyways let me know how I can Help.

@henriblancke
Copy link
Contributor Author

@chriskuchin yeah your handling of task dependencies seems much better. Having the option to enable/disable the task is also nice! One thing I noticed tho is that you're not exposing session_parameters in your PR? Maybe we should just add that and we're good to go? It's up to @ryanking on how you all want to handle this :)

@chriskuchin
Copy link
Contributor

Yeah I got distracted and forgot about them. Happy to put a little more time into the PR if that's what we wanna do and add that

@ryanking
Copy link
Contributor

One thing I noticed tho is that you're not exposing session_parameters in your PR?

Perhaps we can move forward by merging @chriskuchin's PR then adding session_params as a separate PR?

@chriskuchin
Copy link
Contributor

I nearly have the session_parameters piece done on my PR just testing and debugging now @ryanking

@henriblancke
Copy link
Contributor Author

@ryanking @chriskuchin I actually went ahead and added the enabled flag and logic to suspend root or standalone tasks before modifying / creating a child task. I think my use of defer to reactivate the suspended root task might be a little cleaner and safer when anything else fails during modifying or creating a new task. That way we'll always re-enable the root task? Let me know what you all think...

@chriskuchin
Copy link
Contributor

@henriblancke sounds good. Have you tested you session parameters? I had to modify them pretty heavily for them to actually work. Plus you weren't reading their state at all.

@henriblancke
Copy link
Contributor Author

@chriskuchin it did test em, but maybe not enough 😄? Can you elaborate? What do you mean by not reading state? Thanks!

@chriskuchin
Copy link
Contributor

You never read at least that I could find the parameters after you set them. The other problem I had was you were escaping the parameter values which caused them to be invalid as well as not wrapping them in quotes

@chriskuchin
Copy link
Contributor

They aren't even running they error out about not being configured in Travis. Are they passing for you locally?

@chriskuchin
Copy link
Contributor

Ahh you have the acceptance tests hooked up to your fork... I have no idea that was never an error I saw when writing them or getting things working. Sounds like it's an error in the first step. You can enable tf_logs=debug to get more info but it's really noisy so might be hard. Can you run it locally so you run just that test with debug?

@chriskuchin
Copy link
Contributor

So it seems to have something to do with your state. The error occurs during a state refresh so it's probably in the read function I would guess

@henriblancke
Copy link
Contributor Author

@chriskuchin yeah just figured it out adding the id we get from snowflake during reading the task caused the error. It breaks taskIDFromString. I'm running into more problems tho now that this one is resolved

@chriskuchin
Copy link
Contributor

ahh that makes sense I didn't follow that compound id pattern in My MR 👍 let me know if i can help

@ryanking
Copy link
Contributor

@ryanking not sure why the Acceptance tests aren't running in your CI but as long as those are passing the PR looks good to me

ok i will take a look

@ryanking ryanking self-assigned this May 27, 2020
@henriblancke
Copy link
Contributor Author

@ryanking they should be all green here

Copy link
Contributor

@ryanking ryanking left a comment

Choose a reason for hiding this comment

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

This looks quite good, most of my comments here are matters of style.

Comment on lines 146 to 148
for {

builder := snowflake.Task(name, database, dbSchema)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for {
builder := snowflake.Task(name, database, dbSchema)
for {
builder := snowflake.Task(name, database, dbSchema)

row := snowflake.QueryRow(db, q)
task, err := snowflake.ScanTask(row)

if err != nil && name != data.Get("name").(string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This conditional is not very clear. Why do we ignore errors when name == data.Get("name")?

pkg/resources/task.go Show resolved Hide resolved
pkg/resources/task.go Outdated Show resolved Hide resolved
pkg/resources/task.go Outdated Show resolved Hide resolved
pkg/resources/task.go Outdated Show resolved Hide resolved
pkg/resources/task.go Show resolved Hide resolved
pkg/resources/task.go Outdated Show resolved Hide resolved
@ryanking ryanking assigned henriblancke and unassigned ryanking May 28, 2020
@ryanking ryanking removed the request for review from kuannie1 May 28, 2020 16:14
pkg/snowflake/task.go Outdated Show resolved Hide resolved
@henriblancke henriblancke requested a review from a team as a code owner May 31, 2020 18:33
@henriblancke henriblancke requested review from ryanking and removed request for a team May 31, 2020 18:40
@ryanking ryanking assigned ryanking and unassigned henriblancke Jun 1, 2020
@ryanking ryanking merged commit 839cf23 into Snowflake-Labs:master Jun 2, 2020
@ryanking ryanking mentioned this pull request Aug 3, 2020
1 task
czimergebot pushed a commit that referenced this pull request Aug 3, 2020
Snowflake appears to have changed something which is now causing this
test to fail. Skipping it for now while I find someone who can address
the problem.

cc @henriblancke  and @chriskuchin  who worked on this originally. Any chance one of you could look at this?

## Test Plan
* [ ] acceptance tests

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

Successfully merging this pull request may close these issues.

None yet

4 participants