Repository: kumahq/kuma (go)

Issue:
Remove `/status/zones`
### Description

While thinking about: https://github.com/Kong/kong-mesh/issues/6655 I've discovered: https://github.com/kumahq/kuma/blob/master/pkg/api-server/zones_ws.go

It isn't used by kumactl and the GUI.
It's only present in the docs and In e2e tests.

https://github.com/kumahq/kuma/blob/8b5501bd9602335fe76044a554600aa9375de720/test/framework/k8s_controlplane.go#L330-L332

What it does it rather simple:

https://github.com/kumahq/kuma/blob/4d238e129daec34e369f207c8f13fd3af3c50871/pkg/api-server/zones_ws.go#L54

I see 2 options to remove this:

- Let people do this logic themselves
- Add an active entry in ZoneInsight. Maybe active isn't that useful and just Online inside insight is good enough

As this endpoint is niche IMO we can strip it without deprecation.



Pull request description:
chore(api-server): remove `/zones/status`
This endpoint is just a helper around `/zones/_overview`

We should prefer using the basic endpoints and avoid unecessary endpoints

fix #11505

Patch:
diff --git a/UPGRADE.md b/UPGRADE.md
index 12740429c..d0165b2d0 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -6,6 +6,12 @@ with `x.y.z` being the version you are planning to upgrade to.
 If such a section does not exist, the upgrade you want to perform
 does not have any particular instructions.
 
+## Upgrade to `2.12.x`
+
+### Removal of `/status/zones` endpoints
+
+These endpoints were deprecated, and are now removed. You can achieve the same functionality with `/zones/_overview`.
+
 ## Upgrade to `2.11.x`
 
 ### Embedded Proxy DNS is Enabled by Default
diff --git a/app/kumactl/data/install/k8s/demo/demo.yaml b/app/kumactl/data/install/k8s/demo/demo.yaml
index 9a9870fd5..769e870b6 100644
--- a/app/kumactl/data/install/k8s/demo/demo.yaml
+++ b/app/kumactl/data/install/k8s/demo/demo.yaml
@@ -22,7 +22,7 @@ spec:
     spec:
       containers:
         - name: redis
-          image: "redis@sha256:dac8ab0340cef636bf80c4d771e338733c694885567aaabd15fe1368d6bf7c13"
+          image: "redis@sha256:b43d2dcbbdb1f9e1582e3a0f37e53bf79038522ccffb56a25858969d7a9b6c11"
           ports:
             - name: tcp
               containerPort: 6379
diff --git a/app/kumactl/data/install/k8s/tracing/jaeger/all-in-one-template.yaml b/app/kumactl/data/install/k8s/tracing/jaeger/all-in-one-template.yaml
index ccdc6ba8a..32ff423ff 100644
--- a/app/kumactl/data/install/k8s/tracing/jaeger/all-in-one-template.yaml
+++ b/app/kumactl/data/install/k8s/tracing/jaeger/all-in-one-template.yaml
@@ -49,7 +49,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/pkg/api-server/server.go b/pkg/api-server/server.go
index 456302122..10832bf85 100644
--- a/pkg/api-server/server.go
+++ b/pkg/api-server/server.go
@@ -155,7 +155,6 @@ func NewApiServer(
 	addInspectEndpoints(ws, cfg, meshContextBuilder, rt.ResourceManager())
 	addInspectEnvoyAdminEndpoints(ws, cfg, rt.ResourceManager(), rt.Access().EnvoyAdminAccess, rt.EnvoyAdminClient())
 	addInspectMeshServiceEndpoints(ws, rt.ResourceManager(), rt.Access().ResourceAccess)
-	addZoneEndpoints(ws, rt.ResourceManager())
 	guiUrl := ""
 	if cfg.ApiServer.GUI.Enabled && !cfg.IsFederatedZoneCP() {
 		guiUrl = cfg.ApiServer.GUI.BasePath
diff --git a/pkg/api-server/zones_ws.go b/pkg/api-server/zones_ws.go
deleted file mode 100644
index e5fc8ac53..000000000
--- a/pkg/api-server/zones_ws.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package api_server
-
-import (
-	"context"
-
-	"github.com/emicklei/go-restful/v3"
-
-	"github.com/kumahq/kuma/pkg/core/resources/apis/system"
-	"github.com/kumahq/kuma/pkg/core/resources/manager"
-	rest_errors "github.com/kumahq/kuma/pkg/core/rest/errors"
-)
-
-type Zone struct {
-	Name   string `json:"name"`
-	Active bool   `json:"active"`
-}
-
-type Zones []Zone
-
-func addZoneEndpoints(ws *restful.WebService, resManager manager.ResourceManager) {
-	ws.Route(ws.GET("/status/zones").To(func(request *restful.Request, response *restful.Response) {
-		zoneOverviews, err := fetchOverviews(resManager, request.Request.Context())
-		if err != nil {
-			rest_errors.HandleError(request.Request.Context(), response, err, "Could not retrieve a zone overview")
-			return
-		}
-
-		if err := response.WriteAsJson(toZones(zoneOverviews)); err != nil {
-			log.Error(err, "failed marshaling response")
-		}
-	}))
-}
-
-func fetchOverviews(resManager manager.ResourceManager, ctx context.Context) (system.ZoneOverviewResourceList, error) {
-	zones := system.ZoneResourceList{}
-	if err := resManager.List(ctx, &zones); err != nil {
-		return system.ZoneOverviewResourceList{}, err
-	}
-
-	// we cannot paginate insights since there is no guarantee that the elements will be the same as dataplanes
-	insights := system.ZoneInsightResourceList{}
-	if err := resManager.List(ctx, &insights); err != nil {
-		return system.ZoneOverviewResourceList{}, err
-	}
-
-	return system.NewZoneOverviews(zones, insights), nil
-}
-
-func toZones(rlist system.ZoneOverviewResourceList) Zones {
-	var zones Zones
-	for _, overview := range rlist.Items {
-		zones = append(zones, Zone{
-			Name:   overview.GetMeta().GetName(),
-			Active: overview.Spec.GetZoneInsight().IsOnline() && overview.Spec.GetZone().IsEnabled(),
-		})
-	}
-	return zones
-}


Test patch:
diff --git a/app/kumactl/cmd/install/testdata/install-demo.defaults.golden.yaml b/app/kumactl/cmd/install/testdata/install-demo.defaults.golden.yaml
index 214c436c3..9feabfef5 100644
--- a/app/kumactl/cmd/install/testdata/install-demo.defaults.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-demo.defaults.golden.yaml
@@ -53,7 +53,7 @@ spec:
     spec:
       containers:
         - name: redis
-          image: "redis@sha256:dac8ab0340cef636bf80c4d771e338733c694885567aaabd15fe1368d6bf7c13"
+          image: "redis@sha256:b43d2dcbbdb1f9e1582e3a0f37e53bf79038522ccffb56a25858969d7a9b6c11"
           ports:
             - name: tcp
               containerPort: 6379
diff --git a/app/kumactl/cmd/install/testdata/install-demo.overrides.golden.yaml b/app/kumactl/cmd/install/testdata/install-demo.overrides.golden.yaml
index 2affb4c8e..5228cfe1e 100644
--- a/app/kumactl/cmd/install/testdata/install-demo.overrides.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-demo.overrides.golden.yaml
@@ -53,7 +53,7 @@ spec:
     spec:
       containers:
         - name: redis
-          image: "redis@sha256:dac8ab0340cef636bf80c4d771e338733c694885567aaabd15fe1368d6bf7c13"
+          image: "redis@sha256:b43d2dcbbdb1f9e1582e3a0f37e53bf79038522ccffb56a25858969d7a9b6c11"
           ports:
             - name: tcp
               containerPort: 6379
diff --git a/app/kumactl/cmd/install/testdata/install-demo.without-gateway.golden.yaml b/app/kumactl/cmd/install/testdata/install-demo.without-gateway.golden.yaml
index 6ac2ff6d8..a3943eb12 100644
--- a/app/kumactl/cmd/install/testdata/install-demo.without-gateway.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-demo.without-gateway.golden.yaml
@@ -53,7 +53,7 @@ spec:
     spec:
       containers:
         - name: redis
-          image: "redis@sha256:dac8ab0340cef636bf80c4d771e338733c694885567aaabd15fe1368d6bf7c13"
+          image: "redis@sha256:b43d2dcbbdb1f9e1582e3a0f37e53bf79038522ccffb56a25858969d7a9b6c11"
           ports:
             - name: tcp
               containerPort: 6379
diff --git a/app/kumactl/cmd/install/testdata/install-observability.defaults.golden.yaml b/app/kumactl/cmd/install/testdata/install-observability.defaults.golden.yaml
index f2ba4174e..b1641a1db 100644
--- a/app/kumactl/cmd/install/testdata/install-observability.defaults.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-observability.defaults.golden.yaml
@@ -12939,7 +12939,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/app/kumactl/cmd/install/testdata/install-observability.no-grafana.golden.yaml b/app/kumactl/cmd/install/testdata/install-observability.no-grafana.golden.yaml
index 7e36738dd..180220754 100644
--- a/app/kumactl/cmd/install/testdata/install-observability.no-grafana.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-observability.no-grafana.golden.yaml
@@ -1417,7 +1417,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/app/kumactl/cmd/install/testdata/install-observability.no-loki.golden.yaml b/app/kumactl/cmd/install/testdata/install-observability.no-loki.golden.yaml
index 2570f2abf..0c801e080 100644
--- a/app/kumactl/cmd/install/testdata/install-observability.no-loki.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-observability.no-loki.golden.yaml
@@ -12245,7 +12245,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/app/kumactl/cmd/install/testdata/install-observability.no-prometheus.golden.yaml b/app/kumactl/cmd/install/testdata/install-observability.no-prometheus.golden.yaml
index e594574f1..67c804ddd 100644
--- a/app/kumactl/cmd/install/testdata/install-observability.no-prometheus.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-observability.no-prometheus.golden.yaml
@@ -12275,7 +12275,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/app/kumactl/cmd/install/testdata/install-observability.overrides.golden.yaml b/app/kumactl/cmd/install/testdata/install-observability.overrides.golden.yaml
index 3620157a5..de1c086e1 100644
--- a/app/kumactl/cmd/install/testdata/install-observability.overrides.golden.yaml
+++ b/app/kumactl/cmd/install/testdata/install-observability.overrides.golden.yaml
@@ -12939,7 +12939,7 @@ items:
                     value: "9411"
                   - name: COLLECTOR_OTLP_ENABLED
                     value: "true"
-                image: jaegertracing/all-in-one:1.70.0@sha256:c73bec5e6220b91eeda2574ec6aabbb8232f531e6b0bd11819f53548eefa6424
+                image: jaegertracing/all-in-one:1.71.0@sha256:beb31282a9c5d0d10cb78dd168945dab9887acebb42fcc0bd738b08c36b68bc0
                 name: jaeger
                 ports:
                   - containerPort: 5775
diff --git a/test/e2e/helm/kuma_helm_deploy_global_zone.go b/test/e2e/helm/kuma_helm_deploy_global_zone.go
index e58c799c7..c30d5a1d1 100644
--- a/test/e2e/helm/kuma_helm_deploy_global_zone.go
+++ b/test/e2e/helm/kuma_helm_deploy_global_zone.go
@@ -12,9 +12,8 @@ import (
 	"github.com/gruntwork-io/terratest/modules/random"
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
-	"github.com/pkg/errors"
 
-	api_server "github.com/kumahq/kuma/pkg/api-server"
+	"github.com/kumahq/kuma/api/system/v1alpha1"
 	"github.com/kumahq/kuma/pkg/config/core"
 	"github.com/kumahq/kuma/pkg/intercp/catalog"
 	. "github.com/kumahq/kuma/test/framework"
@@ -91,30 +90,20 @@ interCp:
 	})
 
 	It("should deploy Zone and Global on 2 clusters", func() {
-		clustersStatus := api_server.Zones{}
-		Eventually(func() (bool, error) {
-			status, response := http_helper.HttpGet(c1.GetTesting(), global.GetGlobalStatusAPI(), nil)
-			if status != http.StatusOK {
-				return false, errors.Errorf("unable to contact server %s with status %d", global.GetGlobalStatusAPI(), status)
-			}
-			err := json.Unmarshal([]byte(response), &clustersStatus)
-			if err != nil {
-				return false, errors.Errorf("unable to parse response [%s] with error: %v", response, err)
-			}
-			if len(clustersStatus) != 1 {
-				return false, nil
-			}
-			return clustersStatus[0].Active, nil
-		}, "1m", "1s").Should(BeTrue())
-
-		// then
-		active := true
-		for _, cluster := range clustersStatus {
-			if !cluster.Active {
-				active = false
-			}
+		type overviewOutput struct {
+			Items []v1alpha1.ZoneOverview `json:"items"`
 		}
-		Expect(active).To(BeTrue())
+		zoneOverviews := overviewOutput{}
+		Eventually(func(g Gomega) {
+			path := fmt.Sprintf("%s/zones/_overview", global.GetAPIServerAddress())
+			status, response := http_helper.HttpGet(c1.GetTesting(), path, nil)
+			g.Expect(status).To(Equal(http.StatusOK), "unable to contact server %q", path)
+			err := json.Unmarshal([]byte(response), &zoneOverviews)
+			g.Expect(err).ToNot(HaveOccurred(), "unable to parse response %q with error: %v", response, err)
+			g.Expect(zoneOverviews.Items).To(HaveLen(1))
+			g.Expect(zoneOverviews.Items[0].GetZoneInsight().IsOnline()).To(BeTrue())
+			g.Expect(zoneOverviews.Items[0].GetZone().IsEnabled()).To(BeTrue())
+		}, "1m", "1s").Should(Succeed())
 
 		// and dataplanes are synced to global
 		Eventually(func() string {
diff --git a/test/framework/interface.go b/test/framework/interface.go
index e688d7796..4ffbb0e27 100644
--- a/test/framework/interface.go
+++ b/test/framework/interface.go
@@ -645,7 +645,6 @@ type ControlPlane interface {
 	GetKDSServerAddress() string
 	GetKDSInsecureServerAddress() string
 	GetXDSServerAddress() string
-	GetGlobalStatusAPI() string
 	GetAPIServerAddress() string
 	GenerateDpToken(mesh, serviceName string) (string, error)
 	GenerateZoneIngressToken(zone string) (string, error)
diff --git a/test/framework/k8s_controlplane.go b/test/framework/k8s_controlplane.go
index 8a95b8d06..c586fe83b 100644
--- a/test/framework/k8s_controlplane.go
+++ b/test/framework/k8s_controlplane.go
@@ -144,7 +144,7 @@ func (c *K8sControlPlane) VerifyKumaREST() error {
 	_, err := http_helper.HTTPDoWithRetryE(
 		c.t,
 		"GET",
-		c.GetGlobalStatusAPI(),
+		c.GetAPIServerAddress()+"/zones/_overview",
 		nil,
 		headers,
 		http.StatusOK,
@@ -325,10 +325,6 @@ func (c *K8sControlPlane) Exec(cmd ...string) (string, string, error) {
 	return c.cluster.Exec(pod.Namespace, pod.Name, "", cmd...)
 }
 
-func (c *K8sControlPlane) GetGlobalStatusAPI() string {
-	return c.GetAPIServerAddress() + "/status/zones"
-}
-
 func (c *K8sControlPlane) generateToken(
 	tokenPath string,
 	data string,
diff --git a/test/framework/universal_controlplane.go b/test/framework/universal_controlplane.go
index 0ab9f1c1c..4cb191022 100644
--- a/test/framework/universal_controlplane.go
+++ b/test/framework/universal_controlplane.go
@@ -87,10 +87,6 @@ func (c *UniversalControlPlane) getKDSServerAddress(secure bool) string {
 	return protocol + "://" + net.JoinHostPort(c.cpNetworking.IP, "5685")
 }
 
-func (c *UniversalControlPlane) GetGlobalStatusAPI() string {
-	panic("not implemented")
-}
-
 func (c *UniversalControlPlane) GetAPIServerAddress() string {
 	return "http://localhost:" + c.cpNetworking.ApiServerPort
 }