Skip to content

Chore: Remove Endpoints ownerRef workaround for fixed k8s issue #28483 #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions pkg/cache/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,7 @@ func strToUnstructured(jsonStr string) *unstructured.Unstructured {
return &unstructured.Unstructured{Object: obj}
}

var (
testCreationTime, _ = time.Parse(time.RFC3339, "2018-09-20T06:47:27Z")

testService = strToUnstructured(fmt.Sprintf(`
apiVersion: v1
kind: Service
metadata:
name: helm-guestbook
namespace: default
resourceVersion: "123"
uid: "4"
creationTimestamp: "%s"
spec:
selector:
app: guestbook
type: LoadBalancer
status:
loadBalancer:
ingress:
- hostname: localhost`, testCreationTime.UTC().Format(time.RFC3339)))
)
var testCreationTime, _ = time.Parse(time.RFC3339, "2018-09-20T06:47:27Z")

func newCluster(tb testing.TB, objs ...runtime.Object) *clusterCache {
tb.Helper()
Expand Down
8 changes: 0 additions & 8 deletions pkg/cache/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ func (c *clusterCache) resolveResourceReferences(un *unstructured.Unstructured)
gvk := un.GroupVersionKind()

switch {
// Special case for endpoint. Remove after https://github.com/kubernetes/kubernetes/issues/28483 is fixed
case gvk.Group == "" && gvk.Kind == kube.EndpointsKind && len(ownerRefs) == 0:
ownerRefs = append(ownerRefs, metav1.OwnerReference{
Name: un.GetName(),
Kind: kube.ServiceKind,
APIVersion: "v1",
})

// Special case for Operator Lifecycle Manager ClusterServiceVersion:
case gvk.Group == "operators.coreos.com" && gvk.Kind == "ClusterServiceVersion":
if un.GetAnnotations()["olm.operatorGroup"] != "" {
Expand Down
24 changes: 0 additions & 24 deletions pkg/cache/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,6 @@ func TestIsParentOfSameKindDifferentGroupAndUID(t *testing.T) {
assert.False(t, invalidParent.isParentOf(child))
}

func TestIsServiceParentOfEndPointWithTheSameName(t *testing.T) {
nonMatchingNameEndPoint := cacheTest.newResource(strToUnstructured(`
apiVersion: v1
kind: Endpoints
metadata:
name: not-matching-name
namespace: default
`))

matchingNameEndPoint := cacheTest.newResource(strToUnstructured(`
apiVersion: v1
kind: Endpoints
metadata:
name: helm-guestbook
namespace: default
`))

parent := cacheTest.newResource(testService)

assert.True(t, parent.isParentOf(matchingNameEndPoint))
assert.Equal(t, parent.Ref.UID, matchingNameEndPoint.OwnerRefs[0].UID)
assert.False(t, parent.isParentOf(nonMatchingNameEndPoint))
}

func TestIsServiceAccountParentOfSecret(t *testing.T) {
serviceAccount := cacheTest.newResource(strToUnstructured(`
apiVersion: v1
Expand Down