func UnitDisplayStatus(unitStatus, containerStatus StatusInfo, expectWorkload bool) StatusInfo {
	if unitStatus.Status == Terminated {
		return unitStatus
	}
	if containerStatus.Status == Terminated {
		return containerStatus
	}
	if containerStatus.Status == "" {
		// No container update received from k8s yet.
		// Unit may have set status, (though final status
		// can only be active if a container status has come through).
		if isStatusModified(unitStatus) && (unitStatus.Status != Active || !expectWorkload) {
			return unitStatus
		}
		message := unitStatus.Message
		if expectWorkload {
			message = MessageWaitForContainer
		}

		// If no unit status set, assume still allocating.
		return StatusInfo{
			Status:  Waiting,
			Message: message,
			Since:   containerStatus.Since,
		}
	}
	if unitStatus.Status != Active && unitStatus.Status != Waiting && unitStatus.Status != Blocked {
		// Charm has said that there's a problem (error) or
		// it's doing something (maintenance) so we'll stick with that.
		return unitStatus
	}

	// Charm may think it's active, but as yet there's no way for it to
	// query the workload state, so we'll ensure that we only say that
	// it's active if the pod is reported as running. If not, we'll report
	// any pod error.
	switch containerStatus.Status {
	case Error, Blocked, Allocating:
		return containerStatus
	case Waiting:
		if unitStatus.Status == Active {
			return containerStatus
		}
	case Running:
		// Unit hasn't moved from initial state.
		// thumper: I find this questionable, at best it is Unknown.
		if !isStatusModified(unitStatus) {
			return containerStatus
		}
	}
	return unitStatus
}
// UnitDisplayStatus is used for CAAS units where the status of the unit
// could be overridden by the status of the container.
UnitDisplayStatus is used for CAAS units where the status of the unit
could be overridden by the status of the container.
// UnitDisplayStatus is used for CAAS units where the status of the unit // could be overridden by the status of the container .
func UnitDisplayStatus(unitStatus, containerStatus StatusInfo, expectWorkload bool) StatusInfo {
	if unitStatus.Status == Terminated {
		return unitStatus
	}
	if containerStatus.Status == Terminated {
		return containerStatus
	}
	if containerStatus.Status == "" {
		if isStatusModified(unitStatus) && (unitStatus.Status != Active || !expectWorkload) {
			return unitStatus
		}
		message := unitStatus.Message
		if expectWorkload {
			message = MessageWaitForContainer
		}
		return StatusInfo{
			Status:  Waiting,
			Message: message,
			Since:   containerStatus.Since,
		}
	}
	if unitStatus.Status != Active && unitStatus.Status != Waiting && unitStatus.Status != Blocked {
		return unitStatus
	}
	switch containerStatus.Status {
	case Error, Blocked, Allocating:
		return containerStatus
	case Waiting:
		if unitStatus.Status == Active {
			return containerStatus
		}
	case Running:
		if !isStatusModified(unitStatus) {
			return containerStatus
		}
	}
	return unitStatus
}
func UnitDisplayStatus ( unitStatus , containerStatus StatusInfo , expectWorkload bool ) StatusInfo { if unitStatus . Status == Terminated { return unitStatus } if containerStatus . Status == Terminated { return containerStatus } if containerStatus . Status == " " { if isStatusModified ( unitStatus ) && ( unitStatus . Status != Active || ! expectWorkload ) { return unitStatus } message := unitStatus . Message if expectWorkload { message = MessageWaitForContainer } return StatusInfo { Status : Waiting , Message : message , Since : containerStatus . Since , } } if unitStatus . Status != Active && unitStatus . Status != Waiting && unitStatus . Status != Blocked { return unitStatus } switch containerStatus . Status { case Error , Blocked , Allocating : return containerStatus case Waiting : if unitStatus . Status == Active { return containerStatus } case Running : if ! isStatusModified ( unitStatus ) { return containerStatus } } return unitStatus }
UnitDisplayStatus is used for CAAS units where the status of the unit
could be overridden by the status of the container.
UnitDisplayStatus is used for CAAS units where the status of the unit could be overridden by the status of the container .
// No container update received from k8s yet. // Unit may have set status, (though final status // can only be active if a container status has come through). // If no unit status set, assume still allocating. // Charm has said that there's a problem (error) or // it's doing something (maintenance) so we'll stick with that. // Charm may think it's active, but as yet there's no way for it to // query the workload state, so we'll ensure that we only say that // it's active if the pod is reported as running. If not, we'll report // any pod error. // Unit hasn't moved from initial state. // thumper: I find this questionable, at best it is Unknown.