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

Limit --since and --after options to keys and VMs #684

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

kishen-v
Copy link
Contributor

Background:
The --since and --before flags were included at the purge command level, while certain child commands do not support the same.
Changes are made to limit the options to the child commands to have a more concise set of options for the respective commands.

For networks:

Using the options that do not exist anymore
Kishens-MacBook-Pro-2➜  bin : port-deletion : ᐅ  ./pvsadm purge networks --workspace-id <> --ignore-errors --no-prompt --ports --instances --since 1h --before 1h

E1015 08:40:24.671575   80887 main.go:26] unknown flag: --since




Without --before and --since flags
Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ :✭ ᐅ  ./pvsadm purge networks --workspace-id <> --ports --instances
I1015 10:04:19.482878   97874 networks.go:54] Purge networks for the workspace ID: <>
+--------------+-----+-------------+-------+------+-------------------------------------+--------------------------------------+----------+--------+
| ACCESSCONFIG | CRN | DHCPMANAGED | JUMBO | MTU  |                NAME                 |              NETWORKID               |   TYPE   | VLANID |
+--------------+-----+-------------+-------+------+-------------------------------------+--------------------------------------+----------+--------+
|              |     | false       | true  | 9000 | public-192_168_234_176-29-VLAN_2150 | <>| pub-vlan |   2150 |
+--------------+-----+-------------+-------+------+-------------------------------------+--------------------------------------+----------+--------+
┃ Deleting all the above networks and the action is irreversible. Do you really want to continue?
┃
┃                                           Yes     No




For VMs:

Setting both flags that are meant to be mutually exclusive:

Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ :✹✭ ᐅ  ./pvsadm purge vms --workspace-id <> --since 1h --before 1h
Error: if any flags in the group [since before] are set none of the others can be; [before since] were all set

E1015 09:24:17.813825   82821 main.go:26] if any flags in the group [since before] are set none of the others can be; [before since] were all set


Using --before flag
Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ : ᐅ  ./pvsadm purge vms --workspace-id <> --before 1h
+-----------------------------+--------------+--------------------------------------+------+-----+-----------------+--------------------------+
|            NAME             | IP ADDRESSES |                IMAGE                 | CPUS | RAM |     STATUS      |      CREATION DATE       |
+-----------------------------+--------------+--------------------------------------+------+-----+-----------------+--------------------------+
| <>  | External:    | <> |  0.5 |  32 | Status: ACTIVE  | 2024-10-14T09:11:36.000Z |
|                             | Private:     |                                      |      |     | Health: WARNING |                          |
| <>  | External:    | <> |  0.5 |  32 | Status: ACTIVE  | 2024-10-14T09:11:21.000Z |
|                             | Private:     |                                      |      |     | Health: WARNING |                          |
+-----------------------------+--------------+--------------------------------------+------+-----+-----------------+--------------------------+
┃ Deleting all the above instances and the action is irreversible. Do you really want to continue?
┃
┃                                            Yes     No

Using --since flag:

Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ :✭ ᐅ  ./pvsadm purge vms --workspace-id <> --since 1h
+------------+--------------------------+--------------------------------------+------+-----+----------------+--------------------------+
|    NAME    |       IP ADDRESSES       |                IMAGE                 | CPUS | RAM |     STATUS     |      CREATION DATE       |
+------------+--------------------------+--------------------------------------+------+-----+----------------+--------------------------+
| <> | External: 52.118.31.214  | <> | 0.25 |   4 | Status: ACTIVE | 2024-10-15T04:06:38.000Z |
|            | Private: 192.168.234.182 |                                      |      |     | Health: OK     |                          |
+------------+--------------------------+--------------------------------------+------+-----+----------------+--------------------------+
┃ Deleting all the above instances and the action is irreversible. Do you really want to continue?
┃
┃                                            Yes     No


For Keys:


Using the --before flag:
Kishens-MacBook-Pro-2➜  bin : port-deletion  ᐅ  ./pvsadm purge keys --workspace-id <> --regexp kishen --before 1h
I1015 09:34:09.154279   86241 keys.go:49] Purge SSH keys for the workspace ID: <>
I1015 09:34:16.285375   86241 keys.go:68] keys matched are [kishen-mbp-rsa]
┃ Deleting all the above keys and the action is irreversible. Do you really want to continue?
┃
┃                                         Yes     No

Using the --since flag:
Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ :✭ ᐅ  ./pvsadm purge keys --workspace-id <> --regexp kishen --since 100000h
I1015 10:00:35.210025   96640 keys.go:49] Purge SSH keys for the workspace ID: <>
I1015 10:00:42.552181   96640 keys.go:68] keys matched are [kishen-mbp-rsa]
┃ Deleting all the above keys and the action is irreversible. Do you really want to continue?
┃
┃                                         Yes     No

Using --before and --since flag
Kishens-MacBook-Pro-2➜  bin : port-deletion ✘ :✭ ᐅ  ./pvsadm purge keys --workspace-id <> --regexp kishen --since 100000h --before 1h
Error: if any flags in the group [since before] are set none of the others can be; [before since] were all set

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 15, 2024
Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

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

/lgtm

@ppc64le-cloud-bot ppc64le-cloud-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2024
@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishen-v, mkumatag

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

@ppc64le-cloud-bot ppc64le-cloud-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot merged commit a5d778d into ppc64le-cloud:main Oct 15, 2024
5 checks passed
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants