Skip to content

Commit 5a76f22

Browse files
committed
Increase original resource ID max length to 289 chars
Ceilometer formats Swift container resource IDs in the format `<project ID>_<container name>`, where the project ID is 32 characters and container names can be up to 256 characters long, resulting in a resource ID with max length 289 characters. To accommodate this, expand the `original_resource_id` column to have a max length of 289 characters.
1 parent b28f215 commit 5a76f22

File tree

5 files changed

+58
-6
lines changed

5 files changed

+58
-6
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2025 The Gnocchi Developers
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
#
15+
16+
"""Increase original resource ID max length
17+
18+
Revision ID: 94544ca86c7e
19+
Revises: 18fff4509e3e
20+
Create Date: 2025-01-15 22:12:53.822748
21+
22+
"""
23+
24+
from alembic import op
25+
import sqlalchemy as sa
26+
27+
28+
# revision identifiers, used by Alembic.
29+
revision = '94544ca86c7e'
30+
down_revision = '18fff4509e3e'
31+
branch_labels = None
32+
depends_on = None
33+
34+
35+
def upgrade():
36+
op.alter_column("resource", "original_resource_id",
37+
type_=sa.String(289),
38+
nullable=False,
39+
existing_type=sa.String(255),
40+
existing_nullable=False)
41+
op.alter_column("resource_history", "original_resource_id",
42+
type_=sa.String(289),
43+
nullable=False,
44+
existing_type=sa.String(255),
45+
existing_nullable=False)

gnocchi/indexer/sqlalchemy_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def type(cls):
262262
ended_at = sqlalchemy.Column(types.TimestampUTC)
263263
user_id = sqlalchemy.Column(sqlalchemy.String(255))
264264
project_id = sqlalchemy.Column(sqlalchemy.String(255))
265-
original_resource_id = sqlalchemy.Column(sqlalchemy.String(255),
265+
original_resource_id = sqlalchemy.Column(sqlalchemy.String(289),
266266
nullable=False)
267267

268268

gnocchi/tests/functional/gabbits/transformedids.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ tests:
163163
archive_policy_name: medium
164164
status: 400
165165
response_strings:
166-
- transformable resource id >255 max allowed characters for dictionary value
166+
- transformable resource id >289 max allowed characters for dictionary value
167167

168168
- name: post long non uuid resource id
169169
POST: $LAST_URL
170170
data:
171-
# 255 char string
172-
id: four score and seven years ago we the people of the United States of America i have a dream it is the courage to continue that counts four score and seven years ago we the people of the United States of America i have a dream it is the courage to continue
171+
# 289 char string
172+
id: four score and seven years ago we the people of the United States of America i have a dream it is the courage to continue that counts four score and seven years ago we the people of the United States of America i have a dream it is the courage to continue that counts our score and seven y
173173
user_id: 0fbb231484614b1a80131fc22f6afc9c
174174
project_id: f3d41b770cc14f0bb94a1d5be9c0e3ea
175175
metrics:

gnocchi/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def ResourceUUID(value, creator):
4949
try:
5050
return uuid.UUID(value)
5151
except ValueError:
52-
if len(value) <= 255:
52+
if len(value) <= 289:
5353
if creator is None:
5454
creator = "\x00"
5555
return uuid.uuid5(RESOURCE_ID_NAMESPACE,
5656
value + "\x00" + creator)
5757
raise ValueError(
58-
'transformable resource id >255 max allowed characters')
58+
'transformable resource id >289 max allowed characters')
5959

6060

6161
def UUID(value):
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
features:
3+
- |
4+
The maximum length of the resource ID when creating new resources has been
5+
increased from 255 to 289 characters. This extra length allows Gnocchi to
6+
accommodate Swift container resources generated by Ceilometer with the
7+
maximum container name length of 256 characters.

0 commit comments

Comments
 (0)