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

Make mc ping useful for startup checks #4584

Merged
merged 1 commit into from May 30, 2023

Conversation

klauspost
Copy link
Contributor

@klauspost klauspost commented May 29, 2023

Description

Add --exit parameter that will exit after first successful ping.

This makes mc ping much more useful to detect when a server has started.

How to test this PR?

Play around with your local server.

λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=1.37ms     max=1.37ms     average=1.37ms     errors=0   roundtrip=1.37ms

λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=1   roundtrip=2.05s
  2: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=2   roundtrip=2.05s
  3: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=3   roundtrip=2.03s
  4: http://127.0.0.1:9001:9001   min=1.02s      max=1.02s      average=1.02s      errors=0   roundtrip=1.02s

λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=1   roundtrip=2.03s
  2: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=2   roundtrip=2.05s
  3: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=3   roundtrip=2.03s
  4: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=4   roundtrip=2.04s
  5: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=5   roundtrip=2.04s
  6: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=6   roundtrip=2.04s
  7: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=7   roundtrip=2.04s
  8: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=8   roundtrip=2.02s
  9: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=9   roundtrip=2.05s
 10: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=10  roundtrip=2.04s

λ _

Types of changes

  • New feature (non-breaking change which adds functionality)

Add `--exit` parameter that will exit after first successful ping.

This makes `mc ping` much more useful to detect when a server has started.

```
λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=1.37ms     max=1.37ms     average=1.37ms     errors=0   roundtrip=1.37ms

λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=1   roundtrip=2.05s
  2: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=2   roundtrip=2.05s
  3: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=3   roundtrip=2.03s
  4: http://127.0.0.1:9001:9001   min=1.02s      max=1.02s      average=1.02s      errors=0   roundtrip=1.02s

λ go build&&mc ping -x -e 10 myminio
  1: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=1   roundtrip=2.03s
  2: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=2   roundtrip=2.05s
  3: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=3   roundtrip=2.03s
  4: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=4   roundtrip=2.04s
  5: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=5   roundtrip=2.04s
  6: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=6   roundtrip=2.04s
  7: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=7   roundtrip=2.04s
  8: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=8   roundtrip=2.02s
  9: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=9   roundtrip=2.05s
 10: http://127.0.0.1:9001:9001   min=0.00ms     max=0.00ms     average=0.00ms     errors=10  roundtrip=2.04s

λ _
```
Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

In fact, I believe we have 'mc ready' for that

@klauspost
Copy link
Contributor Author

@vadmeste It can't really be used to wait for the cluster to be up (without some scripting magic)

λ mc ready myminio
mc: <ERROR> Couldn't get the health status for `myminio`. Get "http://127.0.0.1:9001/minio/health/cluster": dial tcp 127.0.0.1:9001: connectex: No connection could be made because the target machine actively refused it.
λ 

@harshavardhana
Copy link
Member

@vadmeste It can't really be used to wait for the cluster to be up (without some scripting magic)

λ mc ready myminio
mc: <ERROR> Couldn't get the health status for `myminio`. Get "http://127.0.0.1:9001/minio/health/cluster": dial tcp 127.0.0.1:9001: connectex: No connection could be made because the target machine actively refused it.
λ 

This is actually a bug I think in the implementation, mc ping --exit-on-success is a good idea as well.

@klauspost
Copy link
Contributor Author

mc ping -x -e 60 myminio&&mc ready myminio seems like the reasonable thing to wait for startup.

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM

@harshavardhana harshavardhana merged commit c6d4b63 into minio:master May 30, 2023
5 checks passed
@klauspost klauspost deleted the make-mc-ping-useful branch May 30, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants