devzone 0.46.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,26 @@
1
1
  #!/usr/bin/env bash
2
- # Memory check of the services cluster (#608): a module refuses its
2
+ # Memory check of the services cluster (#608, #612): a module refuses its
3
3
  # installation when the allocatable memory of the nodes is below its minimum.
4
4
  # Sourced by the modules (gitlab, llm) and by the tests; bash 3.2 (macOS).
5
5
  # quantite_ki <quantite> Kubernetes quantity in Ki
6
- # memoire_cluster_ki sum of the allocatable memory, in Ki
6
+ # memoire_cluster_ki allocatable memory of the cluster, in Ki
7
7
  # verifier_memoire_module <module> <minimum_go> [astuce]
8
8
  # Messages in French. Return 0 when the memory is enough, 2 when it is not or
9
9
  # when the cluster is unreachable.
10
10
 
11
+ # Globals written by memoire_cluster_ki (#612) and read by
12
+ # verifier_memoire_module, which calls the function directly: a call written
13
+ # memoire="$(memoire_cluster_ki)" would run it in a subshell and lose them.
14
+ # Callers that only need the number keep using $(memoire_cluster_ki): the
15
+ # value is still printed on stdout (argocd, gitlab, llm are unaffected).
16
+ # MEMOIRE_KI same value as on stdout, in Ki
17
+ # MEMOIRE_REGLE "maximum" when every node is a kind node (the nodes share
18
+ # one VM), "somme" otherwise
19
+ MEMOIRE_KI=""
20
+ MEMOIRE_REGLE=""
21
+
11
22
  # Converts a Kubernetes memory quantity (Ki, Mi, Gi, Ti, K, M, G, bytes)
12
- # into Ki, to add the allocatable memory of the nodes.
23
+ # into Ki, to total the allocatable memory of the nodes.
13
24
  quantite_ki() {
14
25
  local q="${1:-}" nombre
15
26
  case "$q" in
@@ -29,33 +40,73 @@ quantite_ki() {
29
40
  esac
30
41
  }
31
42
 
32
- # Sum of the allocatable memory of the services cluster nodes, in Ki.
33
- # Reading the nodes is reserved to the administrator (#430).
43
+ # Allocatable memory of the services cluster nodes, in Ki. Reading the nodes
44
+ # is reserved to the administrator (#430). One kubectl call gives, per node,
45
+ # its providerID and its allocatable memory on one "<providerID>|<memory>"
46
+ # line (#612). A kind cluster runs on a single Docker daemon: its nodes share
47
+ # the memory of one VM and each of them declares the whole VM, so adding them
48
+ # up lies. When every providerID starts with "kind://" the greatest node
49
+ # memory is returned (MEMOIRE_REGLE=maximum); as soon as one node has no such
50
+ # prefix or an empty providerID the sum is returned (MEMOIRE_REGLE=somme), as
51
+ # before. Known limit, documented: k3d and minikube in Docker mode share a VM
52
+ # too but are not kind, they stay on the sum. A line without the separator
53
+ # carries the memory alone, so it is a node without providerID (sum).
34
54
  memoire_cluster_ki() {
35
- local sortie valeur total=0
55
+ local sortie ligne providerID memoire noeud total=0 max=0 n=0 tous_kind=1
56
+ MEMOIRE_KI=""
57
+ MEMOIRE_REGLE=""
36
58
  sortie="$(compte_admin "$(compte_ctx)" get nodes \
37
- -o jsonpath='{range .items[*]}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
59
+ -o jsonpath='{range .items[*]}{.spec.providerID}{"|"}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
38
60
  [ -n "$sortie" ] || return 1
39
- while IFS= read -r valeur; do
40
- [ -n "$valeur" ] || continue
41
- total=$((total + $(quantite_ki "$valeur")))
61
+ while IFS= read -r ligne; do
62
+ [ -n "$ligne" ] || continue
63
+ case "$ligne" in
64
+ *'|'*)
65
+ providerID="${ligne%%|*}"
66
+ memoire="${ligne#*|}"
67
+ ;;
68
+ *)
69
+ providerID=""
70
+ memoire="$ligne"
71
+ ;;
72
+ esac
73
+ noeud="$(quantite_ki "$memoire")"
74
+ total=$((total + noeud))
75
+ if [ "$noeud" -gt "$max" ]; then max="$noeud"; fi
76
+ case "$providerID" in
77
+ kind://*) ;;
78
+ *) tous_kind=0 ;;
79
+ esac
80
+ n=$((n + 1))
42
81
  done <<<"$sortie"
43
- echo "$total"
82
+ if [ "$n" -gt 0 ] && [ "$tous_kind" -eq 1 ]; then
83
+ MEMOIRE_REGLE="maximum"
84
+ MEMOIRE_KI="$max"
85
+ else
86
+ MEMOIRE_REGLE="somme"
87
+ MEMOIRE_KI="$total"
88
+ fi
89
+ echo "$MEMOIRE_KI"
44
90
  }
45
91
 
46
92
  # Refuses the installation of <module> under <minimum_go> GiB of allocatable
47
93
  # memory. The message says the minimum, the available memory and how to enlarge
48
94
  # the cluster; [astuce] adds an optional hint (for example --preset light).
49
- # Return 0 when the memory is enough, 2 when it is not or the cluster is
50
- # unreachable.
95
+ # On a kind cluster (#612) the available memory is the one of a single node
96
+ # and the message says so. Return 0 when the memory is enough, 2 when it is
97
+ # not or the cluster is unreachable.
51
98
  verifier_memoire_module() {
52
- local nom_module="$1" minimum_go="$2" astuce="${3:-}" memoire
53
- if ! memoire="$(memoire_cluster_ki)"; then
99
+ local nom_module="$1" minimum_go="$2" astuce="${3:-}" memoire precision=""
100
+ if ! memoire_cluster_ki >/dev/null; then
54
101
  echo "devzone : ${nom_module} : cluster des services injoignable : devzone cluster" >&2
55
102
  return 2
56
103
  fi
104
+ memoire="$MEMOIRE_KI"
105
+ if [ "$MEMOIRE_REGLE" = "maximum" ]; then
106
+ precision=" (mémoire d'un seul nœud : cluster kind, VM partagée)"
107
+ fi
57
108
  if [ "$memoire" -lt "$((minimum_go * 1048576))" ]; then
58
- echo "devzone : ${nom_module} : il faut au moins ${minimum_go} Go de mémoire allouable dans le cluster (disponible : $((memoire / 1048576)) Go) ; agrandir le cluster (Docker Desktop → Settings → Resources) puis relancer : devzone enable ${nom_module}${astuce:+ ; astuce : ${astuce}}" >&2
109
+ echo "devzone : ${nom_module} : il faut au moins ${minimum_go} Go de mémoire allouable dans le cluster (disponible : $((memoire / 1048576)) Go)${precision} ; agrandir le cluster (Docker Desktop → Settings → Resources) puis relancer : devzone enable ${nom_module}${astuce:+ ; astuce : ${astuce}}" >&2
59
110
  return 2
60
111
  fi
61
112
  return 0
package/README.md CHANGED
@@ -60,6 +60,8 @@ Mesures du 16/11/2026. Le chiffre LLM vient des valeurs du chart (non mesuré en
60
60
  | LLM modèle 7B (7 milliards de paramètres, fichier Q4_K_M) | 6 Gi | 12 Go |
61
61
  | LLM --preset light (modèle 3B) | 3 Gi demandés, 4 Gi en limite | 8 Go |
62
62
 
63
+ Sur Docker Desktop (kind), le contrôle compare le minimum à la mémoire d'un seul nœud, donc à la VM ; sur un cluster de vraies machines, à la somme des nœuds.
64
+
63
65
  - **Réglage de la RAM** :
64
66
  - **Mac** (Docker Desktop) : *Settings → Resources > Memory*. Autre méthode : modifier `MemoryMiB` dans le fichier `settings-store.json` de Docker Desktop (Docker totalement quitté sinon il réécrit la valeur).
65
67
  - **Windows** : fichier `%UserProfile%\.wslconfig` avec `[wsl2]` et `memory=<N>GB`, puis `wsl --shutdown`. WSL2 prend 50 % de la RAM par défaut.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.46.0",
3
+ "version": "0.46.1",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {