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

Add implementation of Server-Sent Events (SSE) #3700

Merged
merged 7 commits into from
Jul 10, 2023
Merged

Conversation

evidolob
Copy link
Contributor

@evidolob evidolob commented Jun 7, 2023

Fixes: Issue #N

Relates to: Issue #N, PR #N, ...

Solution/Idea

This PR provides implementation of server sent events. This implementation is used to replace existing WebSocket implementation. Currently only status event channel is used for fetching crc status -w data.

Also PR provide logs event channel on which daemon publish all logs collected by logrus logger, it will be used in future work for moving all crc command execution to daemon, as will allow to keep current cli behaviour/output.

PR uses r3labs/sse/v2 as SSE library

Test

You could use curl to view events:

curl -GET -i --unix-socket <path to crc socket>/crc-http.sock "http://localhost/events?stream=logs" to view logs events.
curl -GET -i --unix-socket <path to crc socket>/crc-http.sock "http://localhost/events?stream=status" to view data which used for crc status -w.

crc status -w should work exactly as before.

@gbraad gbraad changed the title Add implementation of server send event Add implementation of Server-Sent Events (SSE) Jun 7, 2023
go.mod Outdated Show resolved Hide resolved
@gbraad
Copy link
Contributor

gbraad commented Jun 7, 2023

feels almost like a drop-in replacement.

@gbraad
Copy link
Contributor

gbraad commented Jun 8, 2023

Fixes: Issue #N

Can you reference the issue this is related to ?

@gbraad
Copy link
Contributor

gbraad commented Jun 8, 2023

curl -GET -i --unix-socket <path to crc socket>/crc-http.sock "http://localhost/events?stream=logs" to view logs events.

This also works on Windows?

@gbraad
Copy link
Contributor

gbraad commented Jun 8, 2023

crc status -w should work exactly as before.

We need to verify if the following scenario worked the same before:

Only CPU and memory are updated:

PS> .\crc.exe stop -f
PS> .\crc.exe status -w
CRC VM:          Stopped
MicroShift:      Stopped (v4.13.0)
Disk Usage:      0B of 0B (Inside the CRC VM)
Cache Usage:     20.72GB
Cache Directory: C:\Users\gbraad\.crc\cache
... in the mean time in another shell start `.\crc.exe start`
... the status like VM and preset does not change; remain 'Stopped'
... wait a little bit: "INFO Starting Microshift service... [takes around 1min]" ... kill watch process 
PS> .\crc.exe status -w
CRC VM:          Running
MicroShift:      Running (v4.13.0)
Disk Usage:      5.462GB of 16.1GB (Inside the CRC VM)
Cache Usage:     20.72GB
Cache Directory: C:\Users\gbraad\.crc\cache
... the status correctly shows the VM is running.

See #3744

Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
Signed-off-by: Yevhen Vydolob <[email protected]>
@openshift-ci
Copy link

openshift-ci bot commented Jul 4, 2023

@evidolob: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 93e9f7f link true /test e2e-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@gbraad gbraad left a comment

Choose a reason for hiding this comment

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

how to implement this for the extension?
and followup with #3744 to include state

@openshift-ci
Copy link

openshift-ci bot commented Jul 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gbraad

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 label Jul 5, 2023
@anjannath anjannath merged commit 7cbf68b into crc-org:main Jul 10, 2023
13 checks passed
@evidolob evidolob deleted the sse branch July 10, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants