diff --git a/Dockerfile b/Dockerfile index 0c70012..bc69bc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/snapshotter.py b/snapshotter.py index 89615fa..58acb4c 100644 --- a/snapshotter.py +++ b/snapshotter.py @@ -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 = {