Skip to content

Commit b6f997b

Browse files
authored
feat: Update to listener v1.4.0 and remove Owner field usage (#678)
- Update listener dependency from v1.3.0 to v1.4.0 - Remove Owner field from WatchEvent construction - Remove extractOwner() function and related code - Remove ownedBy annotation constant (no longer needed) - Remove errNoOwner error - Remove ReasonOwner metric constant - Remove e2e test for owner annotation validation This completes the removal of the deprecated Owner field from runtime-watcher. The Owner field was removed from listener in v1.4.0 as part of architecture refactoring. Part of #549
1 parent bbb9dae commit b6f997b

7 files changed

Lines changed: 11 additions & 63 deletions

File tree

runtime-watcher/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.25.5
55
require (
66
github.com/go-logr/logr v1.4.3
77
github.com/go-logr/zapr v1.3.0
8-
github.com/kyma-project/runtime-watcher/listener v1.3.0
8+
github.com/kyma-project/runtime-watcher/listener v1.4.0
99
github.com/prometheus/client_golang v1.23.2
1010
github.com/sethgrid/pester v1.2.0
1111
github.com/stretchr/testify v1.11.1

runtime-watcher/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2525
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2626
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
2727
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
28-
github.com/kyma-project/runtime-watcher/listener v1.3.0 h1:cpwqKSe092PB7PY9uEKovP2KHLf5xSU2ZnCQzSrEPl8=
29-
github.com/kyma-project/runtime-watcher/listener v1.3.0/go.mod h1:61P0hFo4pRHQACz4MgyXVX35Sm5zDPGaBeomB8i+30Q=
28+
github.com/kyma-project/runtime-watcher/listener v1.4.0 h1:a9mt7RqS3pDnjkbi01Hjd0dzQY4MbmcWSPf6nuVHChs=
29+
github.com/kyma-project/runtime-watcher/listener v1.4.0/go.mod h1:x4yfxqlJQVH2qQx+CMsI/CY4MQ9okWGbD3AfTDT/lP0=
3030
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
3131
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
3232
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

runtime-watcher/pkg/admissionreview/handler.go

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@ import (
2929
)
3030

3131
const (
32-
HTTPTimeout = time.Minute * 3
33-
eventEndpoint = "event"
34-
admissionError = "admission error"
35-
kcpReqFailedMsg = "kcp request failed"
36-
kcpReqSucceededMsg = "kcp request succeeded"
37-
urlPathPattern = "/validate/%s"
38-
ownedBy = "operator.kyma-project.io/owned-by"
39-
statusSubResource = "status"
40-
namespaceNameEntityCount = 2
32+
HTTPTimeout = time.Minute * 3
33+
eventEndpoint = "event"
34+
admissionError = "admission error"
35+
kcpReqFailedMsg = "kcp request failed"
36+
kcpReqSucceededMsg = "kcp request succeeded"
37+
urlPathPattern = "/validate/%s"
38+
statusSubResource = "status"
4139
)
4240

4341
var (
4442
errParseURLPath = errors.New("could not parse url path")
4543
errEmptyModule = errors.New("module name must not be empty")
46-
errNoOwner = errors.New("no owner annotation found")
4744
errInvalidSubResource = errors.New("invalid subresource")
4845
)
4946

@@ -253,13 +250,7 @@ func (h *Handler) checkForChange(resource *Resource, oldObj, obj WatchedObject)
253250
func (h *Handler) sendRequestToKcp(moduleName string, watched WatchedObject) error {
254251
h.metrics.UpdateKCPTotal()
255252

256-
owner, err := extractOwner(watched)
257-
if err != nil {
258-
return h.logAndReturnKCPErr(err, watchermetrics.ReasonOwner)
259-
}
260-
261253
watcherEvent := &listenerTypes.WatchEvent{
262-
Owner: owner,
263254
Watched: listenerTypes.ObjectKey{Namespace: watched.Namespace, Name: watched.Name},
264255
WatchedGvk: metav1.GroupVersionKind(schema.FromAPIVersionAndKind(watched.APIVersion, watched.Kind)),
265256
}
@@ -320,21 +311,6 @@ func (h *Handler) logAndReturnKCPErr(err error, reason watchermetrics.KcpErrReas
320311
return err
321312
}
322313

323-
func extractOwner(watched WatchedObject) (listenerTypes.ObjectKey, error) {
324-
if watched.Annotations == nil || watched.Annotations[ownedBy] == "" {
325-
return listenerTypes.ObjectKey{}, fmt.Errorf("%w: no '%s' annotation found for watched resource %s",
326-
errNoOwner, ownedBy, watched.NamespacedName())
327-
}
328-
ownerKey := watched.Annotations[ownedBy]
329-
ownerParts := strings.Split(ownerKey, "/")
330-
if len(ownerParts) != namespaceNameEntityCount {
331-
return listenerTypes.ObjectKey{}, fmt.Errorf("%w: annotation %s not set correctly on resource %s: %s",
332-
errNoOwner, ownedBy, watched.NamespacedName(), ownerKey)
333-
}
334-
335-
return listenerTypes.ObjectKey{Namespace: ownerParts[0], Name: ownerParts[1]}, nil
336-
}
337-
338314
func (h *Handler) getHTTPSClient() (*http.Client, error) {
339315
httpsClient := http.Client{}
340316

runtime-watcher/pkg/watchermetrics/metrics.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const (
3232
AdmissionRequestsTotal = "watcher_admission_request_total"
3333
kcpErrReasonLabel = "error_reason"
3434
ReasonSubresource KcpErrReason = "invalid-subresource"
35-
ReasonOwner KcpErrReason = "unknown-owner"
3635
ReasonKcpAddress KcpErrReason = "missing-address-or-contract"
3736
ReasonRequest KcpErrReason = "request-setup"
3837
ReasonResponse KcpErrReason = "failed-request"

runtime-watcher/tests/e2e/watcher_metrics_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,5 @@ var _ = Describe("Watcher Metrics", Ordered, func() {
5959
Should(BeNumerically("==", watchermetrics.FipsModeOnly))
6060
})
6161
})
62-
63-
It("When kyma does not have owned by annotation", func() {
64-
Eventually(AddSkipReconciliationLabelToKyma).
65-
WithContext(ctx).
66-
WithArguments(controlPlaneClient, kyma.Name, kyma.Namespace).
67-
Should(Succeed())
68-
69-
Eventually(RemoveKymaAnnotations).
70-
WithContext(ctx).
71-
WithArguments(runtimeClient, defaultRemoteKymaName, remoteNamespace).
72-
Should(Succeed())
73-
74-
By("And spec of SKR Kyma CR is changed", func() {
75-
Eventually(changeRemoteKymaChannel).
76-
WithContext(ctx).
77-
WithArguments(runtimeClient, "regular").
78-
Should(Succeed())
79-
})
80-
})
81-
82-
It("Then Watcher Failed Kcp Metric is 1", func() {
83-
Eventually(GetWatcherFailedKcpTotalMetric).
84-
WithContext(ctx).
85-
WithArguments(watchermetrics.ReasonOwner).
86-
Should(BeNumerically(">=", 1))
87-
})
8862
})
8963
})

runtime-watcher/tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/go-logr/zapr v1.3.0
1313
github.com/google/uuid v1.6.0
1414
github.com/kyma-project/lifecycle-manager/api v1.0.0
15-
github.com/kyma-project/runtime-watcher/listener v1.3.0
15+
github.com/kyma-project/runtime-watcher/listener v1.4.0
1616
github.com/kyma-project/runtime-watcher/skr v0.0.0-00010101000000-000000000000
1717
github.com/onsi/ginkgo/v2 v2.27.3
1818
github.com/onsi/gomega v1.38.3

runtime-watcher/tests/integration/handler_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ var _ = Describe("given watched resource", Ordered, func() {
144144
Name: testCase.params.watchedName,
145145
Namespace: metav1.NamespaceDefault,
146146
},
147-
Owner: listenerTypes.ObjectKey{Name: ownerName, Namespace: metav1.NamespaceDefault},
148147
WatchedGvk: metav1.GroupVersionKind(schema.FromAPIVersionAndKind(WatchedResourceAPIVersion,
149148
WatchedResourceKind)),
150149
},

0 commit comments

Comments
 (0)