@@ -25,6 +25,7 @@ import (
25
25
"k8s.io/client-go/tools/cache"
26
26
"k8s.io/client-go/util/workqueue"
27
27
28
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
28
29
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
29
30
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
30
31
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
@@ -595,11 +596,11 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
595
596
})
596
597
597
598
// ensure the installplan reference is correct
598
- sub , changedIp , err := o .ensureSubscriptionInstallPlanState (logger , sub )
599
+ sub , changedIP , err := o .ensureSubscriptionInstallPlanState (logger , sub )
599
600
if err != nil {
600
601
return err
601
602
}
602
- subscriptionUpdated = subscriptionUpdated || changedIp
603
+ subscriptionUpdated = subscriptionUpdated || changedIP
603
604
604
605
// record the current state of the desired corresponding CSV in the status. no-op if we don't know the csv yet.
605
606
sub , changedCSV , err := o .ensureSubscriptionCSVState (logger , sub , querier )
@@ -756,8 +757,15 @@ func (o *Operator) ensureSubscriptionInstallPlanState(logger *logrus.Entry, sub
756
757
logger .WithField ("installplan" , ipName ).Debug ("found installplan that generated subscription" )
757
758
758
759
out := sub .DeepCopy ()
759
- out .Status .Install = o .referenceForInstallPlan (ip )
760
+ ref , err := operators .GetReference (ip )
761
+ if err != nil {
762
+ logger .WithError (err ).Warn ("unable to generate installplan reference" )
763
+ return nil , false , err
764
+ }
765
+ out .Status .InstallPlanRef = ref
766
+ out .Status .Install = v1alpha1 .NewInstallPlanReference (ref )
760
767
out .Status .State = v1alpha1 .SubscriptionStateUpgradePending
768
+
761
769
updated , err := o .client .OperatorsV1alpha1 ().Subscriptions (sub .GetNamespace ()).UpdateStatus (out )
762
770
if err != nil {
763
771
return nil , false , err
@@ -807,13 +815,14 @@ func (o *Operator) ensureSubscriptionCSVState(logger *logrus.Entry, sub *v1alpha
807
815
return sub , true , nil
808
816
}
809
817
810
- func (o * Operator ) updateSubscriptionStatus (namespace string , subs []* v1alpha1.Subscription , installPlanRef * v1alpha1. InstallPlanReference ) error {
818
+ func (o * Operator ) updateSubscriptionStatus (namespace string , subs []* v1alpha1.Subscription , installPlanRef * corev1. ObjectReference ) error {
811
819
// TODO: parallel, sync waitgroup
812
820
var err error
813
821
for _ , sub := range subs {
814
822
sub .Status .LastUpdated = timeNow ()
815
823
if installPlanRef != nil {
816
- sub .Status .Install = installPlanRef
824
+ sub .Status .InstallPlanRef = installPlanRef
825
+ sub .Status .Install = v1alpha1 .NewInstallPlanReference (installPlanRef )
817
826
sub .Status .State = v1alpha1 .SubscriptionStateUpgradePending
818
827
}
819
828
if _ , subErr := o .client .OperatorsV1alpha1 ().Subscriptions (namespace ).UpdateStatus (sub ); subErr != nil {
@@ -823,7 +832,7 @@ func (o *Operator) updateSubscriptionStatus(namespace string, subs []*v1alpha1.S
823
832
return err
824
833
}
825
834
826
- func (o * Operator ) ensureInstallPlan (logger * logrus.Entry , namespace string , subs []* v1alpha1.Subscription , installPlanApproval v1alpha1.Approval , steps []* v1alpha1.Step ) (* v1alpha1. InstallPlanReference , error ) {
835
+ func (o * Operator ) ensureInstallPlan (logger * logrus.Entry , namespace string , subs []* v1alpha1.Subscription , installPlanApproval v1alpha1.Approval , steps []* v1alpha1.Step ) (* corev1. ObjectReference , error ) {
827
836
if len (steps ) == 0 {
828
837
return nil , nil
829
838
}
@@ -837,15 +846,15 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, sub
837
846
for _ , installPlan := range installPlans {
838
847
if installPlan .Status .CSVManifestsMatch (steps ) {
839
848
logger .Infof ("found InstallPlan with matching manifests: %s" , installPlan .GetName ())
840
- return o . referenceForInstallPlan (installPlan ), nil
849
+ return operators . GetReference (installPlan )
841
850
}
842
851
}
843
852
logger .Warn ("no installplan found with matching manifests, creating new one" )
844
853
845
854
return o .createInstallPlan (namespace , subs , installPlanApproval , steps )
846
855
}
847
856
848
- func (o * Operator ) createInstallPlan (namespace string , subs []* v1alpha1.Subscription , installPlanApproval v1alpha1.Approval , steps []* v1alpha1.Step ) (* v1alpha1. InstallPlanReference , error ) {
857
+ func (o * Operator ) createInstallPlan (namespace string , subs []* v1alpha1.Subscription , installPlanApproval v1alpha1.Approval , steps []* v1alpha1.Step ) (* corev1. ObjectReference , error ) {
849
858
if len (steps ) == 0 {
850
859
return nil , nil
851
860
}
@@ -896,17 +905,8 @@ func (o *Operator) createInstallPlan(namespace string, subs []*v1alpha1.Subscrip
896
905
if err != nil {
897
906
return nil , err
898
907
}
899
- return o .referenceForInstallPlan (res ), nil
900
908
901
- }
902
-
903
- func (o * Operator ) referenceForInstallPlan (ip * v1alpha1.InstallPlan ) * v1alpha1.InstallPlanReference {
904
- return & v1alpha1.InstallPlanReference {
905
- UID : ip .GetUID (),
906
- Name : ip .GetName (),
907
- APIVersion : v1alpha1 .SchemeGroupVersion .String (),
908
- Kind : v1alpha1 .InstallPlanKind ,
909
- }
909
+ return operators .GetReference (res )
910
910
}
911
911
912
912
func (o * Operator ) requeueSubscription (name , namespace string ) {
0 commit comments