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