From af03cf2a4c8847054d7d43a49be647ea539d8153 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Fri, 13 Sep 2024 16:56:16 +0300 Subject: [PATCH] Don't fail on deregistering a repo on repo delete (#4482) this may be a transcient error, so let's not fail and allow minder to delete it. This may result in a dangling webhook registration in github. Which is not too problematic since Minder detects and is able to overwrite them. Signed-off-by: Juan Antonio Osorio --- internal/repositories/service.go | 4 +++- internal/repositories/service_test.go | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/repositories/service.go b/internal/repositories/service.go index 641be1e6b9..739f0c0ca3 100644 --- a/internal/repositories/service.go +++ b/internal/repositories/service.go @@ -534,7 +534,9 @@ func (r *repositoryService) deleteRepository( err = client.DeregisterEntity(ctx, pb.Entity_ENTITY_REPOSITORIES, repo.Properties) if err != nil { - return fmt.Errorf("error deleting webhook: %w", err) + zerolog.Ctx(ctx).Error(). + Dict("properties", repo.Properties.ToLogDict()). + Err(err).Msg("error deregistering repo") } _, err = db.WithTransaction(r.store, func(t db.ExtendQuerier) (*pb.Repository, error) { diff --git a/internal/repositories/service_test.go b/internal/repositories/service_test.go index 3cf2d998f0..84ec057666 100644 --- a/internal/repositories/service_test.go +++ b/internal/repositories/service_test.go @@ -210,15 +210,14 @@ func TestRepositoryService_DeleteRepository(t *testing.T) { ExpectedError: "error instantiating provider", }, { - Name: "DeleteByName fails when entity cannot be deregistered", + Name: "DeleteByName still works when entity cannot be deregistered", DeleteType: ByName, - DBSetup: newDBMock(withSuccessfulGetByName), + DBSetup: newDBMock(withSuccessfulGetByName, withSuccessfulDelete), ServiceSetup: newPropSvcMock(withSuccessfulEntityWithProps), ProviderManagerSetup: func(p provinfv1.Provider) pf.ProviderManagerMockBuilder { return pf.NewProviderManagerMock(pf.WithSuccessfulInstantiateFromID(p)) }, ProviderSetup: newProviderMock(withFailedDeregister), - ExpectedError: "error deleting webhook", }, { Name: "DeleteByName by ID fails when repo cannot be deleted from DB", @@ -264,15 +263,14 @@ func TestRepositoryService_DeleteRepository(t *testing.T) { ExpectedError: "error instantiating provider", }, { - Name: "DeleteByID fails when entity cannot be deregistered", + Name: "DeleteByID works when entity cannot be deregistered", DeleteType: ByID, - DBSetup: newDBMock(), + DBSetup: newDBMock(withSuccessfulDelete), ServiceSetup: newPropSvcMock(withSuccessfulEntityWithProps), ProviderManagerSetup: func(p provinfv1.Provider) pf.ProviderManagerMockBuilder { return pf.NewProviderManagerMock(pf.WithSuccessfulInstantiateFromID(p)) }, ProviderSetup: newProviderMock(withFailedDeregister), - ExpectedError: "error deleting webhook", }, { Name: "DeleteByID by ID fails when repo cannot be deleted from DB",