Skip to content

Commit 122fbaa

Browse files
author
Foivos Filippopoulos
committed
Fix snapshot naming issue and Readme format
1 parent 2d45020 commit 122fbaa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Usage of /gcp-disk-snapshotter:
2020
(Required) Comma separated list of zones where projects disks may live
2121
```
2222

23-
#Configuration File
23+
## Configuration File
2424

2525
Example Configuration File:
2626

snapshot/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,13 @@ func (gsc *GCPSnapClient) CreateSnapshot(diskName, zone string) (string, error)
185185
}
186186

187187
// Name must match regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
188+
// Note: kubernetes creates pvs with names like: kubernetes-dynamic-pvc-828cdc8a-4f85-11e8-a7bc-42010a16140a
189+
// that are 60 chars and so snapshots exceed the 63 chars long with the added suffix.
190+
// Let's just trim `kubernetes-dynamic-` from the name
191+
name := strings.TrimPrefix(diskName, "kubernetes-dynamic-")
188192
snapshot := &compute.Snapshot{
189193
Description: fmt.Sprintf("Snapshot of %s", diskName),
190-
Name: fmt.Sprintf("%s%s-%s", gsc.SnapPrefix, diskName, time.Now().Format("20060102150405")),
194+
Name: fmt.Sprintf("%s%s-%s", gsc.SnapPrefix, name, time.Now().Format("20060102150405")),
191195
Labels: snapLabels,
192196
}
193197

0 commit comments

Comments
 (0)