Fix a regex of naming rule for a Pod of a Deployment

This patch is fix a regex of naming rule for a Pod of a Deployment.

The naming rule of Pod in deployment is
"(deployment name)-(pod template hash)-(5 charactors)".

Currently, "pod template hash" is a regex with a fixed 10 characters.
However, it may be less than 10 characters, this case is fail in
"scale_wait" of CNF scale.

The "pod template hash" string is generated from 32 bit hash. This
may be from 1 to 10 caracters but not sure the lower limit from the
source code of Kubernetes. Temporarily, this is set to be "{1,10}"
but may need to be fixed.

Closes-Bug: #1921059
Change-Id: I49f6cbe032f35f435f6c9ee69ccb8596cccdb326
This commit is contained in:
Naoaki Horie 2021-03-24 02:38:28 +00:00
parent 7fc77c1654
commit 5bf8df21e0
1 changed files with 6 additions and 1 deletions

View File

@ -1249,8 +1249,13 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
match_result = None
if rsc_kind == 'Deployment':
# Expected example: name-012789abef-019az
# NOTE(horie): The naming rule of Pod in deployment is
# "(deployment name)-(pod template hash)-(5 charactors)".
# The "pod template hash" string is generated from 32 bit hash.
# This may be from 1 to 10 caracters but not sure the lower limit
# from the source code of Kubernetes.
match_result = re.match(
rsc_name + '-([0-9a-f]{10})-([0-9a-z]{5})+$',
rsc_name + '-([0-9a-f]{1,10})-([0-9a-z]{5})+$',
pod_name)
elif rsc_kind == 'ReplicaSet':
# Expected example: name-019az