Skip to content

Commit

Permalink
This is an automated cherry-pick of #10422
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
CharlesCheung96 authored and ti-chi-bot committed Jan 11, 2024
1 parent 600ad4a commit 4ffd512
Show file tree
Hide file tree
Showing 13 changed files with 554 additions and 121 deletions.
5 changes: 5 additions & 0 deletions cdc/api/v2/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,13 @@ func (h *OpenAPIV2) updateChangefeed(c *gin.Context) {
zap.String("changefeedInfo", newCfInfo.String()),
zap.Any("upstreamInfo", newUpInfo))

<<<<<<< HEAD
err = h.capture.GetEtcdClient().
UpdateChangefeedAndUpstream(ctx, newUpInfo, newCfInfo, changefeedID)
=======
err = owner.
UpdateChangefeedAndUpstream(ctx, newUpInfo, newCfInfo)
>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))
if err != nil {
_ = c.Error(errors.Trace(err))
return
Expand Down
15 changes: 15 additions & 0 deletions cdc/api/v2/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,13 @@ func TestUpdateChangefeed(t *testing.T) {
verifyUpdateChangefeedConfig(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&model.ChangeFeedInfo{}, &model.UpstreamInfo{}, nil).
Times(1)
<<<<<<< HEAD
etcdClient.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
=======
mockOwner.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any()).
>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))
Return(cerrors.ErrEtcdAPIError).Times(1)

w = httptest.NewRecorder()
Expand All @@ -494,8 +499,13 @@ func TestUpdateChangefeed(t *testing.T) {
Return(oldCfInfo, &model.UpstreamInfo{}, nil).
Times(1)
mockCapture.EXPECT().GetUpstreamManager().Return(upstream.NewManager4Test(&mockPDClient{}), nil).AnyTimes()
<<<<<<< HEAD
etcdClient.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
=======
mockOwner.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any()).
>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))
Return(nil).Times(1)

w = httptest.NewRecorder()
Expand All @@ -511,8 +521,13 @@ func TestUpdateChangefeed(t *testing.T) {
Return(oldCfInfo, &model.UpstreamInfo{}, nil).
Times(1)
mockCapture.EXPECT().GetUpstreamManager().Return(upstream.NewManager4Test(&mockPDClient{}), nil).AnyTimes()
<<<<<<< HEAD
etcdClient.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
=======
mockOwner.EXPECT().
UpdateChangefeedAndUpstream(gomock.Any(), gomock.Any(), gomock.Any()).
>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))
Return(nil).Times(1)

w = httptest.NewRecorder()
Expand Down
18 changes: 18 additions & 0 deletions cdc/owner/mock/owner_mock.go

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

28 changes: 28 additions & 0 deletions cdc/owner/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ type Owner interface {
WriteDebugInfo(w io.Writer, done chan<- error)
Query(query *Query, done chan<- error)
AsyncStop()
<<<<<<< HEAD

Check failure on line 94 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected <<, expected ~ term or type

Check failure on line 94 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected <<, expected ~ term or type
=======
UpdateChangefeedAndUpstream(ctx context.Context,
upstreamInfo *model.UpstreamInfo,
changeFeedInfo *model.ChangeFeedInfo,
) error

Check failure on line 99 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: unexpected ) after top level declaration

Check failure on line 99 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: unexpected ) after top level declaration
UpdateChangefeed(ctx context.Context,
changeFeedInfo *model.ChangeFeedInfo) error
>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))

Check failure on line 102 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'

Check failure on line 102 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'
}

type ownerImpl struct {
Expand Down Expand Up @@ -293,6 +302,25 @@ func (o *ownerImpl) AsyncStop() {
o.cleanStaleMetrics()
}

<<<<<<< HEAD

Check failure on line 305 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: non-declaration statement outside function body

Check failure on line 305 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: non-declaration statement outside function body
=======
func (o *ownerImpl) UpdateChangefeedAndUpstream(ctx context.Context,
upstreamInfo *model.UpstreamInfo,
changeFeedInfo *model.ChangeFeedInfo,
) error {
return o.etcdClient.UpdateChangefeedAndUpstream(ctx, upstreamInfo, changeFeedInfo)
}

func (o *ownerImpl) UpdateChangefeed(ctx context.Context,
changeFeedInfo *model.ChangeFeedInfo,
) error {
return o.etcdClient.SaveChangeFeedInfo(ctx, changeFeedInfo, model.ChangeFeedID{
Namespace: changeFeedInfo.Namespace,
ID: changeFeedInfo.ID,
})
}

>>>>>>> c5d5eff1f2 (api(ticdc): only update upstreamInfo that has changed (#10422))

Check failure on line 323 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

syntax error: non-declaration statement outside function body

Check failure on line 323 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Arm Build (ARM64)

invalid character U+0023 '#'

Check failure on line 323 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

syntax error: non-declaration statement outside function body

Check failure on line 323 in cdc/owner/owner.go

View workflow job for this annotation

GitHub Actions / Mac OS Build

invalid character U+0023 '#'
func (o *ownerImpl) cleanUpChangefeed(state *orchestrator.ChangefeedReactorState) {
state.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
return nil, info != nil, nil
Expand Down
Loading

0 comments on commit 4ffd512

Please sign in to comment.