Skip to content

Commit 2db191e

Browse files
committed
HMS-5947: fix delete-snapshots glitchtip errors
1 parent f8b41ff commit 2db191e

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

pkg/clients/pulp_client/interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type PulpClient interface {
6666
// RpmPublication
6767
CreateRpmPublication(ctx context.Context, versionHref string) (*string, error)
6868
FindRpmPublicationByVersion(ctx context.Context, versionHref string) (*zest.RpmRpmPublicationResponse, error)
69+
DeleteRpmPublication(ctx context.Context, publicationHref string) error
6970

7071
// Distribution
7172
CreateRpmDistribution(ctx context.Context, publicationHref string, name string, basePath string, contentGuardHref *string) (*string, error)

pkg/clients/pulp_client/pulp_client_mock.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/clients/pulp_client/rpm_publication.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,18 @@ func (r *pulpDaoImpl) FindRpmPublicationByVersion(ctx context.Context, versionHr
4040
return nil, nil
4141
}
4242
}
43+
44+
func (r *pulpDaoImpl) DeleteRpmPublication(ctx context.Context, publicationHref string) error {
45+
ctx, client := getZestClient(ctx)
46+
httpResp, err := client.PublicationsRpmAPI.PublicationsRpmRpmDelete(ctx, publicationHref).Execute()
47+
if httpResp != nil {
48+
defer httpResp.Body.Close()
49+
}
50+
if err != nil {
51+
if err.Error() == "404 Not Found" {
52+
return nil
53+
}
54+
return errorWithResponseBody("error deleting rpm publication", httpResp, err)
55+
}
56+
return nil
57+
}

pkg/tasks/delete_snapshots.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ func (ds *DeleteSnapshots) deleteOrUpdatePulpContent(snap models.Snapshot, repo
176176
}
177177
}
178178

179+
err = ds.getPulpClient().DeleteRpmPublication(ds.ctx, snap.PublicationHref)
180+
if err != nil {
181+
return err
182+
}
183+
179184
deleteVersionHref, err := ds.getPulpClient().DeleteRpmRepositoryVersion(ds.ctx, snap.VersionHref)
180185
if err != nil {
181186
return err

pkg/tasks/delete_snapshots_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (s *DeleteSnapshotsSuite) TestDeleteSnapshots() {
113113
s.mockPulpClient.On("DeleteRpmDistribution", ctx, snap.DistributionHref).Return(&deleteDistributionHref, nil)
114114
s.mockPulpClient.On("PollTask", ctx, mock.Anything).Return(nil, nil)
115115
s.mockPulpClient.On("DeleteRpmRepositoryVersion", ctx, snap.VersionHref).Return(utils.Ptr("taskHref"), nil)
116+
s.mockPulpClient.On("DeleteRpmPublication", ctx, snap.PublicationHref).Return(nil)
116117

117118
pulpClient := s.pulpClient()
118119
task := DeleteSnapshots{

0 commit comments

Comments
 (0)