feat: add --ignore-resource-checks option to production commands

- Introduced a new command-line option `--ignore-resource-checks` to skip prerequisite validation for disk, RAM, and CPU during installation and upgrades.
- Updated the `ProductionSetup` struct to include a flag for skipping resource checks, enhancing flexibility for users with specific deployment needs.
- Enhanced logging to inform users when resource checks are skipped, improving transparency during the setup process.
This commit is contained in:
anonpenguin23 2025-11-11 15:39:51 +02:00
parent c2298e476e
commit c405be3e69
No known key found for this signature in database
GPG Key ID: 1CBB1FE35AFBEE30
4 changed files with 82 additions and 59 deletions

View File

@ -13,6 +13,19 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
### Deprecated ### Deprecated
### Fixed ### Fixed
## [0.69.3] - 2025-11-11
### Added
- Added `--ignore-resource-checks` flag to the install command to skip disk, RAM, and CPU prerequisite validation.
### Changed
\n
### Deprecated
### Removed
### Fixed
\n
## [0.69.2] - 2025-11-11 ## [0.69.2] - 2025-11-11
### Added ### Added

View File

@ -19,7 +19,7 @@ test-e2e:
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
VERSION := 0.69.2 VERSION := 0.69.3
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'

View File

@ -61,6 +61,7 @@ func showProdHelp() {
fmt.Printf(" --bootstrap-join ADDR - Bootstrap raft join address (for secondary bootstrap)\n") fmt.Printf(" --bootstrap-join ADDR - Bootstrap raft join address (for secondary bootstrap)\n")
fmt.Printf(" --domain DOMAIN - Domain for HTTPS (optional)\n") fmt.Printf(" --domain DOMAIN - Domain for HTTPS (optional)\n")
fmt.Printf(" --branch BRANCH - Git branch to use (main or nightly, default: main)\n") fmt.Printf(" --branch BRANCH - Git branch to use (main or nightly, default: main)\n")
fmt.Printf(" --ignore-resource-checks - Skip disk/RAM/CPU prerequisite validation\n")
fmt.Printf(" upgrade - Upgrade existing installation (requires root/sudo)\n") fmt.Printf(" upgrade - Upgrade existing installation (requires root/sudo)\n")
fmt.Printf(" Options:\n") fmt.Printf(" Options:\n")
fmt.Printf(" --restart - Automatically restart services after upgrade\n") fmt.Printf(" --restart - Automatically restart services after upgrade\n")
@ -101,6 +102,7 @@ func handleProdInstall(args []string) {
// Parse arguments // Parse arguments
force := false force := false
isBootstrap := false isBootstrap := false
skipResourceChecks := false
var vpsIP, domain, peersStr, bootstrapJoin, branch string var vpsIP, domain, peersStr, bootstrapJoin, branch string
for i, arg := range args { for i, arg := range args {
@ -129,6 +131,8 @@ func handleProdInstall(args []string) {
if i+1 < len(args) { if i+1 < len(args) {
branch = args[i+1] branch = args[i+1]
} }
case "--ignore-resource-checks":
skipResourceChecks = true
} }
} }
@ -164,7 +168,7 @@ func handleProdInstall(args []string) {
debrosHome := "/home/debros" debrosHome := "/home/debros"
debrosDir := debrosHome + "/.debros" debrosDir := debrosHome + "/.debros"
setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, false) setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, false, skipResourceChecks)
// Save branch preference for future upgrades // Save branch preference for future upgrades
if err := production.SaveBranchPreference(debrosDir, branch); err != nil { if err := production.SaveBranchPreference(debrosDir, branch); err != nil {
@ -279,7 +283,7 @@ func handleProdUpgrade(args []string) {
fmt.Printf(" This will preserve existing configurations and data\n") fmt.Printf(" This will preserve existing configurations and data\n")
fmt.Printf(" Configurations will be updated to latest format\n\n") fmt.Printf(" Configurations will be updated to latest format\n\n")
setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, noPull) setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, noPull, false)
// Log if --no-pull is enabled // Log if --no-pull is enabled
if noPull { if noPull {

View File

@ -18,6 +18,7 @@ type ProductionSetup struct {
logWriter io.Writer logWriter io.Writer
forceReconfigure bool forceReconfigure bool
skipOptionalDeps bool skipOptionalDeps bool
skipResourceChecks bool
privChecker *PrivilegeChecker privChecker *PrivilegeChecker
osDetector *OSDetector osDetector *OSDetector
archDetector *ArchitectureDetector archDetector *ArchitectureDetector
@ -63,7 +64,7 @@ func SaveBranchPreference(debrosDir, branch string) error {
} }
// NewProductionSetup creates a new production setup orchestrator // NewProductionSetup creates a new production setup orchestrator
func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure bool, branch string, skipRepoUpdate bool) *ProductionSetup { func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure bool, branch string, skipRepoUpdate bool, skipResourceChecks bool) *ProductionSetup {
debrosDir := debrosHome + "/.debros" debrosDir := debrosHome + "/.debros"
arch, _ := (&ArchitectureDetector{}).Detect() arch, _ := (&ArchitectureDetector{}).Detect()
@ -80,6 +81,7 @@ func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure
arch: arch, arch: arch,
branch: branch, branch: branch,
skipRepoUpdate: skipRepoUpdate, skipRepoUpdate: skipRepoUpdate,
skipResourceChecks: skipResourceChecks,
privChecker: &PrivilegeChecker{}, privChecker: &PrivilegeChecker{},
osDetector: &OSDetector{}, osDetector: &OSDetector{},
archDetector: &ArchitectureDetector{}, archDetector: &ArchitectureDetector{},
@ -157,6 +159,9 @@ func (ps *ProductionSetup) Phase1CheckPrerequisites() error {
ps.logf(" ✓ Basic dependencies available") ps.logf(" ✓ Basic dependencies available")
// Check system resources // Check system resources
if ps.skipResourceChecks {
ps.logf(" ⚠️ Skipping system resource checks (disk, RAM, CPU) due to --ignore-resource-checks flag")
} else {
if err := ps.resourceChecker.CheckDiskSpace(ps.debrosHome); err != nil { if err := ps.resourceChecker.CheckDiskSpace(ps.debrosHome); err != nil {
ps.logf(" ❌ %v", err) ps.logf(" ❌ %v", err)
return err return err
@ -174,6 +179,7 @@ func (ps *ProductionSetup) Phase1CheckPrerequisites() error {
return err return err
} }
ps.logf(" ✓ Sufficient CPU cores available") ps.logf(" ✓ Sufficient CPU cores available")
}
return nil return nil
} }