Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

sg cloud eph: simplify status#64209

Merged
filiphaftek merged 8 commits into
mainfrom
fh/sg_cloud_eph_simplify
Aug 1, 2024
Merged

sg cloud eph: simplify status#64209
filiphaftek merged 8 commits into
mainfrom
fh/sg_cloud_eph_simplify

Conversation

@filiphaftek

@filiphaftek filiphaftek commented Aug 1, 2024

Copy link
Copy Markdown
Contributor
  1. Make sg cloud eph instance status Reason simple string, as CloudAPI will take over and return Reason with job URL - no need to parse Reason anymore.
go run ./dev/sg cloud eph status --name ff-eph56
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
✅ Ephemeral instance "ff-eph56" status retrieved
Ephemeral instance details:
Name                                     Expires In           Instance status                          Details
ff-eph56                                 4h37m4.79031s        unspecified                              creation task is already running: https://console.cloud.google.com/workflows/workflow/us-central1/create-instance-c31bd1a4ea84/executions?project=michael-test-03
  1. Allow re-run create if CloudAPI returns status with Reason - it means instance is not fully created yet, so user might re-try create - CloudAPI will ensure more than one create is not running at the same time.

  2. Updated printers with GOTO action for each instance details:

go run ./dev/sg cloud eph list --all
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
☁️ Fetched 10 instances
Name                                     Expires In           Instance status                          Details
andre-eph-1                              30h10m42.989163s     unspecified                              invoke: sg cloud eph status --name andre-eph-1
ff-eph56                                 4h34m43.989154s      unspecified                              invoke: sg cloud eph status --name ff-eph56

Test plan

Unit tests simplified.
E2e against old and new CloudAPI.

Comment thread dev/sg/internal/cloud/instance.go Outdated
var err error
status.Reason, err = newStatusReason(src.GetReason())
status.Reason = src.GetReason()
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can remove this too

@burmudar

burmudar commented Aug 1, 2024

Copy link
Copy Markdown
Contributor

@filiphaftek can you also run it with --raw?

@filiphaftek

Copy link
Copy Markdown
Contributor Author

@filiphaftek can you also run it with --raw?

Yes, tested already:

go run ./dev/sg cloud eph status --name ff-eph56 --raw
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
✅ Ephemeral instance "ff-eph56" status retrieved
Ephemeral instance details:
ID           : src-2edcd1adad848160cacb
Name         : ff-eph56
InstanceType : ephemeral
Environment  : dev
Version      : 5.5.1337
URL          : https://ff-eph56.sgdev.dev
AdminEmail   : filip.haftek@sourcegraph.com
CreatedAt    : n/a
DeletetAt    : n/a
ExpiresAt    : 2024-08-01T16:00:21Z
Project      : src-7b4a1801a8209eeca568
Region       : us-central1
Status       : unspecified
Details      : creation task is already running: https://console.cloud.google.com/workflows/workflow/us-central1/create-instance-87342535848a/executions?project=michael-test-03

@burmudar

burmudar commented Aug 1, 2024

Copy link
Copy Markdown
Contributor

@filiphaftek can you also run it with --raw?

Yes, tested already:

go run ./dev/sg cloud eph status --name ff-eph56 --raw
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
✅ Ephemeral instance "ff-eph56" status retrieved
Ephemeral instance details:
ID           : src-2edcd1adad848160cacb
Name         : ff-eph56
InstanceType : ephemeral
Environment  : dev
Version      : 5.5.1337
URL          : https://ff-eph56.sgdev.dev
AdminEmail   : filip.haftek@sourcegraph.com
CreatedAt    : n/a
DeletetAt    : n/a
ExpiresAt    : 2024-08-01T16:00:21Z
Project      : src-7b4a1801a8209eeca568
Region       : us-central1
Status       : unspecified
Details      : creation task is already running: https://console.cloud.google.com/workflows/workflow/us-central1/create-instance-87342535848a/executions?project=michael-test-03

Should cloud api status not be progressing or creating instead of unspecified?

@filiphaftek

Copy link
Copy Markdown
Contributor Author

@filiphaftek can you also run it with --raw?

Yes, tested already:

go run ./dev/sg cloud eph status --name ff-eph56 --raw
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
✅ Ephemeral instance "ff-eph56" status retrieved
Ephemeral instance details:
ID           : src-2edcd1adad848160cacb
Name         : ff-eph56
InstanceType : ephemeral
Environment  : dev
Version      : 5.5.1337
URL          : https://ff-eph56.sgdev.dev
AdminEmail   : filip.haftek@sourcegraph.com
CreatedAt    : n/a
DeletetAt    : n/a
ExpiresAt    : 2024-08-01T16:00:21Z
Project      : src-7b4a1801a8209eeca568
Region       : us-central1
Status       : unspecified
Details      : creation task is already running: https://console.cloud.google.com/workflows/workflow/us-central1/create-instance-87342535848a/executions?project=michael-test-03

Should cloud api status not be progressing or creating instead of unspecified?

I though unspecified can be easier for us to differentiate vs instance already created, but progressing upgrade etc here - but as we do not use unspecified anyway, I will switch back to progressing 👍

Comment thread dev/sg/internal/cloud/printers.go Outdated

@burmudar burmudar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small comments! thanks for the fix + improvements!

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
@filiphaftek filiphaftek merged commit 66be2dd into main Aug 1, 2024
@filiphaftek filiphaftek deleted the fh/sg_cloud_eph_simplify branch August 1, 2024 12:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants