Skip to content

Commit 9a00f63

Browse files
authored
Avoid OwnerRef on cluster-scoped resources in all cases (#435)
1 parent 22133f0 commit 9a00f63

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

marketplace/deployer_util/set_ownership.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def main():
8181
action="store_true",
8282
help="Do not look for Application resource to determine "
8383
"what kinds to include. I.e. set owner references for "
84-
"all of the resources in the manifests")
84+
"all of the (namespaced) resources in the manifests")
8585
args = parser.parse_args()
8686

8787
resources = []
@@ -107,7 +107,6 @@ def main():
107107
kinds = map(lambda x: x["kind"], apps[0]["spec"].get("componentKinds", []))
108108

109109
excluded_kinds = ["PersistentVolumeClaim", "Application"]
110-
excluded_kinds.extend(_CLUSTER_SCOPED_KINDS)
111110
included_kinds = [kind for kind in kinds if kind not in excluded_kinds]
112111
else:
113112
included_kinds = None
@@ -136,6 +135,12 @@ def dump(outfile, resources, included_kinds, app_name, app_uid,
136135
app_api_version):
137136
to_be_dumped = []
138137
for resource in resources:
138+
if resource["kind"] in _CLUSTER_SCOPED_KINDS:
139+
# Cluster-scoped resources cannot be owned by a namespaced resource:
140+
# https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents
141+
log.info("Application '{:s}' does not own cluster-scoped '{:s}/{:s}'",
142+
app_name, resource["kind"], resource["metadata"]["name"])
143+
continue
139144
if included_kinds is None or resource["kind"] in included_kinds:
140145
log.info("Application '{:s}' owns '{:s}/{:s}'", app_name,
141146
resource["kind"], resource["metadata"]["name"])

0 commit comments

Comments
 (0)