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

Examples: Add lib functions to wait for shard states #12239

Merged
merged 11 commits into from
Feb 8, 2023

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Feb 5, 2023

Description

Before modifying a shard we need to wait for the tablets to be up, a primary to be elected, and that primary to become healthy/serving. We were skipping this last check, but in practice it was virtually never an issue because the transition to primary after election (by vtorc now) was so fast. After #11520, however, once the primary has been elected it then needs to initialize its sidecar database. This additional time, while small, now makes the local examples unreliable because we do not wait for that to happen before we e.g. execute the ApplySchema vtctl client command. We also did not check for any errors in vtctl client commands like that, so you would not know anything was wrong until trying to execute a later step or command and you would see that e.g. the tables did not exist. In the process, I also made the following notable changes:

Note I took this opportunity to remove an annoying and unnecessary step in the region_sharding examples of having to specify a full path to countries.json — which meant that the examples did not work w/o taking that manual step — when a relative path works and we're using relative paths everywhere else in the examples.

Note I realized that there was a lot of duplicated files/code between the local and region_examples, so I took the opportunity to refactor these so that they share the same files between them (this will require a docs PR now too).

Related Issue(s)

Checklist

@vitess-bot vitess-bot bot added NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels Feb 5, 2023
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 5, 2023

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.
  • If a test is added or modified, there should be a documentation on top of the test to explain what the expected behavior is what the test does.

If a new flag is being introduced:

  • Is it really necessary to add this flag?
  • Flag names should be clear and intuitive (as far as possible)
  • Help text should be descriptive.
  • Flag names should use dashes (-) as word separators rather than underscores (_).

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow should be required, the maintainer team should be notified.

Bug fixes

  • There should be at least one unit or end-to-end test.
  • The Pull Request description should include a link to an issue that describes the bug.

Non-trivial changes

  • There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • Should be documented, either by modifying the existing documentation or creating new documentation.
  • New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • vtctl command output order should be stable and awk-able.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from VTop, if used there.

@mattlord mattlord force-pushed the fix_local_examples branch 2 times, most recently from 57dfbc7 to 3f4104e Compare February 5, 2023 18:23
@mattlord mattlord added Type: Bug Component: Examples Backport to: release-16.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels Feb 5, 2023
@mattlord mattlord force-pushed the fix_local_examples branch 5 times, most recently from 245ce0b to 03fd3c5 Compare February 5, 2023 18:55
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord force-pushed the fix_local_examples branch 4 times, most recently from 0c1955e to 2b95544 Compare February 5, 2023 20:53
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord marked this pull request as ready for review February 5, 2023 21:23
examples/region_sharding/lib/utils.sh Outdated Show resolved Hide resolved
examples/local/lib/utils.sh Outdated Show resolved Hide resolved
Copy link
Member

@GuptaManan100 GuptaManan100 left a comment

Choose a reason for hiding this comment

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

looks good to me apart from the outstanding comments.

Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

Great changes, thanks!

examples/region_sharding/lib/utils.sh Outdated Show resolved Hide resolved
examples/local/lib/utils.sh Outdated Show resolved Hide resolved
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Also address shellcheck warnings.

Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord added a commit to vitessio/website that referenced this pull request Feb 6, 2023
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Copy link
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

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

This is looking good to me! Thank you for doing this @mattlord, this is awesome work 🙌🏻

examples/common/scripts/k3s-down.sh Show resolved Hide resolved
examples/region_sharding/lib/utils.sh Outdated Show resolved Hide resolved
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord merged commit 39e167a into vitessio:main Feb 8, 2023
@mattlord mattlord deleted the fix_local_examples branch February 8, 2023 15:01
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 8, 2023

I was unable to backport this Pull Request to the following branches: release-16.0.

mattlord added a commit to planetscale/vitess that referenced this pull request Feb 8, 2023
* Add lib functions to wait for shard states

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Fixup region example too

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Address minor review comments

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Remove extraneous line change

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Refactor to remove duplicated files/code

Also address shellcheck warnings.

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Fix tests that run in CI

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Use more robust location detection

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Fix backup tests

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Exit on shard healthy failure

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Remove unused dups and adjust client_test and Dockerfiles

Signed-off-by: Matt Lord <mattalord@gmail.com>

---------

Signed-off-by: Matt Lord <mattalord@gmail.com>
frouioui pushed a commit that referenced this pull request Feb 16, 2023
* Add lib functions to wait for shard states



* Fixup region example too



* Address minor review comments



* Remove extraneous line change



* Refactor to remove duplicated files/code

Also address shellcheck warnings.



* Fix tests that run in CI



* Use more robust location detection



* Fix backup tests



* Exit on shard healthy failure



* Remove unused dups and adjust client_test and Dockerfiles



---------

Signed-off-by: Matt Lord <mattalord@gmail.com>
@hmaurer hmaurer mentioned this pull request Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants