Skip to content

Commit

Permalink
Return error id OpenStackNet misses OpenStackNetConfig owner ref
Browse files Browse the repository at this point in the history
In case of backup restore the owner ref needs to get updated by
the OpenStackNetConfig controller. If some other reconcile using
the OpenStackNet happens first, this reference is missing and e.g.
the OpenStackIPSet gets stuck waiting for IPs to be processed.

Signed-off-by: Martin Schuppert <[email protected]>
  • Loading branch information
stuggi authored and openshift-cherrypick-robot committed Oct 24, 2024
1 parent 0435510 commit 99fddee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v1beta1/common_openstacknet.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func AddOSNetConfigRefLabel(
}
}

if _, ok := labels[shared.OpenStackNetConfigReconcileLabel]; !ok {
return labels, fmt.Errorf("OpenStackNet %s misses OpenStackNetConfig owner reference", subnetName)
}

return labels, nil
}

Expand Down
12 changes: 11 additions & 1 deletion api/v1beta1/openstackipset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ var _ webhook.Validator = &OpenStackIPSet{}
func (r *OpenStackIPSet) ValidateCreate() error {
openstackipsetlog.Info("validate create", "name", r.Name)

// TODO(user): fill in your validation logic upon object creation.
//
// Fail early on create if osnetcfg ist not found
//
_, err := GetOsNetCfg(webhookClient, r.GetNamespace(), r.GetLabels()[shared.OpenStackNetConfigReconcileLabel])
if err != nil {
return fmt.Errorf("error getting OpenStackNetConfig %s - %s: %w",
r.GetLabels()[shared.OpenStackNetConfigReconcileLabel],
r.Name,
err)
}

return nil
}

Expand Down

0 comments on commit 99fddee

Please sign in to comment.