Skip to content

Commit

Permalink
Merge pull request #1100 from stuggi/fix_is_osclient_owner
Browse files Browse the repository at this point in the history
Make IPSet OSclient owner check more robust
  • Loading branch information
openshift-merge-bot[bot] authored Oct 29, 2024
2 parents 8be5a74 + e1481a1 commit 905b90c
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions controllers/openstacknetconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,30 +1228,19 @@ func (r *OpenStackNetConfigReconciler) ensureIPReservation(
//
// For backward compatability check if owning object is osClient and set Role to <openstackclient.Role><instance.Name>
//
osClient := &ospdirectorv1beta1.OpenStackClient{}
err := r.Get(ctx, types.NamespacedName{
Name: osIPset.Labels[common.OwnerNameLabelSelector],
Namespace: osIPset.Namespace},
osClient)
if err != nil {
if !k8s_errors.IsNotFound(err) {
cond.Message = fmt.Sprintf("Failed to get %s %s ", osClient.Kind, osIPset.Labels[common.OwnerNameLabelSelector])
cond.Reason = shared.OsClientCondReasonError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)

return nil, err
for _, ref := range osIPset.GetOwnerReferences() {
if ref.Controller != nil &&
*ref.Controller && ref.Kind == "OpenStackClient" {
roleName = fmt.Sprintf("%s%s", openstackclient.Role, osIPset.Spec.RoleName)
}
} else {
roleName = fmt.Sprintf("%s%s", openstackclient.Role, osIPset.Spec.RoleName)
}

allRoles[roleName] = true

//
// are there new networks added to the CR?
//
err = r.ensureIPs(
err := r.ensureIPs(
instance,
cond,
osNet,
Expand Down

0 comments on commit 905b90c

Please sign in to comment.