Skip to content

Commit

Permalink
Build with charmcraft 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Mar 3, 2025
1 parent f2394db commit 4b270b1
Show file tree
Hide file tree
Showing 39 changed files with 106 additions and 72 deletions.
1 change: 1 addition & 0 deletions .charmcraft-channel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.x/stable
6 changes: 5 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.10"
- id: charmcraft
run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: lxd
juju-channel: 3/stable
charm-channel: 3.x/stable
charmcraft-channel: ${{ steps.charmcraft.outputs.channel }}
bootstrap-options: "[email protected]"
- name: Run test
run: tox -e integration
- name: Setup Debug Artifact Collection
Expand Down
29 changes: 29 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
type: charm

bases:
- build-on:
- name: ubuntu
channel: "22.04"
architectures: ["amd64"]
run-on:
- name: ubuntu
channel: "22.04"
architectures: ["amd64", "arm64", "s390x"]
- name: ubuntu
channel: "24.04"
architectures: ["amd64", "arm64", "s390x"]
parts:
charm:
source: src
plugin: reactive
reactive-charm-build-arguments:
- --layer-index
- https://raw.githubusercontent.com/charmed-kubernetes/layer-index/main/
- --debug
- --force
build-snaps:
- charm/3.x/stable
build-environment:
- CHARM_INTERFACES_DIR: $CRAFT_PROJECT_DIR/interfaces/
- CHARM_LAYERS_DIR: $CRAFT_PROJECT_DIR/layers/

58 changes: 0 additions & 58 deletions metadata.yaml

This file was deleted.

1 change: 1 addition & 0 deletions metadata.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion actions/restore.py → src/actions/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def probe_forked_etcd():
try:
output = check_output(split("/snap/bin/etcd.etcdctl member list"))
loop = loop + 1
except:
except Exception:
log("Still waiting on forked etcd instance...")
output = b""
loop = loop + 1
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions actions/snap-upgrade.py → src/actions/snap-upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from charmhelpers.core.hookenv import action_get
from charmhelpers.core.hookenv import action_set
from charmhelpers.core.hookenv import action_fail
from charmhelpers.core.hookenv import config
from charmhelpers.core.hookenv import log
from charms.reactive import is_state
from charms.reactive import remove_state
Expand Down Expand Up @@ -153,7 +152,7 @@ def purge_deb_files():
k = "purge.missing.{}".format(os.path.basename(f))
msg = "Did not purge {}. File not found.".format(f)
action_set({k: msg})
except:
except Exception:
k = "purge.error.{}".format(f)
msg = "Failed to purge {}. Manual removal required.".format(k)
action_set({k: msg})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions src/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: etcd
summary: Deploy a TLS terminated ETCD Cluster
maintainers:
- Tim Van Steenburgh <[email protected]>
- George Kraft <[email protected]>
- Rye Terrell <[email protected]>
- Konstantinos Tsakalozos <[email protected]>
- Charles Butler <[email protected]>
description: |
This charm supports deploying Etcd from the upstream binaries with resources.
It will also TLS wrap your service, and distribute client keys to any service
connecting. Etcd is a highly available key/value store.
docs: https://discourse.charmhub.io/t/charm-etcd-docs-index/5592
provides:
db:
interface: etcd
proxy:
interface: etcd-proxy
prometheus:
interface: prometheus-manual
grafana:
interface: grafana-dashboard
peers:
cluster:
interface: etcd
resources:
snapshot:
type: file
filename: snapshot.tar.gz
description: Tarball snapshot of an etcd clusters data.
core:
type: file
filename: core.snap
description: |
Snap package of core
[DEPRECATED] in favor of using a Snap Store Proxy.
See https://ubuntu.com/kubernetes/docs/proxies for more details.
etcd:
type: file
filename: etcd.snap
description: |
Snap package of etcd
[DEPRECATED] in favor of using a Snap Store Proxy.
See https://ubuntu.com/kubernetes/docs/proxies for more details.
series:
- noble
- jammy
storage:
data:
type: block
description: Data volume to store the Etcd wal file and data.
multiple:
range: 0-1
minimum-size: 1G
subordinate: false
tags:
- database
- keystore
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

def load_alarm_list():
"""Load the cached status from disk, return it as a string"""
alarm_list_path = '/var/lib/nagios/etcd-alarm-list.txt'
alarm_list_path = "/var/lib/nagios/etcd-alarm-list.txt"

with open(alarm_list_path, 'r') as alarm_list_log:
with open(alarm_list_path, "r") as alarm_list_log:
alarm_list = alarm_list_log.read()

return alarm_list.strip()
Expand All @@ -24,7 +24,7 @@ def check_alarms():
if line:
alarms.append(line)
if alarms:
raise nagios_plugin3.CriticalError(' '.join(alarms))
raise nagios_plugin3.CriticalError(" ".join(alarms))


def main():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/unit/lib/test_etcd_databag.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_render_etcd2(
config.set("channel", "3.2/stable")
config.set("snapshot_count", "auto")
bag = etcd_databag.EtcdDatabag()
template_env = Environment(loader=FileSystemLoader("templates"))
template_env = Environment(loader=FileSystemLoader("src/templates"))
config = template_env.get_template("etcd2.conf").render(bag.__dict__)
lines = config.splitlines()
assert 'ETCD_ADVERTISE_CLIENT_URLS="https://[4001:84::1]:5678"' in lines
Expand All @@ -69,7 +69,7 @@ def test_render_etcd3(
config.set("channel", "3.2/stable")
config.set("snapshot_count", "auto")
bag = etcd_databag.EtcdDatabag()
template_env = Environment(loader=FileSystemLoader("templates"))
template_env = Environment(loader=FileSystemLoader("src/templates"))
config = template_env.get_template("etcd3.conf").render(bag.__dict__)
lines = config.splitlines()
assert "advertise-client-urls: https://[4001:84::1]:5678" in lines
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ envlist = lint,unit
[testenv]
basepython = python3
setenv =
PYTHONPATH={toxinidir}:{toxinidir}/lib
PYTHONPATH={toxinidir}/src:{toxinidir}/src/lib

[testenv:format]
deps =
black
commands =
black {toxinidir}/actions {toxinidir}/reactive {toxinidir}/lib {toxinidir}/tests/integration {toxinidir}/tests/unit
black {toxinidir}/src {toxinidir}/tests/integration {toxinidir}/tests/unit

[testenv:unit]
deps =
Expand All @@ -26,7 +26,7 @@ deps =
charms.unit_test
commands =
pytest --cov-report term-missing \
--cov lib --cov-fail-under 75 \
--cov src/lib --cov-fail-under 75 \
--tb native -s {posargs} {toxinidir}/tests/unit

[testenv:integration]
Expand All @@ -46,8 +46,8 @@ deps =
flake8
envdir = {toxworkdir}/py3
commands =
flake8 {toxinidir}/reactive {toxinidir}/lib {toxinidir}/tests/integration {toxinidir}/tests/unit
black --check --diff {toxinidir}/actions {toxinidir}/reactive {toxinidir}/lib {toxinidir}/tests/integration {toxinidir}/tests/unit
flake8 {toxinidir}/src {toxinidir}/tests/integration {toxinidir}/tests/unit
black --check --diff {toxinidir}/src {toxinidir}/tests/integration {toxinidir}/tests/unit

[testenv:validate-wheelhouse]
deps =
Expand Down

0 comments on commit 4b270b1

Please sign in to comment.