commit f379b96dd2a301d1cfa70562454ec957d8341125
Author: Igor Degtiarov <email address hidden>
Date: Mon Dec 1 15:51:25 2014 +0200
[MongoDB] Fix bug with 'bad' chars in metadatas keys
MongoDB has two restrictions on fields names, they cannot contain '.' and
start with '$'. In resource_metadata field we can get any data, so it could
be dict with any keys, and if some key contain i.e. dots sample with this
metadata wouldn't be stored in MongoDB.
To protect samples from missing this patch propose to check metadata
for occurrence of dots and '$' in keys if metadata is dict, and to transform
dict with dots before storing it in MongoDB. Transformation means that
we make dict more nested and new node appears where there is dot in dict
key.
It means that if we get metadata as a dict {'a.b.c': v} before storing in
MongoDB it would be transform in {'a': {'b': {'c': v}}}.
Reviewed: https:/ /review. openstack. org/121003 /git.openstack. org/cgit/ openstack/ ceilometer/ commit/ ?id=f379b96dd2a 301d1cfa7056245 4ec957d8341125
Committed: https:/
Submitter: Jenkins
Branch: master
commit f379b96dd2a301d 1cfa70562454ec9 57d8341125
Author: Igor Degtiarov <email address hidden>
Date: Mon Dec 1 15:51:25 2014 +0200
[MongoDB] Fix bug with 'bad' chars in metadatas keys
MongoDB has two restrictions on fields names, they cannot contain '.' and
start with '$'. In resource_metadata field we can get any data, so it could
be dict with any keys, and if some key contain i.e. dots sample with this
metadata wouldn't be stored in MongoDB.
To protect samples from missing this patch propose to check metadata
for occurrence of dots and '$' in keys if metadata is dict, and to transform
dict with dots before storing it in MongoDB. Transformation means that
we make dict more nested and new node appears where there is dot in dict
key.
It means that if we get metadata as a dict {'a.b.c': v} before storing in
MongoDB it would be transform in {'a': {'b': {'c': v}}}.
Closes-Bug: 1246264 add7d7e58007e7c 5c297d91772
Change-Id: I279ae67cd24d4d