scobleclaw/kubeclaw/internal/controller/agent_controller.go
agent-cos 163a3333d3 feat(pkg/floxenv): add Flox environment lifecycle management package
- Activate / Deactivate via flox activate --detach (with graceful SIGTERM→SIGKILL)
- Non-privileged IsAlive process check with Linux /proc fallback
- Dev-mode stub when flox is missing or FLOXENV_DEV_MODE=1
- Unit and integration tests

Closes #16
2026-05-29 23:40:22 -07:00

51 lines
1.7 KiB
Go

package controller
import (
"context"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
kubeclawv1alpha1 "github.com/nousresearch/kubeclaw/api/v1alpha1"
)
// AgentReconciler reconciles Agent resources.
type AgentReconciler struct {
client.Client
Scheme *runtime.Scheme
}
// +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=kubeclaw.nousresearch.com,resources=agents/finalizers,verbs=update
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch
func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := log.FromContext(ctx)
var agent kubeclawv1alpha1.Agent
if err := r.Get(ctx, req.NamespacedName, &agent); err != nil {
log.Error(err, "unable to fetch Agent")
return ctrl.Result{}, client.IgnoreNotFound(err)
}
log.Info("Reconciling Agent", "agent", agent.Name)
// TODO: Build or update the agent pod from the Agent spec
// TODO: Wire judge sidecar and workflow executor sidecar
// TODO: Inject ConfigMap and Secret references
// TODO: Update AgentStatus with pod reference and conditions
return ctrl.Result{}, nil
}
func (r *AgentReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&kubeclawv1alpha1.Agent{}).
Owns(&corev1.Pod{}).
Complete(r)
}