Skip to content
Closed
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
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Release pipeline — triggered by pushing a v* tag.
#
# Produces, from the tagged commit and nothing else:
# 1. linux/amd64 + linux/arm64 binaries (CGO_ENABLED=0 — the Ceph RBD backend
# sits behind the `ceph` build tag, so cross-compilation needs no cgo)
# 2. a multi-arch container image pushed to ghcr.io
# 3. a GitHub Release with the binaries and their checksums
# 4. the Helm chart published as an OCI artifact (appVersion = the tag)
#
# Version stamping contract (review R1): the tag is injected with
# `-ldflags "-X main.Version=<tag>"` and round-tripped through
# `lightstack --version` before anything is published.
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

env:
GO_VERSION: '1.27.2'

jobs:
test:
name: Test gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run unit tests
run: make test

release:
name: Build and publish
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Build binaries
run: |
VERSION="${GITHUB_REF_NAME}"
mkdir -p dist
for GOOS_GOARCH in linux/amd64 linux/arm64; do
GOOS="${GOOS_GOARCH%/*}"
GOARCH="${GOOS_GOARCH#*/}"
CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \
go build -trimpath \
-ldflags "-s -w -X main.Version=${VERSION}" \
-o "dist/lightstack-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack
CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \
go build -trimpath -s -w \
-o "dist/lightstack-migrate-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack-migrate
done

- name: Verify version stamping
# R1 regression guard: the Makefile used to inject -X main.Version
# into a variable that did not exist, which Go silently ignored.
run: |
VERSION="${GITHUB_REF_NAME}"
GOT="$(./dist/lightstack-${VERSION}-linux-amd64 --version)"
if [ "$GOT" != "$VERSION" ]; then
echo "::error::--version reported '${GOT}', expected '${VERSION}'"
exit 1
fi

- name: Checksums
run: cd dist && sha256sum * > "checksums-${GITHUB_REF_NAME}.txt"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: build/package/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${GITHUB_REF_NAME}
build-args: |
VERSION=${{ github.ref_name }}
VCS_REF=${{ github.sha }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
files: |
dist/lightstack-*
dist/checksums-*

- name: Publish Helm chart
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# The chart's own version (Chart.yaml `version`) is bumped per chart
# change in the repo; the app version is pinned to this release tag
# (and the image tag matches it, including the leading "v").
CHART_VERSION="$(awk '/^version:/ {print $2}' charts/lightstack/Chart.yaml)"
helm package charts/lightstack --app-version "${GITHUB_REF_NAME}" -d dist/
echo "${GHCR_TOKEN}" | helm registry login ghcr.io \
-u "${{ github.actor }}" --password-stdin
helm push "dist/lightstack-${CHART_VERSION}.tgz" \
"oci://ghcr.io/${{ github.repository_owner }}/charts"
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [Unreleased]

### 🚀 Release Engineering
- **Version stamping** (review R1, `docs/review/comprehensive-review-report-2026-10-12.md`):
`main.Version` now exists and is injected via `-ldflags "-X main.Version=..."` by
the Makefile, the Dockerfile (`VERSION` build-arg) and the release workflow;
`lightstack --version` prints it and it is logged at startup. Previously the
ldflags injection targeted a nonexistent variable and was silently ignored —
every shipped binary was unidentifiable.
- **Release pipeline** (`.github/workflows/release.yml`, review R3): pushing a `v*`
tag runs the test gate, builds linux/amd64 + linux/arm64 binaries (CGO-free) with
checksums and a `--version` round-trip check, pushes the multi-arch image to
`ghcr.io`, creates a draft GitHub Release and publishes the Helm chart as an OCI
artifact with `appVersion` pinned to the tag.
- **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release).

### 🔒 Security
- **Refuse well-known/empty JWT secrets at startup** (review S2): the defaults
shipped in `config/lightstack.yaml` and `.env.example` are public, and with
stateless tokens knowing one is enough to mint an admin token. `LoadConfig` now
refuses them; `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented
escape hatch for isolated dev/test stacks (the plain docker-compose dev stack
and `make run` opt in explicitly; the Horizon stack and the Helm chart already
require a real secret).
- **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member`
(matches the seeded admin/member/reader roles) — was `_member_`, which matches
nothing in the seed.

---

## [0.6.1] - 2026-04-22

### 📋 v0.7.0 Planning & Specifications
Expand Down
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ openstack token issue
### Building and Running

```bash
# Build the main binary
# Build the main binary (version-stamped from git describe)
make build # Outputs to bin/lightstack

# Check the build version
./bin/lightstack --version

# Run with configuration
make run # Builds and starts with config/lightstack.yaml

Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ build-with-ebpf: build-ebpf build
# Run the application
run: build
@echo "Starting lightstack..."
./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations
# The dev escape hatch: the shipped config carries the well-known default
# JWT secret, which the binary refuses without this (review S2). `make run`
# is a local-development target only — production deployments set a real
# keystone.jwt_secret (or LIGHTSTACK_JWT_SECRET) and never set this.
LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 \
./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations

# Install dependencies
install-deps:
Expand Down
2 changes: 1 addition & 1 deletion build/package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . .

# Build the binary for target architecture
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags="-w -s" -o lightstack ./cmd/lightstack
go build -ldflags="-w -s -X main.Version=${VERSION}" -o lightstack ./cmd/lightstack

# Build the migration tool for target architecture
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
Expand Down
3 changes: 2 additions & 1 deletion charts/lightstack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: Deploy lightstack (lightweight OpenStack-compatible cloud) on Kuber
type: application
# Chart version (SemVer). Bumped independently of the product.
# 0.3.0: adds the noVNC console proxy + console-token settings (SPEC-021).
version: 0.3.0
# 0.4.0: release-engineering alignment — appVersion 0.7.0 target, OCI publish via the tag-triggered release workflow.
version: 0.4.0
# Default product image tag when image.tag is unset (image.repository is REQUIRED, no default — FR-018).
appVersion: "0.7.0"
kubeVersion: ">=1.25.0-0"
Expand Down
3 changes: 2 additions & 1 deletion cmd/lightstack/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
// wrong directory, console-tokens would list and purge nothing.
func TestLoadConfigAppliesStatePath(t *testing.T) {
path := filepath.Join(t.TempDir(), "lightstack.yaml")
if err := os.WriteFile(path, []byte("state_path: /data/lightstack\n"), 0o600); err != nil {
if err := os.WriteFile(path, []byte(
"state_path: /data/lightstack\nkeystone:\n jwt_secret: test-secret-not-a-default\n"), 0o600); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { paths.SetBase(paths.DefaultBase) })
Expand Down
18 changes: 18 additions & 0 deletions cmd/lightstack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ import (
var (
configPath = flag.String("config", "config/lightstack.yaml", "Path to configuration file")
migrationsPath = flag.String("migrations", "migrations", "Path to migrations directory")
printVersion = flag.Bool("version", false, "Print the build version and exit")
)

// Version identifies the running build in the field: it is stamped at build
// time by the Makefile, the Dockerfile and the release workflow via
// `-ldflags "-X main.Version=<version>"`, and defaults to "dev" otherwise.
// R1 of docs/review/comprehensive-review-report-2026-10-12.md: without this
// variable the ldflags injection silently did nothing, making every shipped
// binary unidentifiable.
var Version = "dev"

func main() {
// Subcommand dispatch: `lightstack cleanup` runs the SPEC-010 teardown and exits,
// before flag.Parse (which would otherwise treat the subcommand as a positional).
Expand All @@ -68,6 +77,15 @@ func main() {

flag.Parse()

// `lightstack --version` reports the stamped build version and exits, so a
// node in the field can be identified without its deployment metadata.
if *printVersion {
fmt.Println(Version)
return
}

log.Printf("lightstack %s starting", Version)

// Load configuration
cfg, err := loadConfig(*configPath)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ services:
LIGHTSTACK_REDIS_URL: "redis://redis:6379/0"
LIGHTSTACK_CACHE_ENABLED: "true"
LIGHTSTACK_JWT_SECRET: "${LIGHTSTACK_JWT_SECRET:-change-me-in-production}"
# The binary refuses the well-known default secret above unless this is
# set (review S2). This is the stub-mode development stack — no real
# guests, tokens never leave the host — so the escape hatch is
# acceptable here. NEVER set it where real guests or foreign clients
# reach the services: pass a real LIGHTSTACK_JWT_SECRET instead.
LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true"
LIGHTSTACK_ENDPOINT_HOST: "localhost" # Use localhost for service catalog URLs (accessible from host)
# Why this exists: tests run outside any guest, so they name the instance they ask
# the metadata service about with the X-Instance-ID header (test/contract/ws4_*,
Expand Down
2 changes: 1 addition & 1 deletion deployments/horizon-config/local_settings
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ STATIC_URL = '/static/'
# Lightstack Service Discovery
OPENSTACK_HOST = "lightstack" # Docker service name
OPENSTACK_KEYSTONE_URL = "http://%s:35357/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "member" # matches the seeded roles (admin/member/reader)

# API Version Configuration (Lightstack Flamingo Compatible)
OPENSTACK_API_VERSIONS = {
Expand Down
41 changes: 38 additions & 3 deletions internal/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,49 @@ func LoadConfig(path string) (*Config, error) {
cfg.Nova.ShutdownTimeout = MaxShutdownTimeout
}

// Warn if using default JWT secret
if cfg.Keystone.JWTSecret == "change-me-in-production" {
fmt.Fprintln(os.Stderr, "WARNING: Using default JWT secret! Set LIGHTSTACK_JWT_SECRET environment variable in production.")
// Refuse well-known (or empty) JWT secrets unless explicitly overridden.
// The defaults below ship in this repository and in .env.example, so anyone
// can read them — and because tokens are stateless, knowing the secret is
// enough to mint an admin token for every service (review finding S2,
// docs/review/comprehensive-review-report-2026-10-12.md). The chart already
// fails fast on an empty secret; this gives the binary the same stance.
if isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() {
return nil, fmt.Errorf(
"keystone.jwt_secret is empty or a well-known default — refusing to start. " +
"Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " +
"environment variable) to a random value, e.g. `openssl rand -base64 32`. " +
"For isolated development or test environments only, " +
"LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check")
}

return &cfg, nil
}

// insecureDefaultJWTSecrets are values that appear in this repository's shipped
// configuration and examples. An empty secret is equally forgeable (HMAC with a
// known key), so it is refused too.
var insecureDefaultJWTSecrets = map[string]struct{}{
"": {},
"change-me-in-production": {},
"change-me-in-production-use-openssl-rand-base64-32": {},
}

func isInsecureDefaultJWTSecret(secret string) bool {
_, known := insecureDefaultJWTSecrets[secret]
return known
}

// allowInsecureDefaultJWTSecret is the documented escape hatch for stub-mode
// development and test stacks that never validate a foreign token.
func allowInsecureDefaultJWTSecret() bool {
switch os.Getenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET") {
case "1", "true":
return true
default:
return false
}
}

// maxRealModeStatePath keeps a guest's console socket path within QEMU's 108-byte
// sun_path: 108 - len("/console-sockets/") - 36 (uuid) - len(".sock") = 50 (SPEC-021
// FR-017). Stub mode creates no sockets, so it is not limited.
Expand Down
Loading
Loading