Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-tkommineni committed Jan 6, 2025
1 parent 6789138 commit 5411ad2
Show file tree
Hide file tree
Showing 6 changed files with 598 additions and 219 deletions.
9 changes: 6 additions & 3 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
* `snow app release-directive set`
* `snow app release-directive unset`
* `snow app version create` now returns version, patch, and label in JSON format.
* Add ability to specify release channel when creating application instance from release directive: `snow app run --from-release-directive --channel=<channel>`
* Add ability to list release channels through `snow app release-channel list` command
* Add support for release channels:
* Add support for release channels feature in native app version creation/drop.
* Add ability to specify release channel when creating application instance from release directive: `snow app run --from-release-directive --channel=<channel>`
* Add ability to list release channels through `snow app release-channel list` command
* Add ability to add and remove accounts from release channels through `snow app release-channel add-accounts` and snow app release-channel remove-accounts` commands.
* Add ability to add/remove versions to/from release channels through `snow app release-channel add-version` and `snow app release-channel remove-version` commands.
* Add `snow spcs service events` command to retrieve service-specific events:
* Supports filtering by service name, container name, instance ID, time intervals (`--since`, `--until`), and pagination (`--first`, `--last`).
* Use `--all` to fetch all columns.
* Add `snow spcs service metrics` command to fetch service metrics:
* Supports filtering by service name, container name, instance ID, and time intervals (`--since`, `--until`).
* Use `--all` to fetch all columns.


## Fixes and improvements
* Fixed crashes with older x86_64 Intel CPUs.
* Fixed inability to add patches to lowercase quoted versions
Expand Down
4 changes: 2 additions & 2 deletions src/snowflake/cli/_plugins/spcs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def format_event_row(event_dict: dict) -> dict:
"DATABASE NAME": database_name,
"SCHEMA NAME": schema_name,
"SERVICE NAME": service_name,
"INSTANCE NAME": instance_name,
"INSTANCE ID": instance_name,
"CONTAINER NAME": container_name,
"SEVERITY": severity,
"EVENT NAME": event_name,
Expand Down Expand Up @@ -232,7 +232,7 @@ def format_metric_row(metric_dict: dict) -> dict:
"DATABASE NAME": database_name,
"SCHEMA NAME": schema_name,
"SERVICE NAME": service_name,
"INSTANCE NAME": instance_name,
"INSTANCE ID": instance_name,
"CONTAINER NAME": container_name,
"METRIC NAME": metric_name,
"METRIC VALUE": metric_value,
Expand Down
16 changes: 13 additions & 3 deletions src/snowflake/cli/_plugins/spcs/services/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ def events(
help="Fetch events that are older than this time ago, in Snowflake interval syntax.",
),
first: int = typer.Option(
default=-1,
default=None,
show_default=False,
help="Fetch only the first N events. Cannot be used with --last.",
),
last: int = typer.Option(
default=-1,
default=None,
show_default=False,
help="Fetch only the last N events. Cannot be used with --first.",
),
Expand All @@ -339,13 +339,16 @@ def events(
),
**options,
):
"""
Retrieve platform events for a service container.
"""
if FeatureFlag.ENABLE_SPCS_SERVICE_EVENTS.is_disabled():
raise FeatureNotEnabledError(
"ENABLE_SPCS_SERVICE_EVENTS",
"Service events collection from SPCS event table is disabled.",
)

if first >= 0 and last >= 0:
if first is not None and last is not None:
raise IncompatibleParametersError(["--first", "--last"])

manager = ServiceManager()
Expand All @@ -359,6 +362,10 @@ def events(
last=last,
show_all_columns=show_all_columns,
)

if not events:
return MessageResult("No events found.")

return CollectionResult(events)


Expand Down Expand Up @@ -393,6 +400,9 @@ def metrics(
),
**options,
):
"""
Retrieve platform metrics for a service container.
"""
if FeatureFlag.ENABLE_SPCS_SERVICE_METRICS.is_disabled():
raise FeatureNotEnabledError(
"ENABLE_SPCS_SERVICE_METRICS",
Expand Down
8 changes: 4 additions & 4 deletions src/snowflake/cli/_plugins/spcs/services/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def get_events(
container_name: str,
since: str | datetime | None = None,
until: str | datetime | None = None,
first: int = -1,
last: int = -1,
first: Optional[int] = None,
last: Optional[int] = None,
show_all_columns: bool = False,
):

Expand All @@ -234,8 +234,8 @@ def get_events(
)
since_clause, until_clause = build_time_clauses(since, until)

first_clause = f"limit {first}" if first >= 0 else ""
last_clause = f"limit {last}" if last >= 0 else ""
first_clause = f"limit {first}" if first is not None else ""
last_clause = f"limit {last}" if last is not None else ""

query = f"""\
select *
Expand Down
Loading

0 comments on commit 5411ad2

Please sign in to comment.