
The previous method of `swift.head_container` worked well, but it caused Mistral to log the exception raised by swiftclient. This then left a red flag in the logs that confused users debugging. This new method checks for the container by listing all the containers in the account and checking for the name. We only consider containers that start with the full name we are looking for - Swift doesn't have an exact match, only a prefix filter. The workflow then can be used to create the container, capturing the logic that was duplicated in each individual workflow. Closes-Bug: #1730712 Depends-On: I41649d15c57e16bffcf7870a52bc01177aae7cc8 Change-Id: I4a6b5b9b31a4f76840a6c6070a1d733ceade5c64
50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
---
|
|
version: '2.0'
|
|
name: tripleo.swift.v1
|
|
description: TripleO Swift Utility Workflows
|
|
|
|
workflows:
|
|
|
|
container_exists:
|
|
|
|
description: >-
|
|
Verify if a Swift container exists
|
|
|
|
Given the name of a Swift container this workflow will verify if it
|
|
already exists. The workflow will ERROR if it doesn't and end in
|
|
SUCCESS if it does.
|
|
|
|
If create_container: true is passed in, then the container will be
|
|
created if it doesn't exist. In this case, if the workflow fails the
|
|
container failed to create.
|
|
|
|
input:
|
|
- container
|
|
- headers: {}
|
|
- create_container: false
|
|
|
|
tags:
|
|
- tripleo-common-managed
|
|
|
|
tasks:
|
|
|
|
# We use the "prefix" input to only list the containers starting with
|
|
# the container name we want to find. There is no way to do an exact
|
|
# match, but this will greatly reduce the possible number of results.
|
|
get_containers:
|
|
action: swiftservice.list
|
|
input:
|
|
options:
|
|
prefix: <% $.container %>
|
|
publish:
|
|
container_exists: <% bool(task().result) and $.container in task().result[0].listing.name %>
|
|
create_input: <% $.headers and {"container" => $.container, "headers" => $.headers} or {"container" => $.container} %>
|
|
on-success:
|
|
- succeed: <% $.container_exists %>
|
|
- fail: <% not $.create_container and not $.container_exists %>
|
|
- create_container: <% $.create_container and not $.container_exists %>
|
|
|
|
create_container:
|
|
action: swift.put_container
|
|
input: <% $.create_input %>
|