Skip to content

Commit

Permalink
Refs 2615: don't propagate canceled context (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
rverdile authored Oct 20, 2023
1 parent 7edf223 commit 6021ade
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/dao/repository_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *repositoryConfigDaoImpl) InitializePulpClient(ctx context.Context, orgI
return err
}

pulpClient := pulp_client.GetPulpClientWithDomain(ctx, domainName)
pulpClient := pulp_client.GetPulpClientWithDomain(context.TODO(), domainName)
r.pulpClient = pulpClient
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (sDao *snapshotDaoImpl) InitializePulpClient(ctx context.Context, orgID str
return err
}

pulpClient := pulp_client.GetPulpClientWithDomain(ctx, domainName)
pulpClient := pulp_client.GetPulpClientWithDomain(context.TODO(), domainName)
sDao.pulpClient = pulpClient
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/handler/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ func (rh *RepositoryHandler) update(c echo.Context, fillDefaults bool) error {
repoParams.FillDefaults()
}

err := rh.DaoRegistry.RepositoryConfig.InitializePulpClient(c.Request().Context(), orgID)
if err != nil {
return ce.NewErrorResponse(ce.HttpCodeForDaoError(err), "Error initializing pulp client", err.Error())
}

repoConfig, err := rh.DaoRegistry.RepositoryConfig.Fetch(orgID, uuid)
if err != nil {
return ce.NewErrorResponse(ce.HttpCodeForDaoError(err), "Error fetching repository", err.Error())
Expand Down
4 changes: 4 additions & 0 deletions pkg/handler/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ func (suite *ReposSuite) TestFullUpdate() {
UUID: uuid,
RepositoryUUID: repoUuid,
}, nil)
suite.reg.RepositoryConfig.On("Update", test_handler.MockOrgId, uuid, expected).Return(false, nil)
suite.reg.RepositoryConfig.On("InitializePulpClient", mock.AnythingOfType("*context.valueCtx"), test_handler.MockOrgId).Return(nil).Once()

mockTaskClientEnqueueIntrospect(suite.tcMock, "https://example.com", repoUuid)

Expand Down Expand Up @@ -895,6 +897,7 @@ func (suite *ReposSuite) TestPartialUpdateUrlChange() {
suite.reg.RepositoryConfig.On("Update", test_handler.MockOrgId, repoConfigUuid, expected).Return(true, nil)
suite.reg.RepositoryConfig.On("Fetch", test_handler.MockOrgId, repoConfigUuid).Return(repoConfig, nil)
suite.reg.TaskInfo.On("IsSnapshotInProgress", *expected.OrgID, repoUuid).Return(false, nil)
suite.reg.RepositoryConfig.On("InitializePulpClient", mock.AnythingOfType("*context.valueCtx"), test_handler.MockOrgId).Return(nil).Once()

mockTaskClientEnqueueSnapshot(suite, &repoConfig)
mockTaskClientEnqueueIntrospect(suite.tcMock, "https://example.com", repoUuid)
Expand Down Expand Up @@ -929,6 +932,7 @@ func (suite *ReposSuite) TestPartialUpdate() {
RepositoryUUID: repoUuid,
Snapshot: false,
}, nil)
suite.reg.RepositoryConfig.On("InitializePulpClient", mock.AnythingOfType("*context.valueCtx"), test_handler.MockOrgId).Return(nil).Once()

mockTaskClientEnqueueIntrospect(suite.tcMock, "https://example.com", repoUuid)

Expand Down

0 comments on commit 6021ade

Please sign in to comment.