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

SNOW-1011772: Suspend and resume commands for compute pools. #740

Merged
merged 9 commits into from
Feb 7, 2024

Conversation

sfc-gh-davwang
Copy link
Contributor

@sfc-gh-davwang sfc-gh-davwang commented Feb 6, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

Added spcs compute-pool suspend <pool_name> and spcs compute-pool resume <pool_name> and updated compute pools tests to check that these commands properly change the compute pool state.

Usage:
compute_pool_resume
compute_pool_suspend

@@ -12,8 +12,9 @@
SINGLE_QUOTED_STRING_LITERAL_REGEX = r"'((?:\\.|''|[^'\n])+?)'"

# See https://docs.snowflake.com/en/sql-reference/identifiers-syntax for identifier syntax
UNQUOTED_IDENTIFIER_REGEX = r"(^[a-zA-Z_])([a-zA-Z0-9_$]{0,254})"
UNQUOTED_IDENTIFIER_REGEX = r"([a-zA-Z_])([a-zA-Z0-9_$]{0,254})"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UNQUOTED_IDENTIFIER_REGEX is only ever used with re.fullmatch so this will not change existing behavior but allows it to be used in other patterns for more flexibility.

("user", "user-example"),
("warehouse", "warehouse-example"),
("view", "view-example"),
("compute-pool", "compute_pool_example"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically hyphens (-) are not allowed as unquoted identifiers, so we should not be using them as arguments for our test object names. This currently cannot be validated with is_valid_object_name because there are also cases where the object identifier is given as object_name(argDataType1, argDataType2, ...) such as UDFs and procedures. Future work could be to add this validation.

sfc-gh-cgorrie
sfc-gh-cgorrie previously approved these changes Feb 6, 2024
Copy link
Contributor

@sfc-gh-cgorrie sfc-gh-cgorrie left a comment

Choose a reason for hiding this comment

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

LGTM (for common project util + test changes). Thanks for creating reusable primitives!

rf"{VALID_IDENTIFIER_REGEX}(?:\.{VALID_IDENTIFIER_REGEX}){{0,{max_depth}}}"
)
return re.fullmatch(pattern, name) is not None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented this to validate compute pool names before I remembered that compute pools are account level objects and thus is_valid_identifier is sufficient. However, I still think it's a useful primitive, especially for validating schema level objects like services, tables, etc.

sfc-gh-astus
sfc-gh-astus previously approved these changes Feb 7, 2024
sfc-gh-astus
sfc-gh-astus previously approved these changes Feb 7, 2024
@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011772-pool-suspend-resume branch from ab5260d to 3604ed2 Compare February 7, 2024 17:05
@sfc-gh-davwang sfc-gh-davwang merged commit c4aa982 into main Feb 7, 2024
17 checks passed
@sfc-gh-davwang sfc-gh-davwang deleted the SNOW-1011772-pool-suspend-resume branch February 7, 2024 17:17
sfc-gh-sichen pushed a commit that referenced this pull request Oct 17, 2024
* Creating validation functions for object names.

* SNOW-1011772: Adding templates for suspend/resume

* SNOW-1011772: Adding 'resume' and 'suspend' commands for 'spcs compute-pool'.

* SNOW-1011772: Adding doc strings

* SNOW-1011772: Documentation fixes

* SNOW-1011772: Test fixes

* SNOW-1011772: Update release notes

* SNOW-1011772: Formatting

* SNOW-1011772: Updating compute pool callback to only allow a single valid identifier
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.

3 participants