Command to discover the versioned tag from latest

This change implements the command
"openstack overcloud container image tag discover" which will become
part of the update and upgrade workflow for deploying new container
images.

It is used to discover the version-based tag by inspecting the image
from a stable tag like current-tripleo-rdo. Stable tags like 'latest'
or 'pike' can't be used for container updates because something needs
to change to trigger the new containers being pulled. Without this
command it would be up to the user to find out what versioned tag to
specify when calling prepare.

This was implemented as its own command instead of integrating with
prepare because there may be multiple image build chains feeding into
the image list (such as RDO, ceph and eventually others) and each will
need its own call to discover the versioned tag.

  tag=$(openstack overcloud container image tag discover \
        --image trunk.registry.rdoproject.org/pike/centos-binary-base:current-tripleo-rdo
        --tag-from-label rdo_version)
  echo $tag
  openstack overcloud container image prepare --tag $tag

Change-Id: I12b16cb267c80e3059786fb980178eb5b3d1a76d
Depends-On: I27ea031287604d70032fb5392aecbce313d4b096
Closes-Bug: #1708967
This commit is contained in:
Steve Baker 2017-08-28 11:20:06 +12:00
parent f2715ebc55
commit eca5393ddc
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,9 @@
---
features:
- The "openstack overcloud container image tag discover" command is provided
to discover the version-based tag by inspecting the image from a stable tag
like 'current-tripleo-rdo'. Stable tags like 'latest' or 'pike' can't be used
for container updates because something needs to change to trigger the new
containers being pulled. Without this command it would be up to the user to
find out what versioned tag to specify when calling prepare.

View File

@ -68,6 +68,7 @@ openstack.tripleoclient.v1 =
overcloud_container_image_upload = tripleoclient.v1.container_image:UploadImage
overcloud_container_image_build = tripleoclient.v1.container_image:BuildImage
overcloud_container_image_prepare = tripleoclient.v1.container_image:PrepareImageFiles
overcloud_container_image_tag_discover = tripleoclient.v1.container_image:DiscoverImageTag
overcloud_delete = tripleoclient.v1.overcloud_delete:DeleteOvercloud
overcloud_credentials = tripleoclient.v1.overcloud_credentials:OvercloudCredentials
overcloud_deploy = tripleoclient.v1.overcloud_deploy:DeployOvercloud

View File

@ -385,3 +385,38 @@ class PrepareImageFiles(command.Command):
os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o666),
'w') as f:
f.write(result_str)
class DiscoverImageTag(command.Command):
"""Discover the versioned tag for an image."""
auth_required = False
log = logging.getLogger(__name__ + ".DiscoverImageTag")
def get_parser(self, prog_name):
parser = super(DiscoverImageTag, self).get_parser(prog_name)
parser.add_argument(
"--image",
dest="image",
metavar='<container image>',
required=True,
help=_("Fully qualified name of the image to discover the tag for "
"(Including registry and stable tag)."),
)
parser.add_argument(
"--tag-from-label",
dest="tag_from_label",
metavar='<image label>',
help=_("Use the value of the specified label to discover the "
"tag."),
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
uploader = image_uploader.ImageUploadManager([])
print(uploader.discover_image_tag(
image=parsed_args.image,
tag_from_label=parsed_args.tag_from_label
))