fence

package
v0.1.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

Fence Recorder Configuration

This directory contains shared configuration for fence recorder paths used by both the nnf-sos controller and the fence-recorder agent.

Files

  • config.go - Go package with fence directory constants for nnf-sos
  • config.py - Python module with fence directory constants for fence-agents

Usage

In nnf-sos (Go)
import "github.com/NearNodeFlash/nnf-sos/pkg/fence"

// Use the shared constants
requestDir := fence.RequestDir
responseDir := fence.ResponseDir
In fence-agents (Python)

Copy config.py to your fence-agents repository and import it:

# If installed in fence-agents/agents/lib/
from lib.fence.config import REQUEST_DIR, RESPONSE_DIR

# Or add the nnf-sos path to sys.path
import sys
sys.path.insert(0, '/path/to/nnf-sos/pkg/fence')
import config
REQUEST_DIR = config.REQUEST_DIR
RESPONSE_DIR = config.RESPONSE_DIR

Updating Paths

When you need to change the fence request/response directory paths:

  1. Update the constants in both config.go and config.py
  2. Ensure both repositories are updated together
  3. Test both the nnf-sos controller and fence agents with the new paths

Directory Structure

The fencing protocol uses two directories:

  • Request Directory (/localdisk/fence-recorder/requests): Where fence agents write JSON request files
  • Response Directory (/localdisk/fence-recorder/responses): Where nnf-sos writes JSON response files

Alternative Approaches

If you prefer a different approach to sharing configuration:

Option 1: Environment Variables

Set environment variables on both systems:

export FENCE_RECORDER_REQUEST_DIR=/localdisk/fence-recorder/requests
export FENCE_RECORDER_RESPONSE_DIR=/localdisk/fence-recorder/responses
Option 2: System Configuration File

Create /etc/nnf/fence-config.json:

{
  "request_dir": "/localdisk/fence-recorder/requests",
  "response_dir": "/localdisk/fence-recorder/responses"
}

Both Go and Python code can read this file at runtime.

Option 3: Git Submodule

Make this configuration directory a separate git repository and include it as a submodule in both nnf-sos and fence-agents.

Current Implementation

The nnf-sos controller currently uses the constants from config.go in:

  • internal/controller/nnf_node_controller.go - NnfNode controller watches both request and response directories using fsnotify
  • internal/controller/nnf_node_block_storage_controller.go - Processes fence requests and writes response files

The fence agent should import config.py to use the same paths.

Documentation

Index

Constants

View Source
const (
	// RequestDir is where fence agents write fence request files
	RequestDir = "/localdisk/fence-recorder/requests"

	// ResponseDir is where nnf-sos writes fence response files
	ResponseDir = "/localdisk/fence-recorder/responses"
)

Fence Recorder Configuration These paths are shared between nnf-sos and fence-agents repositories. If you change these values, ensure both repositories are updated.

Variables

This section is empty.

Functions

func AcknowledgeDLMFence added in v0.1.30

func AcknowledgeDLMFence(nodeName string, log logr.Logger)

AcknowledgeDLMFence acknowledges that a node has been fenced in DLM. This is necessary to unblock any pending DLM lock operations that are waiting for fencing confirmation. Without this, operations like `vgchange --lock-start` and `lvchange --activate ys` will hang.

The nodeName should be the short hostname of the fenced node (e.g., "rabbit-compute-3"). This function looks up the corosync node ID for the given hostname and calls `dlm_tool fence_ack <nodeid>` to acknowledge the fence.

This function handles all errors internally and logs them appropriately. It never fails because DLM fence acknowledgment is best-effort.

func ConfirmPacemakerFence added in v0.1.30

func ConfirmPacemakerFence(nodeName string, log logr.Logger) error

ConfirmPacemakerFence confirms a node as fenced in Pacemaker. This removes the UNCLEAN status from the node, allowing cluster operations like `pcs cluster stop` to proceed without waiting.

Types

type FenceRequest

type FenceRequest struct {
	RequestID    string    `json:"request_id"`
	Timestamp    string    `json:"timestamp"`
	Action       string    `json:"action"`
	TargetNode   string    `json:"target_node"`
	RecorderNode string    `json:"recorder_node"`
	FilePath     string    `json:"-"` // Not from JSON, added when parsing
	ReceivedAt   time.Time `json:"-"` // When we received this request, for stale cleanup
}

FenceRequest represents a fencing request written by a fence agent

type FenceResponse

type FenceResponse struct {
	RequestID       string `json:"request_id"`
	Status          string `json:"status,omitempty"` // "success" or "error"
	Success         bool   `json:"success"`
	Message         string `json:"message"`
	Timestamp       string `json:"timestamp"` // ISO 8601 timestamp
	TargetNode      string `json:"target_node"`
	Action          string `json:"action,omitempty"`
	RecorderNode    string `json:"recorder_node,omitempty"`
	ActionPerformed string `json:"action_performed,omitempty"`
}

FenceResponse represents the response written by nnf-sos after processing a fence request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL