github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/controllers/core/liveupdate/monitor.go (about)

     1  package liveupdate
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  
     6  	"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
     7  )
     8  
     9  // Each LiveUpdate has a monitor associated with it that
    10  // tracks the history of updates.
    11  //
    12  // The monitor keeps track of:
    13  // - The last known Spec
    14  // - Every file change it has seen
    15  // - The history of container updates
    16  type monitor struct {
    17  	manifestName string
    18  	spec         v1alpha1.LiveUpdateSpec
    19  
    20  	// Tracked dependencies.
    21  	lastKubernetesDiscovery   *v1alpha1.KubernetesDiscovery
    22  	lastKubernetesApplyStatus *v1alpha1.KubernetesApplyStatus
    23  	lastDockerComposeService  *v1alpha1.DockerComposeService
    24  	lastTriggerQueue          *v1alpha1.ConfigMap
    25  	lastImageMap              *v1alpha1.ImageMap
    26  
    27  	// History of source file changes.
    28  	sources map[string]*monitorSource
    29  
    30  	// History of container updates.
    31  	hasChangesToSync bool
    32  	containers       map[monitorContainerKey]monitorContainerStatus
    33  }
    34  
    35  type monitorSource struct {
    36  	modTimeByPath   map[string]metav1.MicroTime
    37  	lastImageStatus *v1alpha1.ImageMapStatus
    38  	lastFileEvent   *v1alpha1.FileEvent
    39  }
    40  
    41  type monitorContainerKey struct {
    42  	containerID string
    43  	podName     string
    44  	namespace   string
    45  }
    46  
    47  type monitorContainerStatus struct {
    48  	lastFileTimeSynced metav1.MicroTime
    49  
    50  	// The low water mark is the oldest file timestamp
    51  	// triggered a build failure.
    52  	//
    53  	// If we get a new ImageBuild or new KubernetesApply
    54  	// after this mark, we should try again.
    55  	failedLowWaterMark metav1.MicroTime
    56  	failedReason       string
    57  	failedMessage      string
    58  }