Skip to content

Commit

Permalink
Merge pull request ceph#114 from openshift-cherrypick-robot/cherry-pi…
Browse files Browse the repository at this point in the history
…ck-113-to-release-4.12

[release-4.12] Sync devel branch with upstream
  • Loading branch information
openshift-merge-robot authored Jul 27, 2022
2 parents 52fc394 + e6fd843 commit 1c3b0b0
Show file tree
Hide file tree
Showing 24 changed files with 283 additions and 240 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/stretchr/testify v1.8.0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
golang.org/x/sys v0.0.0-20220209214540-3681064d5158
google.golang.org/grpc v1.47.0
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.0
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1674,8 +1674,8 @@ google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=
google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
Expand Down
2 changes: 0 additions & 2 deletions internal/rbd/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ var (
ErrMissingImageNameInVolID = errors.New("rbd image name information can not be empty in volID")
// ErrDecodeClusterIDFromMonsInVolID is returned when mons hash decoding on migration volID.
ErrDecodeClusterIDFromMonsInVolID = errors.New("failed to get clusterID from monitors hash in volID")
// ErrUnHealthyMirroredImage is returned when mirrored image is not healthy.
ErrUnHealthyMirroredImage = errors.New("mirrored image is not healthy")
)
35 changes: 0 additions & 35 deletions internal/rbd/replicationcontrollerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,6 @@ func (rs *ReplicationServer) PromoteVolume(ctx context.Context,
}
}

mirrorStatus, err := rbdVol.getImageMirroringStatus()
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

err = checkHealthyPrimary(ctx, rbdVol, mirrorStatus)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

var mode librbd.ImageMirrorMode
mode, err = getMirroringMode(ctx, req.GetParameters())
if err != nil {
Expand Down Expand Up @@ -620,31 +610,6 @@ func (rs *ReplicationServer) PromoteVolume(ctx context.Context,
return &replication.PromoteVolumeResponse{}, nil
}

// checkHealthyPrimary checks if the image is a healhty primary or not.
// healthy primary image will be in up+stopped state, for states other
// than this it returns an error message.
func checkHealthyPrimary(ctx context.Context, rbdVol *rbdVolume, mirrorStatus *librbd.GlobalMirrorImageStatus) error {
localStatus, err := mirrorStatus.LocalStatus()
if err != nil {
// LocalStatus can fail if the local site status is not found in
// mirroring status. Log complete sites status to debug why getting
// local status failed
log.ErrorLog(ctx, "mirroring status is %+v", mirrorStatus)

return fmt.Errorf("failed to get local status: %w", err)
}

if !localStatus.Up || localStatus.State != librbd.MirrorImageStatusStateStopped {
return fmt.Errorf("%s %w. State is up=%t, state=%q",
rbdVol,
ErrUnHealthyMirroredImage,
localStatus.Up,
localStatus.State)
}

return nil
}

// DemoteVolume extracts the RBD volume information from the
// volumeID, If the image is present, mirroring is enabled and the
// image is in promoted state it will demote the volume as secondary.
Expand Down
72 changes: 0 additions & 72 deletions internal/rbd/replicationcontrollerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,75 +279,3 @@ func TestCheckVolumeResyncStatus(t *testing.T) {
})
}
}

func Test_checkHealthyPrimary(t *testing.T) {
t.Parallel()
rbdVol := &rbdVolume{
rbdImage: rbdImage{
RbdImageName: "test",
Pool: "test-pool",
},
}
tests := []struct {
name string
ctx context.Context
rbdVol *rbdVolume
mirrorStatus *librbd.GlobalMirrorImageStatus
wantErr bool
}{
{
name: "when image is in up+stopped state",
ctx: context.TODO(),
rbdVol: rbdVol,
mirrorStatus: &librbd.GlobalMirrorImageStatus{
SiteStatuses: []librbd.SiteMirrorImageStatus{
{
MirrorUUID: "",
State: librbd.MirrorImageStatusStateStopped,
Up: true,
},
},
},
wantErr: false,
},
{
name: "when image is in up+error state",
ctx: context.TODO(),
rbdVol: rbdVol,
mirrorStatus: &librbd.GlobalMirrorImageStatus{
SiteStatuses: []librbd.SiteMirrorImageStatus{
{
MirrorUUID: "",
State: librbd.MirrorImageStatusStateError,
Up: false,
},
},
},
wantErr: true,
},
{
name: "when image is in up+replaying state",
ctx: context.TODO(),
rbdVol: rbdVol,
mirrorStatus: &librbd.GlobalMirrorImageStatus{
SiteStatuses: []librbd.SiteMirrorImageStatus{
{
MirrorUUID: "",
State: librbd.MirrorImageStatusStateReplaying,
Up: true,
},
},
},
wantErr: true,
},
}
for _, tt := range tests {
ts := tt
t.Run(ts.name, func(t *testing.T) {
t.Parallel()
if err := checkHealthyPrimary(ts.ctx, ts.rbdVol, ts.mirrorStatus); (err != nil) != ts.wantErr {
t.Errorf("checkHealthyPrimary() error = %v, wantErr %v", err, ts.wantErr)
}
})
}
}
19 changes: 19 additions & 0 deletions scripts/rook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function deploy_rook() {
check_ceph_cluster_health
fi

# Make sure Ceph Mgr is running
check_ceph_mgr

# Check if CephFileSystem is empty
if ! kubectl_retry -n rook-ceph get cephfilesystems -oyaml | grep 'items: \[\]' &>/dev/null; then
check_mds_stat
Expand Down Expand Up @@ -166,6 +169,22 @@ function check_ceph_cluster_health() {
echo ""
}

function check_ceph_mgr() {
for ((retry = 0; retry <= ROOK_DEPLOY_TIMEOUT; retry = retry + 5)); do
echo "Waiting for Ceph Mgr... ${retry}s" && sleep 5

MGR_POD=$(kubectl_retry -n rook-ceph get pods -l app=rook-ceph-mgr -o jsonpath='{.items[0].metadata.name}')
MGR_POD_STATUS=$(kubectl_retry -n rook-ceph get pod "$MGR_POD" -ojsonpath='{.status.phase}')
[[ "$MGR_POD_STATUS" = "Running" ]] && break
done

if [ "$retry" -gt "$ROOK_DEPLOY_TIMEOUT" ]; then
echo "[Timeout] Ceph Mgr is not running (timeout)"
return 1
fi
echo ""
}

function check_mds_stat() {
for ((retry = 0; retry <= ROOK_DEPLOY_TIMEOUT; retry = retry + 5)); do
FS_NAME=$(kubectl_retry -n rook-ceph get cephfilesystems.ceph.rook.io -ojsonpath='{.items[0].metadata.name}')
Expand Down
4 changes: 4 additions & 0 deletions vendor/google.golang.org/grpc/balancer/base/balancer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/google.golang.org/grpc/clientconn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion vendor/google.golang.org/grpc/dialoptions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/google.golang.org/grpc/internal/binarylog/binarylog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/google.golang.org/grpc/internal/envconfig/xds.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions vendor/google.golang.org/grpc/internal/internal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1c3b0b0

Please sign in to comment.