Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds longhorn-manager v1.7.0 rock #10

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/sanity/test_longhorn_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright 2024 Canonical, Ltd.
#

import pytest
from k8s_test_harness.util import docker_util, env_util

ROCK_EXPECTED_FILES = [
"/usr/local/sbin/launch-manager",
"/usr/local/sbin/longhorn-manager",
"/usr/local/sbin/nsmounter",
]


@pytest.mark.parametrize("image_version", ["v1.7.0"])
def test_longhorn_manager_rock(image_version):
"""Test longhorn-manager rock."""
rock = env_util.get_build_meta_info_for_rock_version(
"longhorn-manager", image_version, "amd64"
)
image = rock.image

# check rock filesystem.
docker_util.ensure_image_contains_paths(image, ROCK_EXPECTED_FILES)

# check binary.
process = docker_util.run_in_docker(image, ["longhorn-manager", "--version"])
assert f"longhorn-manager version {image_version}" in process.stdout
86 changes: 86 additions & 0 deletions v1.7.0/longhorn-manager/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

# Rockcraft definition for Longhorn manager image:
# longhornio/longhorn-manager:v1.7.0

name: longhorn-manager
summary: Rock containing Longhorn manager component.
description: |
Rock containing Longhorn manager component: https://github.com/longhorn/longhorn-manager
Aims to replicate the upstream official image: longhornio/longhorn-manager:v1.7.0
license: Apache-2.0

version: "v1.7.0"

# NOTE(aznashwan): the base for the manager image is the Suse Linux Enterprise
# Base Container Image (SLE BCE) Service Pack 6 which ships with Linux 6.4,
# and is thus most comparable to 24.04:
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L44
base: [email protected]
build-base: [email protected]
platforms:
amd64:
arm64:

services:
longhorn-manager:
summary: "longhorn-manager service"
startup: enabled
override: replace
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L24
command: "launch-manager"
on-success: shutdown
on-failure: shutdown

parts:
# NOTE(aznashwan): the longhorn binary is built within a Docker container
# which is set up by Rancher's Dapper tool: https://github.com/rancher/dapper
# The setup steps for the build container are contained within this Dockerfile:
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Dockerfile.dapper
# The Makefile targets are just the scripts found in the scripts/ directory which
# are executed within the Dapper build container:
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Makefile#L10-L11
build-longhorn-manager:
plugin: nil
source-type: git
source: https://github.com/longhorn/longhorn-manager
source-tag: v1.7.0
source-depth: 1
build-packages:
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Dockerfile.dapper#L21
- gcc
- ca-certificates
# - libdevmapper1_03
- libltdl7
build-snaps:
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Dockerfile.dapper#L1
- go/1.22/stable
build-environment:
- GOOS: linux
- GOARCH: $CRAFT_ARCH_BUILD_FOR
- CGO_ENABLED: 0
- VERSION: $CRAFT_PROJECT_VERSION
override-build: |
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L15
mkdir -p $CRAFT_PART_INSTALL/usr/local/sbin/
cp package/launch-manager package/nsmounter $CRAFT_PART_INSTALL/usr/local/sbin/

LINKFLAGS="-X github.com/longhorn/longhorn-manager/meta.Version=$VERSION -extldflags -static -s"
go build -o $CRAFT_PART_INSTALL/usr/local/sbin/ -ldflags "$LINKFLAGS"

add-packages:
plugin: nil
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L20
stage-packages:
- iproute2
- nfs-common # nfs-client
- cifs-utils
- bind9-utils # bind-utils
- e2fsprogs
- xfsprogs
- zip
- unzip
- kmod
stage-snaps:
- iputils
Loading