func (rs *PodAutoscalerStatus) CanScaleToZero(gracePeriod time.Duration) bool {
	if cond := rs.GetCondition(PodAutoscalerConditionActive); cond != nil {
		switch cond.Status {
		case corev1.ConditionFalse:
			return time.Now().After(cond.LastTransitionTime.Inner.Add(gracePeriod))
		}
	}
	return false
}
CanScaleToZero checks whether the pod autoscaler has been in an inactive state
for at least the specified grace period.
package v1alpha1
import (
	"strconv"
	"time"
	autoscalingv1 "k8s.io/api/autoscaling/v1"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"github.com/knative/pkg/apis"
	duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
	"github.com/knative/serving/pkg/apis/autoscaling"
	servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
)
type PodAutoscaler struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec PodAutoscalerSpec `json:"spec,omitempty"`
	Status PodAutoscalerStatus `json:"status,omitempty"`
}
var _ apis.Validatable = (*PodAutoscaler)(nil)
var _ apis.Defaultable = (*PodAutoscaler)(nil)
var _ apis.Immutable = (*PodAutoscaler)(nil)
var _ duckv1alpha1.ConditionsAccessor = (*PodAutoscalerStatus)(nil)
type PodAutoscalerSpec struct {
	Generation int64 `json:"generation,omitempty"`
	ConcurrencyModel servingv1alpha1.RevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"`
	ContainerConcurrency servingv1alpha1.RevisionContainerConcurrencyType `json:"containerConcurrency,omitempty"`
	ScaleTargetRef autoscalingv1.CrossVersionObjectReference `json:"scaleTargetRef"`
	ServiceName string `json:"serviceName"`
}
const (
	PodAutoscalerConditionReady = duckv1alpha1.ConditionReady
	PodAutoscalerConditionActive duckv1alpha1.ConditionType = "Active"
)
var podCondSet = duckv1alpha1.NewLivingConditionSet(PodAutoscalerConditionActive)
type PodAutoscalerStatus struct {
	Conditions duckv1alpha1.Conditions `json:"conditions,omitempty"`
}
type PodAutoscalerList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`
	Items []PodAutoscaler `json:"items"`
}
func (kpa *PodAutoscaler) scaleBoundInt32(key string) int32 {
	if s, ok := kpa.Annotations[key]; ok {
		i, _ := strconv.ParseInt(s, 10, 32)
		return int32(i)
	}
	return 0
}
func (kpa *PodAutoscaler) ScaleBounds() (min, max int32) {
	min = kpa.scaleBoundInt32(autoscaling.MinScaleAnnotationKey)
	max = kpa.scaleBoundInt32(autoscaling.MaxScaleAnnotationKey)
	return
}
func (rs *PodAutoscalerStatus) IsReady() bool {
	return podCondSet.Manage(rs).IsHappy()
}
func (rs *PodAutoscalerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition {
	return podCondSet.Manage(rs).GetCondition(t)
}
func (rs *PodAutoscalerStatus) InitializeConditions() {
	podCondSet.Manage(rs).InitializeConditions()
}
func (rs *PodAutoscalerStatus) MarkActive() {
	podCondSet.Manage(rs).MarkTrue(PodAutoscalerConditionActive)
}
func (rs *PodAutoscalerStatus) MarkActivating(reason, message string) {
	podCondSet.Manage(rs).MarkUnknown(PodAutoscalerConditionActive, reason, message)
}
func (rs *PodAutoscalerStatus) MarkInactive(reason, message string) {
	podCondSet.Manage(rs).MarkFalse(PodAutoscalerConditionActive, reason, message)
}