devzone 0.36.4 → 0.36.5

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.
@@ -62,14 +62,23 @@ voulu() {
62
62
  [ "$v" = on ] && echo on || echo off
63
63
  }
64
64
 
65
- # Application présente dans le cluster : namespace étiqueté et StatefulSet du
66
- # nom de l'application ; sans cluster choisi ou absente : rien. Lecture des
67
- # namespaces réservée à l'administrateur (#430).
65
+ # Application present in the cluster. In the Kubernetes workspace pod: its
66
+ # service resolves in the cluster DNS (no RBAC needed, #515). Elsewhere: labelled
67
+ # namespace and StatefulSet of the app name; reading the namespaces is reserved
68
+ # to the administrator (#430). Nothing without a chosen cluster or when absent.
68
69
  presente() {
69
70
  local ctx ns
71
+ ns="$(app_ns "$1")"
72
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
73
+ # In the pod there is no kubeconfig and the limited service account
74
+ # cannot list StatefulSets (#430): presence is the cluster DNS
75
+ # resolving the service, no RBAC needed, the pod service account
76
+ # stays limited
77
+ getent hosts "$(app_lire "$1" nom).${ns}.svc" >/dev/null 2>&1
78
+ return
79
+ fi
70
80
  ctx="$(cluster_lu)"
71
81
  [ -n "$ctx" ] || return 1
72
- ns="$(app_ns "$1")"
73
82
  compte_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 &&
74
83
  kubectl --context devzone -n "$ns" get statefulset "$1" >/dev/null 2>&1
75
84
  }
@@ -142,6 +151,10 @@ catalogue_lister() {
142
151
  # Relais de l application installee : etat de son script, sinon pid du relais
143
152
  app_relais_arrete() {
144
153
  local app="$1" script etat
154
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
155
+ # In the pod, no relay: the access goes through the workspace ports
156
+ return 1
157
+ fi
145
158
  script="$ICI/catalogue/$app/$app.sh"
146
159
  if [ -f "$script" ]; then
147
160
  etat="$(bash "$script" etat 2>/dev/null || true)"
@@ -181,8 +194,12 @@ catalogue_resume() {
181
194
  if app_relais_arrete "$app"; then
182
195
  printf ' ⚠ application %-12s installée, relais arrêté : devzone reparer\n' "$app"
183
196
  else
184
- printf ' ✔ application %-12s installée : 127.0.0.1:%s\n' \
185
- "$app" "$(app_lire "$app" port)"
197
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
198
+ printf ' ✔ application %-12s installée : local access: devzone workspace ports\n' "$app"
199
+ else
200
+ printf ' ✔ application %-12s installée : 127.0.0.1:%s\n' \
201
+ "$app" "$(app_lire "$app" port)"
202
+ fi
186
203
  fi ;;
187
204
  attendue) printf ' ⚠ application %-12s attendue : devzone appliquer\n' "$app" ;;
188
205
  *) printf ' ✖ application %s en échec : %s : devzone appliquer\n' \
@@ -1202,13 +1202,19 @@ etat() {
1202
1202
  # Socket Docker de l'hôte (#432) : l'avertissement montre l'état réel,
1203
1203
  # le socket monté (même variable que docker-relais.sh), pas l'option :
1204
1204
  # le montage ne change qu'au make rebuild (faux rassurant en attendant)
1205
- relais_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
1206
- if [ -e "$relais_source" ] && [ "$(valeur docker-hote)" = on ]; then
1207
- printf ' ⚠ socket Docker de l hôte partagé (agents compris)\n'
1208
- elif [ -e "$relais_source" ]; then
1209
- printf ' ⚠ socket Docker de l hôte encore partagé : make rebuild sur le poste\n'
1210
- elif [ "$(valeur docker-hote)" = on ]; then
1211
- printf ' ⚠ socket Docker de l hôte absent : make rebuild sur le poste\n'
1205
+ # In the Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes), the pod has
1206
+ # no Docker host socket: no alert, the service account is the cluster access
1207
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
1208
+ printf ' ✔ workspace Kubernetes pod, service account access only (no Docker socket)\n'
1209
+ else
1210
+ relais_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
1211
+ if [ -e "$relais_source" ] && [ "$(valeur docker-hote)" = on ]; then
1212
+ printf ' ⚠ socket Docker de l hôte partagé (agents compris)\n'
1213
+ elif [ -e "$relais_source" ]; then
1214
+ printf ' ⚠ socket Docker de l hôte encore partagé : make rebuild sur le poste\n'
1215
+ elif [ "$(valeur docker-hote)" = on ]; then
1216
+ printf ' ⚠ socket Docker de l hôte absent : make rebuild sur le poste\n'
1217
+ fi
1212
1218
  fi
1213
1219
  # Applications du catalogue (#414)
1214
1220
  if [ -d "$ICI/catalogue" ]; then
@@ -161,12 +161,19 @@ etat_json() {
161
161
 
162
162
  # Option docker-hote (#432) : absente = on ; socket réellement monté
163
163
  # (même source que docker-relais.sh), peut différer jusqu'au make rebuild
164
- if [ "$(valeur docker-hote)" = on ]; then
165
- docker_hote=true
166
- fi
167
- relais_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
168
- if [ -e "$relais_source" ]; then
169
- docker_hote_actif=true
164
+ # In the Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes), the pod has
165
+ # no Docker host socket: the socket is absent (#515)
166
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
167
+ docker_hote=false
168
+ docker_hote_actif=false
169
+ else
170
+ if [ "$(valeur docker-hote)" = on ]; then
171
+ docker_hote=true
172
+ fi
173
+ relais_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
174
+ if [ -e "$relais_source" ]; then
175
+ docker_hote_actif=true
176
+ fi
170
177
  fi
171
178
 
172
179
  services_cluster="$(cluster_lu)"
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+ # Waits for the workspace pod after helm upgrade (#486, #494, #512), sourced by
3
+ # manage/workspace.sh: moved here to keep workspace.sh under 250 lines (#515).
4
+ # Uses drapeau_kubectl and drapeau_helm from workspace.sh.
5
+
6
+ # Attend le pod du workspace ; image introuvable ou pod lent sont dits clairement.
7
+ attendre_pod() {
8
+ local image="$1" attente pas debut etat evenements arch target_revision pod_revision
9
+ attente="${DEVZONE_WORKSPACE_ATTENTE:-120}"
10
+ pas="${DEVZONE_WORKSPACE_PAS:-2}"
11
+ debut="$SECONDS"
12
+ while [ $((SECONDS - debut)) -lt "$attente" ]; do
13
+ # Why: after helm upgrade the pod is still the old one; judge only the revision the StatefulSet is updating to, within the same wait bound.
14
+ # shellcheck disable=SC2046
15
+ target_revision="$(kubectl $(drapeau_kubectl) get statefulset devzone-workspace --namespace devzone-workspace -o jsonpath='{.status.updateRevision}' 2>/dev/null)" || true
16
+ # shellcheck disable=SC2046
17
+ pod_revision="$(kubectl $(drapeau_kubectl) get pod devzone-workspace-0 --namespace devzone-workspace -o jsonpath='{.metadata.labels.controller-revision-hash}' 2>/dev/null)" || true
18
+ if [ -z "$target_revision" ] || [ -z "$pod_revision" ] || [ "$target_revision" != "$pod_revision" ]; then sleep "$pas"; continue; fi
19
+ # shellcheck disable=SC2046
20
+ etat="$(kubectl $(drapeau_kubectl) get pod devzone-workspace-0 --namespace devzone-workspace \
21
+ -o jsonpath='{.status.phase} {.status.initContainerStatuses[*].state.waiting.reason} {.status.containerStatuses[*].state.waiting.reason}' 2>/dev/null)" || true
22
+ case "$etat" in
23
+ *ErrImagePull* | *ImagePullBackOff*)
24
+ # shellcheck disable=SC2046
25
+ evenements="$(kubectl $(drapeau_kubectl) get events --namespace devzone-workspace \
26
+ --field-selector involvedObject.name=devzone-workspace-0 \
27
+ -o jsonpath='{.items[*].message}' 2>/dev/null)" || true
28
+ case "$evenements" in
29
+ *"no match for platform"*)
30
+ # shellcheck disable=SC2046
31
+ arch="$(kubectl $(drapeau_kubectl) get nodes \
32
+ -o jsonpath='{.items[0].status.nodeInfo.architecture}' 2>/dev/null)" || true
33
+ echo "✖ image $image sans version pour $arch : les livraisons de devzone la publient pour amd64 et arm64." >&2
34
+ ;;
35
+ *)
36
+ echo "✖ image $image introuvable : elle est publiée à chaque livraison de devzone." >&2
37
+ ;;
38
+ esac
39
+ echo " Pour une image construite à la main : devzone workspace demarrer --image <repository:tag>" >&2
40
+ # shellcheck disable=SC2046
41
+ helm $(drapeau_helm) uninstall devzone-workspace --namespace devzone-workspace >/dev/null 2>&1 || true
42
+ return 1
43
+ ;;
44
+ Running*)
45
+ echo "✔ workspace démarré ($image)"
46
+ return 0
47
+ ;;
48
+ esac
49
+ sleep "$pas"
50
+ done
51
+ echo "⚠ pod pas encore prêt après $attente s : devzone workspace etat" >&2
52
+ return 0
53
+ }
@@ -45,55 +45,6 @@ image_par_defaut() {
45
45
  fi
46
46
  }
47
47
 
48
- # Attend le pod du workspace ; image introuvable ou pod lent sont dits clairement.
49
- attendre_pod() {
50
- local image="$1" attente pas debut etat evenements arch target_revision pod_revision
51
- attente="${DEVZONE_WORKSPACE_ATTENTE:-120}"
52
- pas="${DEVZONE_WORKSPACE_PAS:-2}"
53
- debut="$SECONDS"
54
- while [ $((SECONDS - debut)) -lt "$attente" ]; do
55
- # Why: after helm upgrade the pod is still the old one; judge only the revision the StatefulSet is updating to, within the same wait bound.
56
- # shellcheck disable=SC2046
57
- target_revision="$(kubectl $(drapeau_kubectl) get statefulset devzone-workspace --namespace devzone-workspace -o jsonpath='{.status.updateRevision}' 2>/dev/null)" || true
58
- # shellcheck disable=SC2046
59
- pod_revision="$(kubectl $(drapeau_kubectl) get pod devzone-workspace-0 --namespace devzone-workspace -o jsonpath='{.metadata.labels.controller-revision-hash}' 2>/dev/null)" || true
60
- if [ -z "$target_revision" ] || [ -z "$pod_revision" ] || [ "$target_revision" != "$pod_revision" ]; then sleep "$pas"; continue; fi
61
- # shellcheck disable=SC2046
62
- etat="$(kubectl $(drapeau_kubectl) get pod devzone-workspace-0 --namespace devzone-workspace \
63
- -o jsonpath='{.status.phase} {.status.initContainerStatuses[*].state.waiting.reason} {.status.containerStatuses[*].state.waiting.reason}' 2>/dev/null)" || true
64
- case "$etat" in
65
- *ErrImagePull* | *ImagePullBackOff*)
66
- # shellcheck disable=SC2046
67
- evenements="$(kubectl $(drapeau_kubectl) get events --namespace devzone-workspace \
68
- --field-selector involvedObject.name=devzone-workspace-0 \
69
- -o jsonpath='{.items[*].message}' 2>/dev/null)" || true
70
- case "$evenements" in
71
- *"no match for platform"*)
72
- # shellcheck disable=SC2046
73
- arch="$(kubectl $(drapeau_kubectl) get nodes \
74
- -o jsonpath='{.items[0].status.nodeInfo.architecture}' 2>/dev/null)" || true
75
- echo "✖ image $image sans version pour $arch : les livraisons de devzone la publient pour amd64 et arm64." >&2
76
- ;;
77
- *)
78
- echo "✖ image $image introuvable : elle est publiée à chaque livraison de devzone." >&2
79
- ;;
80
- esac
81
- echo " Pour une image construite à la main : devzone workspace demarrer --image <repository:tag>" >&2
82
- # shellcheck disable=SC2046
83
- helm $(drapeau_helm) uninstall devzone-workspace --namespace devzone-workspace >/dev/null 2>&1 || true
84
- return 1
85
- ;;
86
- Running*)
87
- echo "✔ workspace démarré ($image)"
88
- return 0
89
- ;;
90
- esac
91
- sleep "$pas"
92
- done
93
- echo "⚠ pod pas encore prêt après $attente s : devzone workspace etat" >&2
94
- return 0
95
- }
96
-
97
48
  # Installe ou met à jour le workspace dans le cluster.
98
49
  demarrer() {
99
50
  local depot tag image avec_image="" args=()
@@ -132,6 +83,11 @@ demarrer() {
132
83
  else
133
84
  args+=(--set "image.tag=$tag")
134
85
  fi
86
+ # latest moves at every release: an image already on the node would stay
87
+ # the old one with IfNotPresent (#515)
88
+ if [ "$tag" = latest ]; then
89
+ args+=(--set "image.pullPolicy=Always")
90
+ fi
135
91
  # shellcheck disable=SC2046
136
92
  helm $(drapeau_helm) upgrade --install devzone-workspace "$(chemin_chart)" "${args[@]}"
137
93
  attendre_pod "$image" || return 1
@@ -205,6 +161,8 @@ copier_depuis() {
205
161
  --namespace "$NAMESPACE" -c workspace
206
162
  }
207
163
 
164
+ # shellcheck source=scripts/workspace-wait.sh
165
+ . "$ICI/scripts/workspace-wait.sh"
208
166
  # shellcheck source=scripts/migrer.sh
209
167
  . "$ICI/scripts/migrer.sh"
210
168
  # shellcheck source=scripts/migrer-retour.sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.36.4",
3
+ "version": "0.36.5",
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": {