Skip to content

Status, Details, and List rayclusters CLI Functions #258

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

Merged
merged 10 commits into from
Aug 3, 2023
Merged

Status, Details, and List rayclusters CLI Functions #258

merged 10 commits into from
Aug 3, 2023

Conversation

carsonmh
Copy link
Contributor

Issue link

Closes #240

What changes have been made

  • Added list rayclusters details raycluster and status raycluster functions in the CLI
  • Added list_clusters_all_namespaces to list all RayClusters in all the namespaces in a Kubernetes Cluster

Verification steps

After building SDK, see list of commands using codeflare

  • list rayclusters for listing, optionally specifying namespace or --all
  • status raycluster specifying name as an argument and namespace as an option
  • details raycluster specifying name as an argument and namespace as an option

There are also unit tests for these functions to be run

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • Testing is not required for this change

@carsonmh carsonmh changed the base branch from main to cli-update July 31, 2023 21:22
Copy link
Collaborator

@Maxusmusti Maxusmusti left a comment

Choose a reason for hiding this comment

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

Looks great, just a couple of small adjustments:

  • Rather than have the default namespace be "default" for list/status/details, I think we should simply require the user to specify the namespace. We are slowly moving away from default="default" (still some things to change in the SDK), as it's not actually what most people use.
  • You may want to clean up output when a cluster of a certain name is not found:
Traceback (most recent call last):
File "/opt/homebrew/bin/codeflare", line 8, in <module>
  sys.exit(cli())
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
  return self.main(*args, **kwargs)
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 1053, in main
  rv = self.invoke(ctx)
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
  return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
  return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
  return ctx.invoke(self.callback, **ctx.params)
File "/opt/homebrew/lib/python3.8/site-packages/click/core.py", line 754, in invoke
  return __callback(*args, **kwargs)
File "/opt/homebrew/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
  return f(get_current_context(), *args, **kwargs)
File "/Users/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/cli/commands/status.py", line 19, in raycluster
  cluster = get_cluster(name, namespace)
File "/Users/meyceoz/Documents/codeflare-sdk/src/codeflare_sdk/cluster/cluster.py", line 433, in get_cluster
  raise FileNotFoundError(
FileNotFoundError: Cluster quicktest is not found in default namespace

This is the correct error, though since this is a CLI, we may want to catch this FileNotFoundError and just tell the user the message part "Cluster {name} not found in {ns} namespace"

  • With the current implementation, it seems as though we are rewriting the appwrapper to storage every time we call status or details, due to recreation of the Cluster object. I don't think this is necessarily a blocking issue, but something we may want to think about, or maybe open an issue for, for tracking purposes.

@carsonmh carsonmh requested a review from Maxusmusti August 2, 2023 20:45
Copy link
Collaborator

@Maxusmusti Maxusmusti left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Maxusmusti

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2023
@openshift-merge-robot openshift-merge-robot merged commit 68dff40 into project-codeflare:cli-update Aug 3, 2023
@MichaelClifford
Copy link
Collaborator

@Maxusmusti @carsonmh what about using cluster.get_current_namespace() instead of requiring a namespace? This should just default to the current context's namespace.

@click.option("--namespace", type=str)
@click.option("--all", is_flag=True)
@click.pass_context
def rayclusters(ctx, namespace, all):
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this be raycluster? Its a little confusing when sometimes we want to use raycluster and othertimes we use rayclusters

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'll create an alias so the user can do either

Comment on lines +561 to +575
def _get_all_ray_clusters() -> List[RayCluster]:
list_of_clusters = []
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
rcs = api_instance.list_cluster_custom_object(
group="ray.io",
version="v1alpha1",
plural="rayclusters",
)
except Exception as e:
return _kube_api_error_handling(e)
for rc in rcs["items"]:
list_of_clusters.append(_map_to_ray_cluster(rc))
return list_of_clusters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add this functionality into the original _get_ray_clusters() function?

the idea is that by default, _get_ray_clusters() get from all namespaces. If you provide a namespace, then it will select only from that namespace.

@Maxusmusti WDYT?

def raycluster(name, namespace):
"""
Delete a specified RayCluster from the Kubernetes cluster
"""
cluster = get_cluster(name, namespace)
try:
cluster = get_cluster(name, namespace)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its a little awkward that delete command returns a "Written to: xyz.yaml` message. Anyway we can avoid this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carsonmh carsonmh mentioned this pull request Aug 3, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI List and view Ray Clusters
4 participants