Skip to content

Commit

Permalink
fix: issue with scheduled-volume-snapshot label length
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneorth committed Dec 20, 2023
1 parent 81fc1e4 commit 65214d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --no-cache-dir --upgrade pip==22.1.2 setuptools==67.1.0 \
&& pip install --no-cache-dir --upgrade pip==23.3 setuptools==67.1.0 \
&& pip install --no-cache-dir -r requirements.txt \
&& rm requirements.txt

Expand Down
7 changes: 5 additions & 2 deletions snapshotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ def new_snapshot_needed(scheduled_snapshot, existing_snapshots):


def create_new_snapshot(scheduled_snapshot):
scheduled_snapshot_name = scheduled_snapshot.get('metadata').get('name')
scheduled_snapshot_name = scheduled_snapshot.get('metadata', {}).get('name')
pvc_name = scheduled_snapshot.get('spec', {}).get('persistentVolumeClaimName')
new_snapshot_name = f'{scheduled_snapshot_name}-{str(int(time.time()))}'
new_snapshot_namespace = scheduled_snapshot.get('metadata', {}).get('namespace')
scheduled_snapshot_name_label = scheduled_snapshot_name
if len(scheduled_snapshot_name) > 63:
scheduled_snapshot_name_label = scheduled_snapshot_name[:63]
new_snapshot_labels = {
**scheduled_snapshot.get('spec', {}).get('snapshotLabels', {}),
'scheduled-volume-snapshot': scheduled_snapshot.get('metadata', {}).get('name')
'scheduled-volume-snapshot': scheduled_snapshot_name_label
}
logging.info(f'Creating snapshot {new_snapshot_name} in namespace {new_snapshot_namespace}')
volume_snapshot_body = {
Expand Down

0 comments on commit 65214d7

Please sign in to comment.