Skip to content

Commit

Permalink
Fix building image
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Jul 5, 2024
1 parent b24f201 commit d341342
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion scripts/build-openstack-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUNNER_TAR_URL="$1"
HTTP_PROXY="$2"
HTTPS_PROXY="$3"
NO_PROXY="$4"
BASE_IMAGE="$7"
BASE_IMAGE="$5"

# retry function
retry() {
Expand Down
24 changes: 13 additions & 11 deletions src-docs/openstack_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Module for handling interactions with OpenStack.

---

<a href="../src/openstack_cloud/openstack_manager.py#L351"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L355"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `build_image`

Expand All @@ -30,6 +30,7 @@ build_image(
cloud_config: dict[str, dict],
github_client: GithubClient,
path: GithubOrg | GithubRepo,
base_image: BaseImage,
proxies: Optional[ProxyConfig] = None
) → str
```
Expand All @@ -44,6 +45,7 @@ Build and upload an image to OpenStack.
- <b>`cloud_config`</b>: The cloud configuration to connect OpenStack with.
- <b>`github_client`</b>: The Github client to interact with Github API.
- <b>`path`</b>: Github organisation or repository path.
- <b>`base_image`</b>: The base image for building the image.
- <b>`proxies`</b>: HTTP proxy settings.


Expand All @@ -60,7 +62,7 @@ Build and upload an image to OpenStack.

---

<a href="../src/openstack_cloud/openstack_manager.py#L413"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L419"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `create_instance_config`

Expand Down Expand Up @@ -96,7 +98,7 @@ Create an instance config from charm data.

---

<a href="../src/openstack_cloud/openstack_manager.py#L123"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L124"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `InstanceConfig`
The configuration values for creating a single runner instance.
Expand Down Expand Up @@ -135,7 +137,7 @@ __init__(

---

<a href="../src/openstack_cloud/openstack_manager.py#L198"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L199"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ProxyStringValues`
Wrapper class to proxy values to string.
Expand All @@ -154,7 +156,7 @@ Wrapper class to proxy values to string.

---

<a href="../src/openstack_cloud/openstack_manager.py#L307"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L311"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `OpenstackUpdateImageError`
Represents an error while updating image on Openstack.
Expand All @@ -165,7 +167,7 @@ Represents an error while updating image on Openstack.

---

<a href="../src/openstack_cloud/openstack_manager.py#L507"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L513"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GithubRunnerRemoveError`
Represents an error removing registered runner from Github.
Expand All @@ -176,7 +178,7 @@ Represents an error removing registered runner from Github.

---

<a href="../src/openstack_cloud/openstack_manager.py#L517"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L523"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `OpenstackRunnerManager`
Runner manager for OpenStack-based instances.
Expand All @@ -189,7 +191,7 @@ Runner manager for OpenStack-based instances.
- <b>`unit_num`</b>: The juju unit number.
- <b>`instance_name`</b>: Prefix of the name for the set of runners.

<a href="../src/openstack_cloud/openstack_manager.py#L526"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L532"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand Down Expand Up @@ -218,7 +220,7 @@ Construct OpenstackRunnerManager object.

---

<a href="../src/openstack_cloud/openstack_manager.py#L1717"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L1723"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `flush`

Expand All @@ -235,7 +237,7 @@ Flush Openstack servers.

---

<a href="../src/openstack_cloud/openstack_manager.py#L609"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L615"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_github_runner_info`

Expand All @@ -252,7 +254,7 @@ Get information on GitHub for the runners.

---

<a href="../src/openstack_cloud/openstack_manager.py#L557"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_manager.py#L563"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `reconcile`

Expand Down
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ def _common_install_code(self, state: CharmState) -> bool: # noqa: C901
cloud_config=state.charm_config.openstack_clouds_yaml,
github_client=github,
path=state.charm_config.path,
base_image=state.runner_config.base_image,
proxies=state.proxy_config,
)
self.unit.status = ActiveStatus()
Expand Down
8 changes: 7 additions & 1 deletion src/openstack_cloud/openstack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from charm_state import (
Arch,
BaseImage,
CharmState,
GithubOrg,
ProxyConfig,
Expand Down Expand Up @@ -231,12 +232,14 @@ def _get_default_proxy_values(proxies: Optional[ProxyConfig] = None) -> ProxyStr

def _build_image_command(
runner_info: RunnerApplication,
base_image: BaseImage,
proxies: Optional[ProxyConfig] = None,
) -> list[str]:
"""Get command for building runner image.
Args:
runner_info: The runner application to fetch runner tar download url.
base_image: The base image for building the image.
proxies: HTTP proxy settings.
Returns:
Expand All @@ -250,6 +253,7 @@ def _build_image_command(
proxy_values.http,
proxy_values.https,
proxy_values.no_proxy,
str(base_image),
]
return cmd

Expand Down Expand Up @@ -353,6 +357,7 @@ def build_image( # noqa: C901
cloud_config: dict[str, dict],
github_client: GithubClient,
path: GithubPath,
base_image: BaseImage,
proxies: Optional[ProxyConfig] = None,
) -> str:
"""Build and upload an image to OpenStack.
Expand All @@ -362,6 +367,7 @@ def build_image( # noqa: C901
cloud_config: The cloud configuration to connect OpenStack with.
github_client: The Github client to interact with Github API.
path: Github organisation or repository path.
base_image: The base image for building the image.
proxies: HTTP proxy settings.
Raises:
Expand All @@ -387,7 +393,7 @@ def build_image( # noqa: C901

try:
execute_command(
_build_image_command(runner_application, proxies),
_build_image_command(runner_application, proxies, base_image),
check_exit=True,
)
except SubprocessError as exc:
Expand Down

0 comments on commit d341342

Please sign in to comment.