-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update canal with recent improvements to flannel (#77)
* align gh workflow and tox with current flannel - dupe recent charm-flannel improvements for building resources - drop crashdump in favor of a simple debug-log for failed runner jobs - bump resource script to known-good charm-flannel commit - tox tweaks to be consistent with other charms * follow ck best practices for integration tests (overlay k8s-core with locally built charm/resources) * use etcd3 calls to align with flannel changes * dont run tests on l33t commits to main
- Loading branch information
Showing
9 changed files
with
224 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,106 @@ | ||
name: Run tests with Tox | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
call-inclusive-naming-check: | ||
name: Inclusive Naming | ||
name: Inclusive naming | ||
uses: canonical-web-and-design/Inclusive-naming/.github/workflows/woke.yaml@main | ||
with: | ||
fail-on-error: "true" | ||
|
||
validate-wheelhouse: | ||
name: Validate Wheelhouse | ||
uses: charmed-kubernetes/workflows/.github/workflows/validate-wheelhouse.yaml@main | ||
|
||
lint-unit: | ||
name: Lint Unit | ||
uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@main | ||
|
||
validate-wheelhouse: | ||
uses: charmed-kubernetes/workflows/.github/workflows/validate-wheelhouse.yaml@main | ||
resources-build: | ||
name: Build Resources with docker | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- lint-unit | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
- name: Install Docker | ||
run: sudo snap install docker | ||
- name: Build Resources | ||
run: sudo ./build-canal-resources.sh | ||
- name: Upload flannel artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: flannel-resources | ||
path: ./flannel-*.tar.gz | ||
- name: Upload calico artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: calico-resources | ||
path: ./calico*.tar.gz | ||
- name: Upload calico-node-image artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: calico-node-image-resources | ||
path: ./calico-node-image.tar.gz | ||
|
||
integration-test: | ||
name: Integration test with VMWare | ||
integration-tests: | ||
name: Integration test with Vsphere | ||
runs-on: self-hosted | ||
timeout-minutes: 60 | ||
needs: | ||
- call-inclusive-naming-check | ||
- lint-unit | ||
- validate-wheelhouse | ||
timeout-minutes: 360 | ||
- resources-build | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: vsphere | ||
credentials-yaml: ${{ secrets.CREDENTIALS_YAML }} | ||
clouds-yaml: ${{ secrets.CLOUDS_YAML }} | ||
bootstrap-options: "--model-default datastore=vsanDatastore --model-default primary-network=VLAN_2764" | ||
- name: Install docker (flannel resources) | ||
run: sudo snap install docker | ||
- name: Install juju-crashdump | ||
run: sudo snap install juju-crashdump --classic | ||
- name: Run test | ||
bootstrap-options: "${{ secrets.FOCAL_BOOTSTRAP_OPTIONS }} --model-default datastore=vsanDatastore --model-default primary-network=VLAN_2764" | ||
bootstrap-constraints: "arch=amd64 cores=2 mem=4G" | ||
|
||
- name: Download flannel artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: flannel-resources | ||
|
||
- name: Download calico artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: calico-resources | ||
|
||
- name: Download calico-node-image artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: calico-node-image-resources | ||
|
||
- name: Run integration test | ||
run: tox -e integration | ||
- name: Upload crashdump | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v2 | ||
|
||
- name: Setup Debug Artifact Collection | ||
if: failure() | ||
run: mkdir tmp | ||
|
||
- name: Collect Juju Logs | ||
if: failure() | ||
run: juju debug-log --replay --no-tail | tee tmp/juju-status.txt | ||
|
||
- name: Upload debug artifacts | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: crashdump | ||
path: juju-crashdump-*.tar.xz | ||
name: test-run-artifacts | ||
path: tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
description: A minimal Kubernetes cluster with two machines with virtual networks provided by Canal. | ||
series: &series {{ series }} | ||
applications: | ||
calico: null | ||
kubernetes-control-plane: | ||
options: | ||
channel: {{ snap_channel }} | ||
kubernetes-worker: | ||
options: | ||
channel: {{ snap_channel }} | ||
canal: | ||
charm: {{ charm }} | ||
channel: null | ||
resources: | ||
flannel: {{flannel_amd64|default("0")}} | ||
flannel-arm64: {{flannel_arm64|default("0")}} | ||
calico: {{calico_amd64|default("0")}} | ||
calico-arm64: {{calico_arm64|default("0")}} | ||
calico-node-image: {{calico_node_image|default("0")}} | ||
relations: | ||
- - canal:etcd | ||
- etcd:db | ||
- - canal:cni | ||
- kubernetes-control-plane:cni | ||
- - canal:cni | ||
- kubernetes-worker:cni |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,29 @@ | ||
import logging | ||
from pathlib import Path | ||
import pytest | ||
import shlex | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def ensure_arch_names(current_resources): | ||
for resource in current_resources: | ||
if any(arch in resource.name for arch in ['s390x', 'arm64', 'amd64']): | ||
continue | ||
if resource.name == 'calico-node-image.tar.gz': | ||
# doesn't have an associated arch | ||
continue | ||
# without an arch, assume 'amd64' | ||
head, tail = resource.name.split('.', 1) | ||
arched_name = "{}-amd64.{}".format(head, tail) | ||
(resource.parent / arched_name).symlink_to(resource) | ||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--series", | ||
type=str, | ||
default="focal", | ||
help="Set series for the machine units", | ||
) | ||
parser.addoption( | ||
"--snap-channel", | ||
type=str, | ||
default="1.24/stable", | ||
help="Set snap channel for the control-plane & worker units", | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
async def setup_resources(ops_test): | ||
"""Provides the flannel resources needed to deploy the charm.""" | ||
script_path = resource_path = Path.cwd() | ||
current_resources = list(resource_path.glob("*.tar.gz")) | ||
tmpdir = ops_test.tmp_path / "resources" | ||
tmpdir.mkdir(parents=True, exist_ok=True) | ||
if not current_resources: | ||
# If they are not locally available, try to build them | ||
log.info("Build Resources...") | ||
build_script = script_path / "build-canal-resources.sh" | ||
rc, stdout, stderr = await ops_test.run( | ||
*shlex.split("sudo {}".format(build_script)), cwd=tmpdir, check=False | ||
) | ||
if rc != 0: | ||
err = (stderr or stdout).strip() | ||
log.warning("build-flannel-resources failed: {}".format(err)) | ||
current_resources = list(Path(tmpdir).glob("*.tar.gz")) | ||
resource_path = tmpdir | ||
if not current_resources: | ||
# if we couldn't build them, just download a fixed version | ||
log.info("Downloading Resources...") | ||
fetch_script = script_path / "fetch-charm-store-resources.sh" | ||
rc, stdout, stderr = await ops_test.run( | ||
*shlex.split(str(fetch_script)), cwd=tmpdir, check=False | ||
) | ||
if rc != 0: | ||
err = (stderr or stdout).strip() | ||
log.warning("fetch-charm-store-resources failed: {}".format(err)) | ||
current_resources = list(Path(tmpdir).glob("*.tar.gz")) | ||
resource_path = tmpdir | ||
if not current_resources: | ||
pytest.fail("Could not prepare necessary resources for testing charm") | ||
ensure_arch_names(current_resources) | ||
yield resource_path | ||
def series(request): | ||
return request.config.getoption("--series") | ||
|
||
|
||
@pytest.fixture() | ||
def snap_channel(request): | ||
return request.config.getoption("--snap-channel") |
Oops, something went wrong.