diff --git a/pkg/reconciler/common/common.go b/pkg/reconciler/common/common.go index 7e93ba547..faaa501cd 100644 --- a/pkg/reconciler/common/common.go +++ b/pkg/reconciler/common/common.go @@ -43,8 +43,7 @@ func PipelineReady(informer informer.TektonPipelineInformer) (*v1alpha1.TektonPi } return nil, err } - readyCondition := ppln.GetStatus().GetCondition(apis.ConditionReady) - if readyCondition != nil && strings.Contains(readyCondition.Message, v1alpha1.UpgradePending) { + if isUpgradePending(ppln.GetStatus()) { return nil, v1alpha1.DEPENDENCY_UPGRADE_PENDING_ERR } if !ppln.Status.IsReady() { @@ -53,6 +52,18 @@ func PipelineReady(informer informer.TektonPipelineInformer) (*v1alpha1.TektonPi return ppln, nil } +// isUpgradePending checks if the component status indicates an upgrade is pending +func isUpgradePending(status v1alpha1.TektonComponentStatus) bool { + if status == nil { + return false + } + readyCondition := status.GetCondition(apis.ConditionReady) + if readyCondition == nil { + return false + } + return strings.Contains(readyCondition.Message, v1alpha1.UpgradePending) +} + func PipelineTargetNamspace(informer informer.TektonPipelineInformer) (string, error) { ppln, err := getPipelineRes(informer) if err != nil {