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

feat: Task resource v1 readiness #3113

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-jcieslak
Copy link
Collaborator

@sfc-gh-jcieslak sfc-gh-jcieslak commented Oct 3, 2024

Changes

  • Mostly done task resource refactor
  • Sweepers test fixed (they always added errors even when they're nil)
  • Minor changes in SDK (find out the bug with alter task and right now we're only supporting upper-cased warehouse names; added that to the field description)
  • Acceptance tests
  • The enabled field is not a three-valued boolean because it created certain issues when updating the task. The task status is very important for their management and working, so I decided to have them as regular boolean values that are either true or false, nothing in between.

Next prs

  • Apply comments from feat: Tasks v1 readiness - SDK part #3086
  • Data source
  • Move some of the logic to SDK
  • Refactor SDK suspend root logic for tasks (and overall suspend logic in SDK/resource)
  • Examples, documentation, and migration guide
  • More test cases for complicated DAG structures to show the resource can handle more complex structures
  • Analyze non-deterministic test cases
  • Refactor task resuming in task resource (most likely with the use of defer) because currently, there may be cases that error can cause tasks to be not resumed.

References

Copy link

github-actions bot commented Oct 3, 2024

Integration tests failure for 28bf6a5cb6a95fa2d9cb42a558710bb4ad08ee58

@sfc-gh-jcieslak sfc-gh-jcieslak marked this pull request as ready for review October 4, 2024 09:20
Copy link

github-actions bot commented Oct 4, 2024

Integration tests failure for 62adccb771be11faeea226dd4b4b4c29fcea2833

func (t *TaskResourceAssert) HasAfterIds(ids ...sdk.SchemaObjectIdentifier) *TaskResourceAssert {
t.AddAssertion(assert.ValueSet("after.#", strconv.FormatInt(int64(len(ids)), 10)))
for i, id := range ids {
t.AddAssertion(assert.ValueSet(fmt.Sprintf("after.%d", i), id.FullyQualifiedName()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The order shouldn't matter here.


import (
"fmt"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
Copy link
Collaborator

Choose a reason for hiding this comment

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

reviewdog

return u.
HasSuspendTaskAfterNumFailures(10).
HasTaskAutoRetryAttempts(0).
HasUserTaskManagedInitialWarehouseSize("Medium").
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use const from sdk.

HasClientSessionKeepAliveHeartbeatFrequency(3600).
HasClientTimestampTypeMapping(sdk.ClientTimestampTypeMappingLtz).
HasDateInputFormat("AUTO").
HasDateOutputFormat("YYYY-MM-DD").
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I wonder if Snowflake has a list of available fields, and if we could use enums here if it makes sense (in other places as well).

HasTransactionAbortOnError(false).
HasTransactionDefaultIsolationLevel(sdk.TransactionDefaultIsolationLevelReadCommitted).
HasTwoDigitCenturyStart(1970).
HasUnsupportedDdlAction(sdk.UnsupportedDDLAction(strings.ToLower(string(sdk.UnsupportedDDLActionIgnore)))).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious, why do we convert to lower case?

HasSuspendTaskAfterNumFailuresString("2"),
resourceshowoutputassert.TaskShowOutput(t, rootTaskModel.ResourceReference()).
HasSchedule(schedule).
// HasTaskRelations(sdk.TaskRelations{FinalizerTask: &finalizerTaskId}).
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about these comments?

resourceassert.TaskResource(t, firstTaskStandaloneModelDisabled.ResourceReference()).
HasScheduleString(schedule).
HasEnabledString(r.BooleanFalse).
HasSuspendTaskAfterNumFailuresString("10"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also check that finalized/finalizer fields are empty.

basicConfigModel := model.TaskWithId("test", id, false, statement)

// New warehouse created, because the common one has lower-case letters that won't work
warehouse, warehouseCleanup := acc.TestClient().Warehouse.CreateWarehouse(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have SNOW-1541938 for streamlits, we should create a similar ticket for this.

expectedTaskConfig := strings.ReplaceAll(taskConfig, "$", "")
taskConfigVariableValue := "$" + taskConfig
comment := random.Comment()
condition := `SYSTEM$STREAM_HAS_DATA('MYSTREAM')`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have some test cases for different spaces and new lines for fields with SQL statements.

HasConfig(expectedTaskConfig).
HasBudget("").
HasTaskRelations(sdk.TaskRelations{}),
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pls add a test case with external changes.

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.

2 participants