Skip to content

Commit

Permalink
fix(olm): delete api services upon CSV deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Peeler committed Mar 7, 2019
1 parent db79dba commit 6fcc261
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/controller/operators/olm/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,25 @@ func (a *Operator) handleClusterServiceVersionDeletion(obj interface{}) {
a.csvQueueSet.Requeue(clusterServiceVersion.GetName(), namespace)
}
}

for _, desc := range clusterServiceVersion.Spec.APIServiceDefinitions.Owned {
apiServiceName := fmt.Sprintf("%s.%s", desc.Version, desc.Group)
fetched, err := a.lister.APIRegistrationV1().APIServiceLister().Get(apiServiceName)
if k8serrors.IsNotFound(err) {
continue
}
if err != nil {
logger.WithError(err).Warn("api service get failure")
}
apiServiceLabels := fetched.GetLabels()
if clusterServiceVersion.GetName() == apiServiceLabels[ownerutil.OwnerKey] && clusterServiceVersion.GetNamespace() == apiServiceLabels[ownerutil.OwnerNamespaceKey] {
logger.Infof("gcing api service %v", apiServiceName)
err := a.OpClient.DeleteAPIService(apiServiceName, &metav1.DeleteOptions{})
if err != nil {
logger.WithError(err).Warn("cannot delete orphaned api service")
}
}
}
}

func (a *Operator) removeDanglingChildCSVs(csv *v1alpha1.ClusterServiceVersion) error {
Expand Down

0 comments on commit 6fcc261

Please sign in to comment.