fix: proxmox client relit la config DB à chaque requête (token update sans redémarrage)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
enzo 2026-03-21 00:39:19 +01:00
parent c0dff6d86f
commit c6028b6951

View file

@ -58,16 +58,14 @@ func (h *ProxmoxHandler) initClient() {
log.Printf("[proxmox/init] Impossible de déchiffrer le token : %v", err) log.Printf("[proxmox/init] Impossible de déchiffrer le token : %v", err)
return return
} }
log.Printf("[proxmox/init] Client initialisé — url=%s", url)
h.client = proxmox.NewClient(url, token) h.client = proxmox.NewClient(url, token)
} }
// GetResources retourne la liste de toutes les ressources Proxmox (LXC + VM + nodes). // GetResources retourne la liste de toutes les ressources Proxmox (LXC + VM + nodes).
// GET /api/proxmox/resources // GET /api/proxmox/resources
func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) { func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) {
if h.client == nil { // Toujours relire la config (prend en compte les mises à jour du token sans redémarrage)
h.initClient() h.initClient()
}
if h.client == nil { if h.client == nil {
JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable) JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable)
return return
@ -86,9 +84,7 @@ func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) {
// GetLXC retourne uniquement les conteneurs LXC. // GetLXC retourne uniquement les conteneurs LXC.
// GET /api/proxmox/lxc // GET /api/proxmox/lxc
func (h *ProxmoxHandler) GetLXC(w http.ResponseWriter, r *http.Request) { func (h *ProxmoxHandler) GetLXC(w http.ResponseWriter, r *http.Request) {
if h.client == nil { h.initClient()
h.initClient()
}
if h.client == nil { if h.client == nil {
JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable) JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable)
return return