devzone 0.50.3 → 0.50.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.
@@ -46,6 +46,10 @@ if [ -f "$ICI/argocd/conf.sh" ]; then
46
46
  ARGOCD_CONF="$RACINE/.argocd.conf"
47
47
  . "$ICI/argocd/conf.sh"
48
48
  fi
49
+ # GitOps repository line in the Kubernetes workspace pod (#639)
50
+ # shellcheck source=SCRIPTDIR/etat-gitops.sh
51
+ # shellcheck disable=SC1091
52
+ . "$ICI/etat-gitops.sh"
49
53
 
50
54
  # Assistants IA, versions figées : mettre à jour ici, puis devzone apply
51
55
  # (ou Rebuild Container). Une ligne par paquet, séparées par une ligne qui ne
@@ -1253,6 +1257,8 @@ etat() {
1253
1257
  argocd_repo="$(conf_get argocd repo)"
1254
1258
  if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
1255
1259
  printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
1260
+ elif dans_pod; then
1261
+ gitops_state_line
1256
1262
  else
1257
1263
  printf ' ○ argocd no GitOps repository: devzone argocd init\n'
1258
1264
  fi
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ # GitOps repository line of the state in the Kubernetes workspace pod (#639).
3
+ # The pod has no kubeconfig and its service account cannot read Applications
4
+ # today: one short read of the root Application tells whether Argo CD manages
5
+ # the cluster from Git; a refusal or an absence falls back to the workstation
6
+ # state. Sourced by devzone, called only when dans_pod is true.
7
+
8
+ # Namespace of the Argo CD of devzone: GITOPS_NS when the includer knows it
9
+ # (argocd/gitops.sh), otherwise the namespace of the module.
10
+ : "${GITOPS_NS:=devzone-argocd}"
11
+
12
+ # State line of the GitOps repository: the URL of the root Application when
13
+ # the pod can read it, otherwise the workstation command that shows the state
14
+ gitops_state_line() {
15
+ local url
16
+ url="$(kubectl get application devzone -n "$GITOPS_NS" \
17
+ -o jsonpath='{.spec.source.repoURL}' --request-timeout=5s 2>/dev/null || true)"
18
+ if [ -n "$url" ]; then
19
+ printf ' ○ argocd GitOps repository: %s\n' "$url"
20
+ else
21
+ printf ' ○ argocd managed from the workstation: devzone workspace argocd status\n'
22
+ fi
23
+ }
@@ -3,7 +3,9 @@
3
3
  # Sourced by ports-workspace.sh, never run alone. One kubectl get svc -A per
4
4
  # round: each TCP port of each Service gets a local port, kept stable in
5
5
  # .devzone.ports-workspace/apps/<namespace>.<service>.<port> while the Service
6
- # exists. Output lines: "portlocal|namespace|svc/name|remoteport", as pw_services.
6
+ # exists. Only Services with a ready endpoint are relayed (#638): the others keep
7
+ # their local port and show as "no ready pod" in status. Output lines:
8
+ # "portlocal|namespace|svc/name|remoteport", as pw_services.
7
9
 
8
10
  PA_MAX=30
9
11
  # Namespaces never relayed: system ones, and those of the devzone modules
@@ -15,6 +17,20 @@ pa_discover() {
15
17
  pw_kubectl get svc -A -o 'jsonpath={range .items[*]}{.metadata.namespace}|{.metadata.name}|{.spec.clusterIP}|{.spec.type}|{.metadata.annotations.devzone\.io/relay}|{range .spec.ports[*]}{.port}/{.protocol},{end}{"\n"}{end}' 2>/dev/null
16
18
  }
17
19
 
20
+ # Services with a ready endpoint, as " namespace/name " items, from one kubectl get
21
+ # endpointslices call. A Service with several slices is ready if one of its slices has
22
+ # a ready endpoint. Exit 1 if the call fails: the caller then relays every Service.
23
+ pa_ready() {
24
+ local out ns name conds set=" "
25
+ out="$(pw_kubectl get endpointslices -A -o 'jsonpath={range .items[*]}{.metadata.namespace}|{.metadata.labels.kubernetes\.io/service-name}|{range .endpoints[*]}{.conditions.ready},{end}{"\n"}{end}' 2>/dev/null)" || return 1
26
+ while IFS='|' read -r ns name conds; do
27
+ [ -n "$ns" ] || continue
28
+ [ -n "$name" ] || continue
29
+ case "$conds" in *true*) set="$set$ns/$name " ;; esac
30
+ done <<<"$out"
31
+ echo "$set"
32
+ }
33
+
18
34
  # Is the Service excluded? $1 namespace, $2 name, $3 clusterIP, $4 type, $5 relay annotation.
19
35
  pa_excluded() {
20
36
  case "$PA_NS_SKIP" in *" $1 "*) return 0 ;; esac
@@ -53,14 +69,26 @@ pa_new() {
53
69
  }
54
70
 
55
71
  # One round of applications, from the ports already wanted "$1" (services, pod).
56
- # Prints the relay lines; writes apps/ (stable local port) and plafond/ (cap marker),
57
- # removes the state of Services gone, warns once per port over the cap of PA_MAX.
72
+ # Prints the relay lines; writes apps/ (stable local port), plafond/ (cap marker) and
73
+ # no-ready-pod/ (Service without ready endpoint, not relayed nor counted), removes the
74
+ # state of Services gone, warns once per port over the cap of PA_MAX.
58
75
  pa_round() {
59
76
  local d used excl ns name ip type annot ports pp port key stored loc n=0 seen="" f
77
+ local ready="" ready_ok=1 unready
60
78
  d="$(pw_dir)"
61
79
  mkdir -p "$d/apps" "$d/plafond"
62
80
  excl="$(grep -E '^ports_exclus=' .devzone.modules 2>/dev/null | tail -1 | cut -d= -f2- | tr ',' ' ')"
63
81
  used=" $1 $excl "
82
+ # One kubectl call per round. If it fails, every Service is relayed, warned once.
83
+ if ready="$(pa_ready)"; then
84
+ rm -f "$d/endpoints-unreadable"
85
+ else
86
+ ready_ok=0
87
+ if [ ! -e "$d/endpoints-unreadable" ]; then
88
+ : >"$d/endpoints-unreadable"
89
+ echo "⚠ endpointslices unreadable, ready pods not checked" >&2
90
+ fi
91
+ fi
64
92
  while IFS='|' read -r ns name ip type annot ports; do
65
93
  [ -n "$ns" ] || continue
66
94
  pa_excluded "$ns" "$name" "$ip" "$type" "$annot" && continue
@@ -78,6 +106,16 @@ pa_round() {
78
106
  fi
79
107
  used="$used $loc "
80
108
  [ "$loc" = "$stored" ] || printf '%s' "$loc" >"$d/apps/$key"
109
+ unready=0
110
+ if [ "$ready_ok" -eq 1 ]; then
111
+ case "$ready" in *" $ns/$name "*) ;; *) unready=1 ;; esac
112
+ fi
113
+ if [ "$unready" -eq 1 ]; then
114
+ mkdir -p "$d/no-ready-pod"
115
+ : >"$d/no-ready-pod/$key"
116
+ continue
117
+ fi
118
+ rm -f "$d/no-ready-pod/$key"
81
119
  if [ "$n" -lt "$PA_MAX" ]; then
82
120
  n=$((n + 1))
83
121
  rm -f "$d/plafond/$key"
@@ -88,13 +126,14 @@ pa_round() {
88
126
  fi
89
127
  done
90
128
  done <<<"$(pa_discover)"
91
- for f in "$d"/apps/* "$d"/plafond/*; do
129
+ for f in "$d"/apps/* "$d"/plafond/* "$d"/no-ready-pod/*; do
92
130
  [ -e "$f" ] || continue
93
131
  case "$seen" in *" $(basename "$f") "*) ;; *) rm -f "$f" ;; esac
94
132
  done
95
133
  }
96
134
 
97
135
  # Status lines of relayed applications: local URL, then namespace/service:port.
136
+ # Then the Services without ready pod, with the local URL they would get.
98
137
  pa_status() {
99
138
  local d f key rest loc
100
139
  d="$(pw_dir)"
@@ -106,4 +145,12 @@ pa_status() {
106
145
  rest="${key#*.}"
107
146
  echo " http://127.0.0.1:$loc ${key%%.*}/${rest%%.*}:${rest#*.}"
108
147
  done
148
+ for f in "$d"/no-ready-pod/*; do
149
+ [ -e "$f" ] || continue
150
+ key="$(basename "$f")"
151
+ loc="$(cat "$d/apps/$key" 2>/dev/null || true)"
152
+ [ -n "$loc" ] || continue
153
+ rest="${key#*.}"
154
+ echo " http://127.0.0.1:$loc ${key%%.*}/${rest%%.*}:${rest#*.} no ready pod"
155
+ done
109
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.50.3",
3
+ "version": "0.50.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": {