Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

feat: Implement MachineReconciler with SSH connectivity checks #4

Description

@kitsunoff

⚠️ TDD MANDATORY

Tests MUST be written BEFORE implementation code. No exceptions.

All SSH scenarios, failure modes, and state transitions must have tests written FIRST.


Description

Implement MachineReconciler that handles SSH connectivity checks and hardware scanning.

Tasks

Test First: SSH Scenarios

  • Test: SSH connection refused → Discoverable=False, reason=SSHFailed
  • Test: SSH connection timeout → Discoverable=False, reason=SSHFailed
  • Test: SSH authentication failed → Discoverable=False, reason=SSHFailed
  • Test: DNS resolution failed → Discoverable=False, reason=SSHFailed
  • Test: SSH key secret not found → Discoverable=False, reason=CredentialsMissing
  • Test: SSH connection success → Discoverable=True, Ready=True
  • Test: Machine deletion blocked by config → DeletionBlocked=True

Core Reconciler

  • Implement MachineReconciler struct with dependencies
  • Implement Reconcile() with observedGeneration updates
  • Implement SetupWithManager() with Secret watches
  • Add finalizer handling for deletion

SSH Interface

  • Define SSH Client interface for testability
  • Implement real SSH client using golang.org/x/crypto/ssh
  • Implement mock SSH client for testing
  • Handle key-based and password-based authentication
  • Implement connection timeout handling

Discovery Logic

  • Implement checkDiscoverable() with SSH connection test
  • Update Discoverable condition based on result
  • Handle various failure modes (connection refused, timeout, auth failed, DNS)
  • Emit events for state changes

Hardware Scanning

  • Write tests for hardware scan parsing
  • Implement hardware scan execution via SSH
  • Parse scan results into hardwareFacts
  • Store nixFacterResult as raw JSON
  • Schedule periodic rescans

Secret Watches

  • Write tests for Secret watch triggers
  • Register field indexes for SSH key/password secrets
  • Implement findMachinesForSecret() mapper
  • Add predicate to filter only data changes

State Machine

Undiscoverable <---> Discoverable
      |                    |
      v                    v
   Deleting            Deleting
      |                    |
      v                    v
   Deleted              Deleted

Reference

See docs/kubebuilder-migration-analysis.md sections 9, 14, 23, 24, 26.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions