Skip to content

Commit

Permalink
Merge remote-tracking branch 'openshift/openshift-4.12' into rebase-e…
Browse files Browse the repository at this point in the history
…tcd-3.5.12-openshift-4.12
  • Loading branch information
Elbehery committed Jan 31, 2024
2 parents b200a8d + bb43fb5 commit 6e72dc1
Show file tree
Hide file tree
Showing 28 changed files with 992 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .ci-operator.yaml
@@ -0,0 +1,4 @@
build_root_image:
name: builder
namespace: ocp
tag: rhel-8-etcd-golang-1.16
21 changes: 21 additions & 0 deletions .github/workflows/go-version.yaml
@@ -0,0 +1,21 @@
name: Go version setup

on:
workflow_call:
outputs:
goversion:
value: ${{ jobs.version.outputs.goversion }}

jobs:
version:
name: Set Go version variable for all the workflows
runs-on: ubuntu-latest
outputs:
goversion: ${{ steps.goversion.outputs.goversion }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- id: goversion
run: |
GO_VERSION=$(cat .go-version)
echo "Go Version: $GO_VERSION"
echo "goversion=$GO_VERSION" >> $GITHUB_OUTPUT
13 changes: 13 additions & 0 deletions OWNERS
@@ -0,0 +1,13 @@
approvers:
- deads2k
- hasbro17
- dusk125
- Elbehery
- tjungblu
reviewers:
- deads2k
- dusk125
- hasbro17
- Elbehery
- tjungblu
component: "Etcd"
87 changes: 87 additions & 0 deletions REBASE.openshift.md
@@ -0,0 +1,87 @@
# Maintaining openshift/etcd

OpenShift is based on upstream etcd. With every release of etcd that is
intended to be shipped as OCP, it is necessary to incorporate the upstream changes
while ensuring that our downstream customizations are maintained.

## Maintaining this document

An openshift/etcd rebase is a complex process involving many manual and
potentially error-prone steps. If, while performing a rebase, you find areas where
the documented procedure is unclear or missing detail, please update this document
and include the change in the rebase PR. This will ensure that the instructions are
as comprehensive and accurate as possible for the person performing the next
rebase.

## Getting started

Before incorporating upstream changes you may want to:

- Read this document
- Find the best tool for resolving merge conflicts
- Use diff3 conflict resolution strategy
(https://blog.nilbus.com/take-the-pain-out-of-git-conflict-resolution-use-diff3/)
- Teach Git to remember how you’ve resolved a conflict so that the next time it can
resolve it automatically (https://git-scm.com/book/en/v2/Git-Tools-Rerere)

## Preparing the local repo clone

Clone from a personal fork of etcd via a pushable (ssh) url:

```
git clone git@github.com:<user id>/etcd
```

## Updating with `rebase.sh`

To finally rebase, a script that will merge and rebase along the happy path without automatic conflict resolution and at the end will create a PR for you.

Here are the steps:
1. Create a new OCPBUGS JIRA ticket with the respective OpenShift version to rebase. Please include the change logs in the ticket description. You can clone a previous rebase we did in [OCPBUGS-947](https://issues.redhat.com/browse/OCPBUGS-947) and adjust.
2. It's best to start off with a fresh fork of [openshift/etcd](https://github.com/openshift/etcd/). Stay on the master branch.
3. This script requires `jq`, `git`, `podman` and `bash`. `gh` is optional.
4. In the root dir of that fork run:
```
openshift-hack/rebase.sh --etcd-tag=v3.5.4 --openshift-release=openshift-4.12 --jira-id=666
```

where `etcd-tag` is the [etcd-io/etcd](https://github.com/etcd-io/etcd/) release tag, the `openshift-release`
is the OpenShift release branch in [openshift/etcd](https://github.com/openshift/etcd/) and the `jira-id` is the
number of the OCPBUGS ticket created in step (1).

5. In case of conflicts, it will ask you to step into another shell to resolve those. The script will continue by committing the resolution with `UPSTREAM: <drop>`.
6. At the end, there will be a "rebase-$VERSION" branch pushed to your fork.
7. If you have `gh` installed and are logged in, it will attempt to create a PR for you by opening a web browser.

## Building and testing

- Build the code with `make`
- Test the code with `make test`

## Payload testing

After all the above are green and your PR pre-submits are too, you can start with payload testing. This is to ensure the nightly jobs won't break on etcd after the merge, they also test all of OpenShift (including upgrades) well enough.

You should run those two:

> /payload 4.x nightly informing
>
> /payload 4.x nightly blocking
Replace 4.x with the respective OpenShift release you're merging against.

It pays off to inspect some Prometheus metrics (CPU, memory, disk usage) with an upgrade job through PromeCIus. This is to ensure we don't increase resource usage inadvertently.

## Testing with ClusterBot

Sometimes it's easier to debug an issue using cluster bot. Here you can simply run the given OpenShift release using your rebase PR:

> launch openshift/etcd#155
This is particularly helpful when you want to test specific providers, for example Bare Metal or VSphere, or just other variants like SNO.

## Performance Testing

We currently do not do performance testing after an etcd rebase in OpenShift, however the upstream community and [SIG Scalability in k/k does](https://github.com/etcd-io/etcd/issues/14138#issuecomment-1247665949).

The OpenShift scalability team also regularly runs performance tests with upcoming 4.y.0 releases.
21 changes: 0 additions & 21 deletions ROADMAP.md

This file was deleted.

13 changes: 13 additions & 0 deletions build.sh
Expand Up @@ -2,6 +2,8 @@

set -euo pipefail

GO_BUILD_FLAGS="${GO_BUILD_FLAGS} ${GOFLAGS:+-$GOFLAGS}"

source ./scripts/test_lib.sh

GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
Expand Down Expand Up @@ -91,6 +93,17 @@ etcd_build() {
"-ldflags=${GO_LDFLAGS[*]}" \
-o="../${out}/etcdctl" . || return 2
) || return 2

run rm -f "${out}/discover-etcd-initial-cluster"
# shellcheck disable=SC2086
(
cd ./openshift-tools/discover-etcd-initial-cluster
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \
-installsuffix=cgo \
"-ldflags=${GO_LDFLAGS[*]}" \
-o="../../${out}/discover-etcd-initial-cluster" . || return 2
) || return 2

# Verify whether symbol we overriden exists
# For cross-compiling we cannot run: ${out}/etcd --version | grep -q "Git SHA: ${GIT_SHA}"

Expand Down
24 changes: 24 additions & 0 deletions client/v3/patch_cluster.go
@@ -0,0 +1,24 @@
package clientv3

import (
"context"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
)

// NonLinearizeableMemberLister is used by the discover-etcd-initial-cluster command to get a list of members to ensure that *this*
// member has been added to the list. This is needed on restart scenarios when there isn't quorum. We need the first
// two etcd servers to start without quorum having been established by finding themselves in the member list and moving
// past the gate.
type NonLinearizeableMemberLister interface {
// NonLinearizeableMemberList is like MemberList only without linearization.
NonLinearizeableMemberList(ctx context.Context) (*MemberListResponse, error)
}

func (c *cluster) NonLinearizeableMemberList(ctx context.Context) (*MemberListResponse, error) {
// it is safe to retry on list.
resp, err := c.remote.MemberList(ctx, &pb.MemberListRequest{}, c.callOpts...)
if err == nil {
return (*MemberListResponse)(resp), nil
}
return nil, toErr(ctx, err)
}
7 changes: 2 additions & 5 deletions etcdctl/ctlv3/command/check.go
Expand Up @@ -107,13 +107,10 @@ var checkDatascaleCfgMap = map[string]checkDatascaleCfg{
// NewCheckCommand returns the cobra command for "check".
func NewCheckCommand() *cobra.Command {
cc := &cobra.Command{
Use: "check <subcommand>",
Short: "commands for checking properties of the etcd cluster",
Use: "check <subcommand> is no longer supported in OpenShift. Performance analysis should be performed using metrics, please see the etcd dashboards",
Short: "command no longer supported in OpenShift",
}

cc.AddCommand(NewCheckPerfCommand())
cc.AddCommand(NewCheckDatascaleCommand())

return cc
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -19,6 +19,7 @@ require (
github.com/bgentry/speakeasy v0.1.0
github.com/dustin/go-humanize v1.0.0
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
go.etcd.io/bbolt v1.3.8
go.etcd.io/etcd/api/v3 v3.5.12
go.etcd.io/etcd/client/pkg/v3 v3.5.12
Expand Down Expand Up @@ -69,7 +70,6 @@ require (
github.com/prometheus/procfs v0.6.0 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
Expand Down

0 comments on commit 6e72dc1

Please sign in to comment.