Revert "Action to perform container image prepare"
Need to understand what is causing 1783586, but for now safest action is to revert. Related-Bug: 1783586 This reverts commit 49c169a144b6bbe23f1f1ff525183ce8c0351fc1. Change-Id: I9d7ec0ebdb0f54328395ead06adab5ccff8b1997
This commit is contained in:
parent
49c169a144
commit
27ec819523
@ -82,7 +82,6 @@ mistral.actions =
|
||||
tripleo.config.download_config = tripleo_common.actions.config:DownloadConfigAction
|
||||
tripleo.config.get_overcloud_config = tripleo_common.actions.config:GetOvercloudConfig
|
||||
tripleo.container_images.prepare = tripleo_common.actions.container_images:PrepareContainerImageEnv
|
||||
tripleo.container_images.prepare_params = tripleo_common.actions.container_images:PrepareContainerImageParameters
|
||||
tripleo.deployment.config = tripleo_common.actions.deployment:OrchestrationDeployAction
|
||||
tripleo.deployment.deploy = tripleo_common.actions.deployment:DeployStackAction
|
||||
tripleo.deployment.get_deployment_failures = tripleo_common.actions.deployment:DeploymentFailuresAction
|
||||
|
@ -13,12 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mistral_lib import actions
|
||||
import six
|
||||
from swiftclient import exceptions as swiftexceptions
|
||||
import yaml
|
||||
|
||||
@ -26,7 +26,6 @@ from tripleo_common.actions import base
|
||||
from tripleo_common.actions import heat_capabilities
|
||||
from tripleo_common import constants
|
||||
from tripleo_common.image import kolla_builder
|
||||
from tripleo_common.utils import plan as plan_utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -82,74 +81,3 @@ class PrepareContainerImageEnv(base.TripleOAction):
|
||||
update_action = heat_capabilities.UpdateCapabilitiesAction(
|
||||
environments, container=self.container)
|
||||
return update_action.run(context)
|
||||
|
||||
|
||||
class PrepareContainerImageParameters(base.TripleOAction):
|
||||
"""Populate environment with image params
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, container=constants.DEFAULT_CONTAINER_NAME):
|
||||
super(PrepareContainerImageParameters, self).__init__()
|
||||
self.container = container
|
||||
|
||||
def _get_role_data(self, swift):
|
||||
try:
|
||||
j2_role_file = swift.get_object(
|
||||
self.container, constants.OVERCLOUD_J2_ROLES_NAME)[1]
|
||||
role_data = yaml.safe_load(j2_role_file)
|
||||
except swiftexceptions.ClientException:
|
||||
LOG.info("No %s file found, not filtering container images by role"
|
||||
% constants.OVERCLOUD_J2_ROLES_NAME)
|
||||
role_data = None
|
||||
return role_data
|
||||
|
||||
def run(self, context):
|
||||
self.context = context
|
||||
swift = self.get_object_client(context)
|
||||
|
||||
try:
|
||||
plan_env = plan_utils.get_env(swift, self.container)
|
||||
except swiftexceptions.ClientException as err:
|
||||
err_msg = ("Error retrieving environment for plan %s: %s" % (
|
||||
self.container, err))
|
||||
LOG.exception(err_msg)
|
||||
return actions.Result(error=err_msg)
|
||||
|
||||
try:
|
||||
env_paths, temp_env_paths = plan_utils.build_env_paths(
|
||||
swift, self.container, plan_env)
|
||||
env_files, env = plan_utils.process_environments_and_files(
|
||||
swift, env_paths)
|
||||
|
||||
role_data = self._get_role_data(swift)
|
||||
image_params = kolla_builder.container_images_prepare_multi(
|
||||
env, role_data, dry_run=True)
|
||||
except Exception as err:
|
||||
LOG.exception("Error occurred while processing plan files.")
|
||||
return actions.Result(error=six.text_type(err))
|
||||
finally:
|
||||
# cleanup any local temp files
|
||||
for f in temp_env_paths:
|
||||
os.remove(f)
|
||||
|
||||
try:
|
||||
swift.put_object(
|
||||
self.container,
|
||||
constants.CONTAINER_DEFAULTS_ENVIRONMENT,
|
||||
yaml.safe_dump(
|
||||
{'parameter_defaults': image_params},
|
||||
default_flow_style=False
|
||||
)
|
||||
)
|
||||
except swiftexceptions.ClientException as err:
|
||||
err_msg = ("Error updating %s for plan %s: %s" % (
|
||||
constants.CONTAINER_DEFAULTS_ENVIRONMENT, self.container, err))
|
||||
LOG.exception(err_msg)
|
||||
return actions.Result(error=err_msg)
|
||||
|
||||
environments = {constants.CONTAINER_DEFAULTS_ENVIRONMENT: True}
|
||||
|
||||
update_action = heat_capabilities.UpdateCapabilitiesAction(
|
||||
environments, container=self.container)
|
||||
return update_action.run(context)
|
||||
|
@ -116,56 +116,3 @@ class PrepareContainerImageEnvTest(base.TestCase):
|
||||
'for plan overcloud: nope',
|
||||
action.run(self.ctx).error
|
||||
)
|
||||
|
||||
|
||||
class PrepareContainerImageParametersTest(base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(PrepareContainerImageParametersTest, self).setUp()
|
||||
self.ctx = mock.MagicMock()
|
||||
|
||||
@mock.patch("tripleo_common.actions.container_images."
|
||||
"PrepareContainerImageParameters._get_role_data")
|
||||
@mock.patch("tripleo_common.actions.container_images."
|
||||
"PrepareContainerImageParameters.get_object_client")
|
||||
@mock.patch("tripleo_common.actions.heat_capabilities."
|
||||
"UpdateCapabilitiesAction")
|
||||
@mock.patch("tripleo_common.utils.plan.get_env", autospec=True)
|
||||
@mock.patch("tripleo_common.image.kolla_builder."
|
||||
"container_images_prepare_multi")
|
||||
def test_run(self, prepare, get_env, update_action, goc, grd):
|
||||
plan = {
|
||||
'version': '1.0',
|
||||
'environments': [],
|
||||
'parameter_defaults': {}
|
||||
}
|
||||
role_data = [{'name': 'Controller'}]
|
||||
final_env = {'environments': [
|
||||
{'path': 'overcloud-resource-registry-puppet.yaml'},
|
||||
{'path': 'environments/containers-default-parameters.yaml'},
|
||||
{'path': 'user-environment.yaml'}
|
||||
]}
|
||||
image_params = {'FooContainerImage': '192.0.2.1/foo/image'}
|
||||
image_env_contents = yaml.safe_dump(
|
||||
{'parameter_defaults': image_params},
|
||||
default_flow_style=False
|
||||
)
|
||||
|
||||
swift = goc.return_value
|
||||
swift.get_object.return_value = role_data
|
||||
prepare.return_value = image_params
|
||||
grd.return_value = role_data
|
||||
|
||||
get_env.return_value = plan
|
||||
update_action.return_value.run.return_value = final_env
|
||||
action = container_images.PrepareContainerImageParameters(
|
||||
container='overcloud')
|
||||
self.assertEqual(final_env, action.run(self.ctx))
|
||||
|
||||
get_env.assert_called_once_with(swift, 'overcloud')
|
||||
prepare.assert_called_once_with({}, role_data, dry_run=True)
|
||||
swift.put_object.assert_called_once_with(
|
||||
'overcloud',
|
||||
'environments/containers-default-parameters.yaml',
|
||||
image_env_contents
|
||||
)
|
||||
|
@ -150,7 +150,7 @@ workflows:
|
||||
queue_name: <% $.queue_name %>
|
||||
on-complete:
|
||||
- run_validations: <% $.run_validations %>
|
||||
- container_image_prepare_params: <% not $.run_validations %>
|
||||
- create_swift_rings_backup_plan: <% not $.run_validations %>
|
||||
|
||||
run_validations:
|
||||
workflow: tripleo.validations.v1.run_groups
|
||||
@ -161,15 +161,6 @@ workflows:
|
||||
queue_name: <% $.queue_name %>
|
||||
publish-on-error:
|
||||
message: <% task().result %>
|
||||
on-success: container_image_prepare_params
|
||||
on-error: set_deployment_failed
|
||||
|
||||
container_image_prepare_params:
|
||||
action: tripleo.container_images.prepare_params
|
||||
input:
|
||||
container: <% $.container %>
|
||||
publish-on-error:
|
||||
message: <% task().result %>
|
||||
on-success: create_swift_rings_backup_plan
|
||||
on-error: set_deployment_failed
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user