Skip to content

Commit

Permalink
Loop through ownerReferences to find the rollout reference.
Browse files Browse the repository at this point in the history
If we pass belongs to rollout check, we know there is a rollout to find.

Signed-off-by: mitchell amihod <4623+meeech@users.noreply.github.com>
  • Loading branch information
meeech committed Feb 11, 2025
1 parent 3dd8af0 commit 15a0992
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion experiments/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,13 @@ func (ec *experimentContext) reconcileAnalysisRun(analysis v1alpha1.ExperimentAn
// This makes sure the rollout gets the Analysis Run events, which will then trigger any subscribed notifications
// #4009
if experimentutil.BelongsToRollout(ec.ex) {
roRef := ec.ex.OwnerReferences[0]
var roRef metav1.OwnerReference
for _, owner := range ec.ex.OwnerReferences {
if owner.Kind == "Rollout" {
roRef = owner
}
}

rollout, err := ec.argoProjClientset.ArgoprojV1alpha1().Rollouts(ec.ex.Namespace).Get(context.TODO(), roRef.Name, metav1.GetOptions{})
if err != nil {
ec.log.Warnf("Failed to get parent Rollout of the Experiment '%s': %v", roRef.Name, err)
Expand Down
7 changes: 6 additions & 1 deletion utils/experiment/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ func BelongsToRollout(experiment *v1alpha1.Experiment) bool {
return false
}

return experiment.OwnerReferences[0].Kind == "Rollout"
for _, owner := range experiment.OwnerReferences {
if owner.Kind == "Rollout" {
return true
}
}
return false
}

func HasFinished(experiment *v1alpha1.Experiment) bool {
Expand Down

0 comments on commit 15a0992

Please sign in to comment.