Skip to content

Commit

Permalink
Merge pull request #1099 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1098-to-v1.3.x

[v1.3.x] Return error id OpenStackNet misses OpenStackNetConfig owner ref
  • Loading branch information
openshift-merge-bot[bot] authored Oct 24, 2024
2 parents 0435510 + 99fddee commit 7b930b5
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 7b930b5

Please sign in to comment.