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

feat: address various points after review #2

Merged
merged 1 commit into from
Dec 9, 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
27 changes: 2 additions & 25 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-12-03T00:08:31Z by kres 232fe63.
# Generated on 2024-12-06T13:45:15Z by kres 1ebe796.

name: default
concurrency:
Expand Down Expand Up @@ -108,25 +108,8 @@ jobs:
- name: qemu-up
run: |
make qemu-up
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
- name: image-qemu-up
run: |
make image-qemu-up
- name: push-omni-infra-provider-bare-metal-qemu-up
if: github.event_name != 'pull_request'
env:
PUSH: "true"
run: |
make image-qemu-up
- name: run-integration-test
env:
OMNI_INTEGRATION_TEST_IMAGE: ghcr.io/utkuozdemir/omni-integration-test:latest
TEMP_REGISTRY: registry.dev.siderolabs.io
run: |
sudo -E make run-integration-test
Expand All @@ -146,13 +129,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: logs
path: |-
/tmp/omni.log
/tmp/provider.log
~/.talos/clusters/**/*.log
!~/.talos/clusters/**/swtpm.log
!~/.talos/clusters/**/dhcpd.log
!~/.talos/clusters/**/lb.log
path: /tmp/test-logs
retention-days: "5"
- name: Generate Checksums
if: startsWith(github.ref, 'refs/tags/')
Expand Down
21 changes: 6 additions & 15 deletions .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ spec:
ignoredPaths:
- hack/compose/docker-compose.override.yml
---
kind: auto.CommandConfig
name: qemu-up
spec:
disableImage: true
---
kind: common.Image
name: image-provider
spec:
imageName: omni-infra-provider-bare-metal
baseImage: ghcr.io/siderolabs/talosctl:v1.9.0-alpha.3
pushLatest: false
extraEnvironment:
PLATFORM: linux/amd64,linux/arm64
---
kind: common.Image
name: image-qemu-up
spec:
imageName: omni-infra-provider-bare-metal-qemu-up
baseImage: ghcr.io/siderolabs/talosctl:v1.9.0-alpha.3
pushLatest: false
---
kind: custom.Step
name: ipxe
spec:
Expand Down Expand Up @@ -130,7 +127,6 @@ spec:
sops: true
environment:
TEMP_REGISTRY: registry.dev.siderolabs.io
OMNI_INTEGRATION_TEST_IMAGE: ghcr.io/utkuozdemir/omni-integration-test:latest # todo: testing, remove later
artifacts:
enabled: true
extraPaths:
Expand All @@ -140,12 +136,7 @@ spec:
always: true
continueOnError: true
paths:
- "/tmp/omni.log"
- "/tmp/provider.log"
- "~/.talos/clusters/**/*.log"
- "!~/.talos/clusters/**/swtpm.log"
- "!~/.talos/clusters/**/dhcpd.log"
- "!~/.talos/clusters/**/lb.log"
- "/tmp/test-logs"
---
kind: common.SOPS
spec:
Expand Down
24 changes: 6 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# syntax = docker/dockerfile-upstream:1.11.1-labs
# syntax = docker/dockerfile-upstream:1.12.0-labs

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-12-05T10:44:40Z by kres 232fe63.
# Generated on 2024-12-06T12:07:03Z by kres 1ebe796.

ARG TOOLCHAIN

FROM ghcr.io/siderolabs/talosctl:v1.9.0-alpha.3 AS base-image-provider
FROM ghcr.io/siderolabs/ca-certificates:v1.9.0 AS image-ca-certificates

FROM ghcr.io/siderolabs/talosctl:v1.9.0-alpha.3 AS base-image-qemu-up

FROM ghcr.io/siderolabs/ca-certificates:v1.8.0 AS image-ca-certificates

FROM ghcr.io/siderolabs/fhs:v1.8.0 AS image-fhs
FROM ghcr.io/siderolabs/fhs:v1.9.0 AS image-fhs

FROM --platform=linux/amd64 ghcr.io/siderolabs/ipxe:v1.8.0-16-g71d23b4 AS ipxe-linux-amd64

FROM --platform=linux/arm64 ghcr.io/siderolabs/ipxe:v1.8.0-16-g71d23b4 AS ipxe-linux-arm64

# runs markdownlint
FROM docker.io/oven/bun:1.1.36-alpine AS lint-markdown
FROM docker.io/oven/bun:1.1.38-alpine AS lint-markdown
WORKDIR /src
RUN bun i [email protected] [email protected]
COPY .markdownlint.json .
Expand Down Expand Up @@ -217,7 +213,7 @@ FROM scratch AS qemu-up-all
COPY --from=qemu-up-linux-amd64 / /
COPY --from=qemu-up-linux-arm64 / /

FROM base-image-provider AS image-provider
FROM scratch AS image-provider
ARG TARGETARCH
COPY --from=provider provider-linux-${TARGETARCH} /provider
COPY --from=image-fhs / /
Expand All @@ -233,11 +229,3 @@ COPY --from=ghcr.io/siderolabs/talos-metal-agent-boot-assets:v1.9.0-alpha.3-agen
LABEL org.opencontainers.image.source=https://github.com/siderolabs/omni-infra-provider-bare-metal
ENTRYPOINT ["/provider"]

FROM base-image-qemu-up AS image-qemu-up
ARG TARGETARCH
COPY --from=qemu-up qemu-up-linux-${TARGETARCH} /qemu-up
COPY --from=image-fhs / /
COPY --from=image-ca-certificates / /
LABEL org.opencontainers.image.source=https://github.com/siderolabs/omni-infra-provider-bare-metal
ENTRYPOINT ["/qemu-up"]

14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-12-04T12:05:52Z by kres 232fe63.
# Generated on 2024-12-06T14:06:35Z by kres 1ebe796.

# common variables

Expand All @@ -21,11 +21,11 @@ PROTOBUF_GO_VERSION ?= 1.35.2
GRPC_GO_VERSION ?= 1.5.1
GRPC_GATEWAY_VERSION ?= 2.24.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.27.0
GOIMPORTS_VERSION ?= 0.28.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.62.0
GOLANGCILINT_VERSION ?= v1.62.2
GOFUMPT_VERSION ?= v0.7.0
GO_VERSION ?= 1.23.3
GO_VERSION ?= 1.23.4
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand Down Expand Up @@ -140,7 +140,7 @@ else
GO_LDFLAGS += -s
endif

all: unit-tests provider image-provider qemu-up image-qemu-up ipxe run-integration-test lint
all: unit-tests provider image-provider qemu-up ipxe run-integration-test lint

$(ARTIFACTS): ## Creates artifacts directory.
@mkdir -p $(ARTIFACTS)
Expand Down Expand Up @@ -241,10 +241,6 @@ qemu-up-linux-arm64: $(ARTIFACTS)/qemu-up-linux-arm64 ## Builds executable for
.PHONY: qemu-up
qemu-up: qemu-up-linux-amd64 qemu-up-linux-arm64 ## Builds executables for qemu-up.

.PHONY: image-qemu-up
image-qemu-up: ## Builds image for omni-infra-provider-bare-metal-qemu-up.
@$(MAKE) target-$@ TARGET_ARGS="--tag=$(REGISTRY)/$(USERNAME)/omni-infra-provider-bare-metal-qemu-up:$(IMAGE_TAG)"

run-integration-test: provider qemu-up
TEMP_REGISTRY=$(TEMP_REGISTRY) OMNI_IMAGE=$(OMNI_IMAGE) OMNI_INTEGRATION_TEST_IMAGE=$(OMNI_INTEGRATION_TEST_IMAGE) SKIP_CLEANUP=$(SKIP_CLEANUP) hack/test/integration.sh

Expand Down
24 changes: 12 additions & 12 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/siderolabs/omni-infra-provider-bare-metal/internal/constants"
"github.com/siderolabs/omni-infra-provider-bare-metal/internal/provider"
"github.com/siderolabs/omni-infra-provider-bare-metal/internal/provider/meta"
"github.com/siderolabs/omni-infra-provider-bare-metal/internal/version"
Expand Down Expand Up @@ -88,10 +89,7 @@ func runCmd() error {
}

func init() {
const (
apiPowerMgmtStateDirFlag = "api-power-mgmt-state-dir"
dhcpProxyIfaceOrIPFlag = "dhcp-proxy-iface-or-ip"
)
const apiPowerMgmtStateDirFlag = "api-power-mgmt-state-dir"

rootCmd.Flags().StringVar(&meta.ProviderID, "id", meta.ProviderID, "The id of the infra provider, it is used to match the resources with the infra provider label.")
rootCmd.Flags().BoolVar(&debug, "debug", false, "Enable debug mode & logs.")
Expand All @@ -108,9 +106,10 @@ func init() {
rootCmd.Flags().BoolVar(&providerOptions.UseLocalBootAssets, "use-local-boot-assets", provider.DefaultOptions.UseLocalBootAssets,
"Use local boot assets for iPXE booting. If set, the iPXE server will use the kernel and initramfs from the local assets "+
"instead of forwarding the request to the image factory to boot into agent mode.")
rootCmd.Flags().StringVar(&providerOptions.DHCPProxyIfaceOrIP, dhcpProxyIfaceOrIPFlag, provider.DefaultOptions.DHCPProxyIfaceOrIP,
rootCmd.Flags().StringVar(&providerOptions.DHCPProxyIfaceOrIP, "dhcp-proxy-iface-or-ip", provider.DefaultOptions.DHCPProxyIfaceOrIP,
"The interface name or the IP address on the interface to run the DHCP proxy server on. "+
"If it is an IP address, the DHCP proxy server will run on the interface that has the IP address.")
"If it is an IP address, the DHCP proxy server will run on the interface that has the IP address. "+
"If not specified, defaults to the API advertise address.")
rootCmd.Flags().StringVar(&providerOptions.ImageFactoryBaseURL, "image-factory-base-url", provider.DefaultOptions.ImageFactoryBaseURL,
"The base URL of the image factory.")
rootCmd.Flags().StringVar(&providerOptions.ImageFactoryPXEBaseURL, "image-factory-pxe-base-url", provider.DefaultOptions.ImageFactoryPXEBaseURL,
Expand All @@ -119,23 +118,24 @@ func init() {
"The default Talos version to when forwarding iPXE requests to the image factory to boot into Talos agent.")
rootCmd.Flags().BoolVar(&providerOptions.AgentTestMode, "agent-test-mode", provider.DefaultOptions.AgentTestMode,
fmt.Sprintf("Enable agent test mode. In this mode, the Talos agent will be booted into the test mode via the kernel arg %q. "+
"In this mode, you probably want to set the --%s flag, as the test mode agents are probably QEMU machines whose power is managed over the HTTP API.",
`In this mode, you probably want to set the "--%s" flag, as the test mode agents are probably QEMU machines whose power is managed over the HTTP API.`,
config.TestModeKernelArg, apiPowerMgmtStateDirFlag))
rootCmd.Flags().StringVar(&providerOptions.APIPowerMgmtStateDir, apiPowerMgmtStateDirFlag, provider.DefaultOptions.APIPowerMgmtStateDir,
"The directory to read the power management API endpoints and ports, to be used to manage the power state of the machines which are managed via API "+
"(e.g., QEMU VMs created by 'talosctl cluster create') Mainly used for testing purposes.")
"(e.g., QEMU VMs created by 'qemu-up' or 'talosctl cluster create') Mainly used for testing purposes.")
rootCmd.Flags().StringVar(&providerOptions.BootFromDiskMethod, "boot-from-disk-method", provider.DefaultOptions.BootFromDiskMethod,
"Default method to use to boot server from disk if it hits iPXE endpoint after install.")
rootCmd.Flags().StringSliceVar(&providerOptions.MachineLabels, "machine-labels", provider.DefaultOptions.MachineLabels,
"Comma separated list of key=value pairs to be set to the machine. Example: key1=value1,key2,key3=value3")
rootCmd.Flags().BoolVar(&providerOptions.InsecureSkipTLSVerify, "insecure-skip-tls-verify", provider.DefaultOptions.InsecureSkipTLSVerify,
"Skip TLS verification when connecting to the Omni API.")
rootCmd.Flags().BoolVar(&providerOptions.ClearState, "clear-state", provider.DefaultOptions.ClearState, "Clear the state of the provider on startup.")

if constants.IsDebugBuild {
rootCmd.Flags().BoolVar(&providerOptions.ClearState, "clear-state", provider.DefaultOptions.ClearState, "Clear the state of the provider on startup.")
}

rootCmd.Flags().BoolVar(&providerOptions.EnableResourceCache, "enable-resource-cache", provider.DefaultOptions.EnableResourceCache,
"Enable controller runtime resource cache.")
rootCmd.Flags().BoolVar(&providerOptions.WipeWithZeroes, "wipe-with-zeroes", provider.DefaultOptions.WipeWithZeroes,
"When wiping a machine, write zeroes to the whole disk instead doing a fast wipe.")

// mark the flags as required
rootCmd.MarkFlagRequired(dhcpProxyIfaceOrIPFlag) //nolint:errcheck
}
30 changes: 14 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siderolabs/omni-infra-provider-bare-metal

go 1.23.3
go 1.23.4

replace (
github.com/pensando/goipmi => github.com/siderolabs/goipmi v0.0.0-20211214143420-35f956689e67
Expand All @@ -21,21 +21,20 @@ require (
github.com/siderolabs/image-factory v0.6.2
github.com/siderolabs/net v0.4.0
github.com/siderolabs/omni/client v0.0.0-20241205095318-ce403382d64c
github.com/siderolabs/talos v1.9.0-alpha.3.0.20241202095056-770be16425d2
github.com/siderolabs/talos-metal-agent v0.1.0-alpha.2
github.com/siderolabs/talos v1.9.0-beta.0
github.com/siderolabs/talos-metal-agent v0.1.0-alpha.3
github.com/siderolabs/talos/pkg/machinery v1.9.0-beta.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/net v0.31.0
golang.org/x/net v0.32.0
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.68.0
google.golang.org/grpc v1.68.1
google.golang.org/protobuf v1.35.2
gopkg.in/yaml.v3 v3.0.1
)

require (
cel.dev/expr v0.18.0 // indirect
cel.dev/expr v0.19.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect
Expand Down Expand Up @@ -107,9 +106,8 @@ require (
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/siderolabs/crypto v0.5.0 // indirect
github.com/siderolabs/crypto v0.5.1 // indirect
github.com/siderolabs/go-api-signature v0.3.6 // indirect
github.com/siderolabs/go-blockdevice/v2 v2.0.6 // indirect
github.com/siderolabs/go-cmd v0.1.3 // indirect
Expand All @@ -135,15 +133,15 @@ require (
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
Loading