Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rator into test/ssh_debug_workflow
  • Loading branch information
yanksyoon committed Jan 18, 2024
2 parents 9ef2041 + babe46d commit 62cc88b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ retry '/snap/bin/lxc exec builder -- /usr/bin/nslookup github.com' 'Wait for net
/snap/bin/lxc exec builder -- /usr/bin/apt-get update
/snap/bin/lxc exec builder --env DEBIAN_FRONTEND=noninteractive -- /usr/bin/apt-get upgrade -yq
/snap/bin/lxc exec builder --env DEBIAN_FRONTEND=noninteractive -- /usr/bin/apt-get install linux-generic-hwe-22.04 -yq
# This will remove older version of kernel as HWE is installed now.
/snap/bin/lxc exec builder -- /usr/bin/apt-get autoremove --purge

/snap/bin/lxc restart builder
retry '/snap/bin/lxc exec builder -- /usr/bin/who' 'Wait for lxd agent to be ready' 30
Expand All @@ -107,6 +109,10 @@ fi
/snap/bin/lxc exec builder -- /usr/sbin/usermod -aG docker ubuntu
/snap/bin/lxc exec builder -- /usr/sbin/iptables -I DOCKER-USER -j ACCEPT

# Reduce image size
/snap/bin/lxc exec builder -- /usr/bin/npm cache clean --force
/snap/bin/lxc exec builder -- /usr/bin/apt-get clean

# Download and verify checksum of yq
if [[ $(uname -m) == 'aarch64' ]]; then
YQ_ARCH="arm64"
Expand Down
3 changes: 2 additions & 1 deletion src-docs/event_timer.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Construct the timer manager.

---

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

### <kbd>function</kbd> `disable_event_timer`

Expand Down Expand Up @@ -96,6 +96,7 @@ The timeout is the number of seconds before an event is timed out. If not set or

- <b>`event_name`</b>: Name of the juju event to schedule.
- <b>`interval`</b>: Number of minutes between emitting each event.
- <b>`timeout`</b>: Timeout for each event handle in minutes.



Expand Down
5 changes: 3 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def __init__(self, *args, **kargs) -> None:
path=self.config["path"], # for detecting changes
token=self.config["token"], # for detecting changes
runner_bin_url=None,
runner_image_url=None,
)

self.proxies: ProxySetting = {}
Expand Down Expand Up @@ -503,7 +502,9 @@ def _on_config_changed(self, _event: ConfigChangedEvent) -> None:
self._refresh_firewall()
try:
self._event_timer.ensure_event_timer(
"reconcile-runners", self.config["reconcile-interval"]
event_name="reconcile-runners",
interval=int(self.config["reconcile-interval"]),
timeout=int(self.config["reconcile-interval"]) - 1,
)
except TimerEnableError as ex:
logger.exception("Failed to start the event timer")
Expand Down
8 changes: 7 additions & 1 deletion src/event_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,21 @@ def ensure_event_timer(self, event_name: str, interval: int, timeout: Optional[i
Args:
event_name: Name of the juju event to schedule.
interval: Number of minutes between emitting each event.
timeout: Timeout for each event handle in minutes.
Raises:
TimerEnableError: Timer cannot be started. Events will be not emitted.
"""
if timeout is not None:
timeout_in_secs = timeout * 60
else:
timeout_in_secs = interval * 30

context: EventConfig = {
"event": event_name,
"interval": interval,
"random_delay": interval // 4,
"timeout": timeout or (interval * 30),
"timeout": timeout_in_secs,
"unit": self.unit_name,
}
self._render_event_template("service", event_name, context)
Expand Down

0 comments on commit 62cc88b

Please sign in to comment.