Skip to content

Commit c4c8457

Browse files
Adding PackageRevision Deletion Guide
1 parent a124b78 commit c4c8457

File tree

2 files changed

+378
-2
lines changed

2 files changed

+378
-2
lines changed

content/en/docs/neo-porch/4_tutorials_and_how-tos/working_with_package_revisions/creating-packages.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,15 @@ porchctl rpkg get porch-test.my-first-package.v1 --namespace default
275275
The lifecycle should now show `Published`.
276276

277277
```bash
278-
NAME PACKAGE WORKSPACENAME REVISION LATEST LIFECYCLE REPOSITORY
279-
porch-test.my-first-package.v1 my-first-package v1 1 true Published porch-test
278+
NAME                               PACKAGE            WORKSPACENAME   REVISION   LATEST   LIFECYCLE   REPOSITORY
279+
porch-test.my-first-package.main   my-first-package   main            -1         true     Published   porch-test
280+
porch-test.my-first-package.v1     my-first-package   v1              1          false    Published   porch-test
280281
```
281282

283+
{{% alert title="Note" color="primary" %}}
284+
Porch automatically creates a main branch-tracking PackageRevision (with workspace `main` and revision `-1`) to track the latest published version of this package.
285+
{{% /alert %}}
286+
282287
---
283288

284289
## Step 6b: Reject the Package Revision (Alternative)
Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
---
2+
title: "Deleting Package Revisions"
3+
type: docs
4+
weight: 7
5+
description: "A step by step guide to deleting package revisions in Porch"
6+
---
7+
8+
## Tutorial Overview
9+
10+
You will learn how to:
11+
12+
1. Delete Draft and Proposed PackageRevisions directly
13+
2. Propose Published PackageRevisions for deletion
14+
3. Approve or reject deletion proposals
15+
4. Understand the deletion workflow and safety mechanisms
16+
17+
{{% alert title="Note" color="primary" %}}
18+
This tutorial assumes a porch repository is initialized with the "porch-test" name.
19+
Replace any "porch-test" value with your repository's name in the commands below.
20+
{{% /alert %}}
21+
22+
---
23+
24+
## Understanding PackageRevision Deletion
25+
26+
PackageRevision deletion in Porch follows different workflows depending on the lifecycle state:
27+
28+
**Direct Deletion:**
29+
- **Draft** and **Proposed** PackageRevisions can be deleted immediately
30+
- No approval process required
31+
- Permanently removes the PackageRevision and its Git branch
32+
33+
**Deletion Proposal Workflow:**
34+
- **Published** PackageRevisions require a two-step deletion process
35+
- First propose deletion, then approve the proposal
36+
- Provides safety mechanism to prevent accidental deletion of production packages
37+
38+
**Branch-Tracking PackageRevisions:**
39+
40+
- When you publish a PackageRevision, Porch automatically creates a "main" branch-tracking PackageRevision
41+
- These have revision `-1` and workspace name `main`
42+
- They track the current state of the package on the main Git branch
43+
- **Important**: These are managed automatically by Porch and should not be directly modified
44+
- The only user interaction should be deletion after all regular PackageRevisions of **that specific package** are deleted
45+
46+
---
47+
48+
## Step 1: Create Test PackageRevisions
49+
50+
Let's create some test PackageRevisions to demonstrate the deletion workflows:
51+
52+
```bash
53+
# Create a Draft PackageRevision
54+
porchctl rpkg init test-draft-package \
55+
--namespace=default \
56+
--repository=porch-test \
57+
--workspace=draft-v1 \
58+
--description="Test package for deletion"
59+
60+
# Create a Proposed PackageRevision
61+
porchctl rpkg init test-proposed-package \
62+
--namespace=default \
63+
--repository=porch-test \
64+
--workspace=proposed-v1 \
65+
--description="Test package for deletion"
66+
67+
porchctl rpkg propose porch-test.test-proposed-package.proposed-v1 --namespace=default
68+
69+
# Create a Published PackageRevision
70+
porchctl rpkg init test-published-package \
71+
--namespace=default \
72+
--repository=porch-test \
73+
--workspace=published-v1 \
74+
--description="Test package for deletion"
75+
76+
porchctl rpkg propose porch-test.test-published-package.published-v1 --namespace=default
77+
porchctl rpkg approve porch-test.test-published-package.published-v1 --namespace=default
78+
```
79+
80+
**Verify the PackageRevisions were created:**
81+
82+
```bash
83+
porchctl rpkg get --namespace=default
84+
```
85+
86+
You should see output similar to:
87+
88+
```bash
89+
NAME PACKAGE WORKSPACENAME REVISION LATEST LIFECYCLE REPOSITORY
90+
porch-test.test-draft-package.draft-v1 test-draft-package draft-v1 0 false Draft porch-test
91+
porch-test.test-proposed-package.proposed-v1 test-proposed-package proposed-v1 0 false Proposed porch-test
92+
porch-test.test-published-package.published-v1 test-published-package published-v1 1 true Published porch-test
93+
```
94+
95+
---
96+
97+
## Step 2: Delete Draft PackageRevisions
98+
99+
Draft PackageRevisions can be deleted immediately without any approval process:
100+
101+
```bash
102+
porchctl rpkg del porch-test.test-draft-package.draft-v1 --namespace=default
103+
```
104+
105+
**What this does:**
106+
107+
- Immediately removes the Draft PackageRevision
108+
- Deletes the corresponding Git branch (`draft/draft-v1`)
109+
- No approval or confirmation required
110+
111+
**Verify deletion:**
112+
113+
```bash
114+
porchctl rpkg get --namespace=default --name=test-draft-package
115+
```
116+
117+
The Draft PackageRevision should no longer appear in the list.
118+
119+
---
120+
121+
## Step 3: Delete Proposed PackageRevisions
122+
123+
Proposed PackageRevisions can also be deleted directly:
124+
125+
```bash
126+
porchctl rpkg del porch-test.test-proposed-package.proposed-v1 --namespace=default
127+
```
128+
129+
**What this does:**
130+
131+
- Immediately removes the Proposed PackageRevision
132+
- Deletes the corresponding Git branch (`proposed/proposed-v1`)
133+
- No approval process required
134+
135+
**Verify deletion:**
136+
137+
```bash
138+
porchctl rpkg get --namespace=default --name=test-proposed-package
139+
```
140+
141+
The Proposed PackageRevision should no longer appear in the list.
142+
143+
---
144+
145+
## Step 4: Propose Published PackageRevision for Deletion
146+
147+
Published PackageRevisions cannot be deleted directly. You must first propose them for deletion:
148+
149+
```bash
150+
porchctl rpkg propose-delete porch-test.test-published-package.published-v1 --namespace=default
151+
```
152+
153+
**What this does:**
154+
155+
- Changes the PackageRevision lifecycle from `Published` to `DeletionProposed`
156+
- Signals that the PackageRevision should be deleted
157+
- Requires approval before actual deletion occurs
158+
159+
**Verify the state change:**
160+
161+
```bash
162+
porchctl rpkg get porch-test.test-published-package.published-v1 --namespace=default
163+
```
164+
165+
The lifecycle should now show `DeletionProposed`:
166+
167+
```bash
168+
NAME PACKAGE WORKSPACENAME REVISION LATEST LIFECYCLE REPOSITORY
169+
porch-test.test-published-package.published-v1 test-published-package published-v1 1 true DeletionProposed porch-test
170+
```
171+
172+
---
173+
174+
## Step 5a: Approve Deletion Proposal
175+
176+
If you want to proceed with deletion, approve the deletion proposal:
177+
178+
```bash
179+
porchctl rpkg del porch-test.test-published-package.published-v1 --namespace=default
180+
```
181+
182+
**What this does:**
183+
184+
- Permanently deletes the PackageRevision
185+
- Removes the Git tag and any associated branches
186+
- Cannot be undone once completed
187+
188+
**Verify deletion:**
189+
190+
```bash
191+
porchctl rpkg get --namespace=default --name=test-published-package
192+
```
193+
194+
The PackageRevision should no longer exist.
195+
196+
---
197+
198+
## Step 5b: Reject Deletion Proposal (Alternative)
199+
200+
If you decide not to delete the PackageRevision, you can reject the deletion proposal:
201+
202+
```bash
203+
# First, let's create another Published PackageRevision for this example
204+
porchctl rpkg init test-reject-delete \
205+
--namespace=default \
206+
--repository=porch-test \
207+
--workspace=reject-v1 \
208+
--description="Test package for rejection"
209+
210+
porchctl rpkg propose porch-test.test-reject-delete.reject-v1 --namespace=default
211+
porchctl rpkg approve porch-test.test-reject-delete.reject-v1 --namespace=default
212+
213+
# Propose it for deletion
214+
porchctl rpkg propose-delete porch-test.test-reject-delete.reject-v1 --namespace=default
215+
216+
# Now reject the deletion proposal
217+
porchctl rpkg reject porch-test.test-reject-delete.reject-v1 --namespace=default
218+
```
219+
220+
**What this does:**
221+
222+
- Changes lifecycle from `DeletionProposed` back to `Published`
223+
- PackageRevision returns to normal published state
224+
- Can be used again normally
225+
226+
**Verify the state change:**
227+
228+
```bash
229+
porchctl rpkg get porch-test.test-reject-delete.reject-v1 --namespace=default
230+
```
231+
232+
The lifecycle should be back to `Published`.
233+
234+
---
235+
236+
## Batch Deletion Operations
237+
238+
You can delete multiple PackageRevisions in a single command:
239+
240+
**Delete multiple Draft/Proposed PackageRevisions:**
241+
242+
```bash
243+
porchctl rpkg del package1 package2 package3 --namespace=default
244+
```
245+
246+
**Propose multiple Published PackageRevisions for deletion:**
247+
248+
```bash
249+
porchctl rpkg propose-delete package1 package2 package3 --namespace=default
250+
```
251+
252+
**Approve multiple deletion proposals:**
253+
254+
```bash
255+
porchctl rpkg del package1 package2 package3 --namespace=default
256+
```
257+
258+
---
259+
260+
## Deletion Workflow Summary
261+
262+
The complete deletion workflow depends on the PackageRevision lifecycle state:
263+
264+
```mermaid
265+
graph TD
266+
A[PackageRevision] --> B{Lifecycle State?}
267+
B -->|Draft| C[porchctl rpkg del]
268+
B -->|Proposed| C
269+
B -->|Published| D[porchctl rpkg propose-delete]
270+
C --> E[Immediately Deleted]
271+
D --> F[DeletionProposed State]
272+
F --> G{Decision?}
273+
G -->|Approve| H[porchctl rpkg del]
274+
G -->|Reject| I[porchctl rpkg reject]
275+
H --> E
276+
I --> J[Back to Published]
277+
```
278+
279+
---
280+
281+
## Safety Considerations
282+
283+
**Published PackageRevision Protection:**
284+
- Two-step deletion process prevents accidental removal
285+
- Deletion proposals can be reviewed before approval
286+
- Rejected proposals restore the PackageRevision to Published state
287+
288+
**Git Repository Impact:**
289+
- Draft/Proposed deletions remove Git branches
290+
- Published deletions remove Git tags and references
291+
- Deletion is permanent and cannot be undone
292+
293+
**Dependency Considerations:**
294+
- Check if other PackageRevisions depend on the one being deleted
295+
- Deleting upstream packages may affect downstream clones
296+
- Consider the impact on deployed workloads
297+
298+
---
299+
300+
## Troubleshooting
301+
302+
**Cannot delete Published PackageRevision directly:**
303+
304+
```bash
305+
Error: cannot delete published package revision directly, use propose-delete first
306+
```
307+
308+
- Use `porchctl rpkg propose-delete` first, then `porchctl rpkg del`
309+
310+
**PackageRevision not found:**
311+
312+
- Verify the exact PackageRevision name: `porchctl rpkg get --namespace=default`
313+
- Check you're using the correct namespace
314+
- Ensure the PackageRevision hasn't already been deleted
315+
316+
**Permission denied:**
317+
318+
- Check RBAC permissions: `kubectl auth can-i delete packagerevisions -n default`
319+
- Verify your service account has proper deletion roles
320+
321+
**Deletion proposal stuck:**
322+
323+
- Check the PackageRevision status: `porchctl rpkg get <name> -o yaml`
324+
- Look for conditions that might prevent deletion
325+
- Ensure no other processes are modifying the PackageRevision
326+
327+
---
328+
329+
## Complete Cleanup
330+
331+
After deleting PackageRevisions, you may notice "main" branch-tracking PackageRevisions still exist. These are automatically created by Porch when packages are published and must be deleted separately.
332+
333+
{{% alert title="Important" color="warning" %}}
334+
Main branch-tracking PackageRevisions (with workspace name "main" and revision "-1") are managed automatically by Porch. Do not modify, propose, approve, or otherwise interact with them except for deletion after all regular PackageRevisions of that specific package have been removed.
335+
{{% /alert %}}
336+
337+
**Check for remaining PackageRevisions:**
338+
339+
```bash
340+
porchctl rpkg get --namespace=default
341+
```
342+
343+
You might see output like:
344+
345+
```bash
346+
NAME PACKAGE WORKSPACENAME REVISION LATEST LIFECYCLE REPOSITORY
347+
porch-test.test-published-package.main test-published-package main -1 false Published porch-test
348+
porch-test.test-reject-delete.main test-reject-delete main -1 false Published porch-test
349+
```
350+
351+
**Delete the main branch-tracking PackageRevisions:**
352+
353+
```bash
354+
# Propose deletion of main branch PackageRevisions
355+
porchctl rpkg propose-delete porch-test.test-published-package.main --namespace=default
356+
porchctl rpkg propose-delete porch-test.test-reject-delete.main --namespace=default
357+
358+
# Approve the deletions
359+
porchctl rpkg del porch-test.test-published-package.main --namespace=default
360+
porchctl rpkg del porch-test.test-reject-delete.main --namespace=default
361+
```
362+
363+
**Verify complete cleanup:**
364+
365+
```bash
366+
porchctl rpkg get --namespace=default
367+
```
368+
369+
All test PackageRevisions should now be removed.
370+
371+
---

0 commit comments

Comments
 (0)