The sync agent holds no Kubernetes credential, so the operator goes to it for the
state of a sync: every 30 seconds it asks the agent of each Treebind for its report
(GET /status on port 8080 of the sync pod) with a short-lived token of its own
service account. The decisions behind this are in
ADR 0011,
ADR 0015 and
ADR 0037.
Whether the operator can read the report is the condition AgentUnreachable. It is
about the operator's view of the agent, not about the sync, so it never changes
Ready: the sync can work while the operator cannot read it. What the report says of
the sync is in the conditions Synced and Conflict and in status.lastSyncedCommit
and status.lastSyncTime, which a section of their own
describes.
kubectl describe treebind <name>
kubectl get treebind <name> -o jsonpath='{.status.conditions[?(@.type=="AgentUnreachable")]}'
| Status | Reason | Means | What to check |
|---|---|---|---|
False |
ReportReceived |
The operator read the report | Nothing |
Unknown |
AwaitingAgentReport |
The operator has not polled yet | Wait a minute |
Unknown |
PollFailing |
The polls have failed for less than 3 minutes | Wait: a pod that has just started, or a rollout, looks like this |
Unknown |
AgentNotRunning |
The name of the sync pod does not resolve | The pod does not exist yet, or has no address: Ready and kubectl describe pod say why (SyncPodUnschedulable for a pod that the scheduler cannot place, as after a drain of the node of a claim of local-path; an unbound claim). It is never True, but after 3 minutes Synced is Unknown if a report was read before |
Unknown |
TokenUnavailable |
The operator could not get a token for the agent | The operator's log. The operator needs permission to create a token of its own service account, which the Role token-role in its namespace gives it. With --status-subject naming another account, that Role has to name the account too |
Unknown |
KeysUnavailable |
The operator could not put the cluster's public keys where the agent reads them, so the agent refuses its token | The operator's log, and whether a ConfigMap called <name>-sync-keys that the operator did not create is in the way |
True |
ConnectionFailed |
The polls failed for 3 minutes: the connection was refused or nothing answered | A network policy or a service mesh must let the operator reach port 8080 of the sync pod. When Ready says SyncPodNodeNotReady, the node of the sync pod is not ready, and the message says so instead: Ready names the node and what to do |
True |
TokenRefused |
The agent answers 401 | The ConfigMap <name>-sync-keys may not have reached the pod yet, or may hold other keys |
True |
UnexpectedResponse |
The agent answers with a status that is not a report | The log of the sync pod |
True |
ReportUnreadable |
The answer is too large, is not JSON, has another version or is another Treebind's | The log of the sync pod, and whether the operator and the agent image are of the same release |
A failure is Unknown with the reason PollFailing and turns True only when the
polls have failed for 3 minutes in a row. It goes back to False at the first poll
that works. After a failed poll the operator tries again in a minute, not in 30
seconds.
From the same report the operator writes two more conditions and two fields of the status, in the same write as
AgentUnreachable and only when something changed. kubectl describe treebind <name> shows them, and kubectl get treebind
shows Ready, Synced and Conflict. The decisions behind them are in
ADR 0037.
Each change of Synced and Conflict is also an event on the Treebind, and every condition is a metric:
metrics and events. The quickstart shows them on
a Treebind that syncs, and an example after a conflict that the policy resolved.
kubectl get treebind <name> -o jsonpath='{.status.conditions[?(@.type=="Synced")]}'
kubectl get treebind <name> -o jsonpath='{.status.lastSyncedCommit} {.status.lastSyncTime}'
status.lastSyncedCommit is the full id of the commit of the repository at which the agent last saw the checkout and the
branch agree, after a pull or a push. With spec.repository.path it is the repository's commit and not the checkout's
snapshot of it (the directory of the repository). status.lastSyncTime is when the agent first saw
them agree at that commit, by its clock and in whole seconds. The two change together, when the commit changes: a pull that
finds nothing new changes neither, so a Treebind with nothing to sync keeps its time. A restart of the sync pod, a step that
fails and a poll that fails clear nothing.
| Status | Reason | Means | What to check |
|---|---|---|---|
True |
InSync |
No step of the sync has failed, and the agent has seen the checkout and the branch agree since it started, at status.lastSyncedCommit |
Nothing |
False |
The reason of the step that failed, as its check spells it: FetchFailed, Blocked, TooManyDeletions, PushRejected and the others of the checks |
A step failed. The message says which step, what the reason means, and at which commit the volume and the repository last agreed | The check of the same name in the report and the log of the sync pod, which say which file and what the Git host said. The page of the step says what to do: the checkout, pulling, local changes. For a push that the host refused and for a conflict that was not resolved, recovering from a conflict or a rejected push starts from these conditions |
False |
SyncFailed |
A step failed with a reason that this release of the operator does not define, as an agent of another release can report | The log of the sync pod, and whether the operator and the agent image are of the same release |
Unknown |
AwaitingAgentReport |
The operator has not polled yet | Wait a minute |
Unknown |
SyncPending |
No step has failed, and the agent has not seen the volume and the repository agree since it started: the lock, the checkout, the first pull or the first push is still to come, as after every start of the sync pod | Wait: the first pull comes within one interval of the checkout |
Unknown |
AgentOutdated |
The report is of another pod template than the spec gives now, as while the sync pod is replaced after a change of the spec, or of an agent of the release before, which reports none | Wait for the new pod. If it lasts, Ready says whether the sync objects could not be updated (ReconcileFailed), and kubectl describe pod says why the new pod does not run |
Unknown |
AgentUnreachable |
The operator has not read a report for 3 minutes, whatever the reason, so it does not know what the sync does: AgentUnreachable is True, or it is Unknown because the sync pod does not run (AgentNotRunning) or the operator cannot make the call (TokenUnavailable, KeysUnavailable). For the second, the 3 minutes count only once a report has been read: a Treebind that was never read keeps AwaitingAgentReport. The next report puts it back |
AgentUnreachable says why, and Ready says why the sync pod does not run |
- It follows the steps, not the files.
Truesays that no step failed and that the agent has seen the two agree, and not that nothing waits. Files that the application wrote and that have not settled, files that have settled and are not committed yet, and commits of the checkout that are not pushed yet are no failure, so they do not makeSyncedFalse.status.lastSyncedCommitsays at which commit the volume and the repository last agreed. - The reason is of the first step that failed. The order is the one of the report. A reason that needs a person comes before one that waits for the Git host, so that a host that does not answer does not hide a file that someone has to move.
- A restart makes it
Unknown. The agent keeps what it saw in memory, so after every start of the sync podSyncedsaysSyncPendinguntil the first pull or push that finds the two in agreement, orFalseif a step fails first. It isTrueagain after that, with the commit and the time of the status as they were if nothing new came. - The messages are fixed. A message is a sentence for the step and the reason, the first 12 digits of
status.lastSyncedCommit, and where to read more. Nothing that the agent wrote is in it, because everyone who can read the Treebind reads it, and the text of a check names files and quotes the Git host. - How current it is. The operator reads the report every 30 seconds, a fifth more or less, every minute after a poll that failed, and at once after a change of the spec. A change shows in the status that long after the agent made it, and a change from Git also waits for the pull. The conditions carry the generation of the spec they were made for.
| Status | Reason | Means | What to check |
|---|---|---|---|
True |
The reason of the update that could not be made: Blocked, TooManyDeletions, TooManyCommits, Refused or PullFailed |
The last pull found that your directory and the repository each have commits that the other lacks, and could not resolve it with spec.sync.conflictPolicy. Local work waits for a person |
The message, the Pull and Conflict checks of the report, conflicts and what to do. A pull that passes without a conflict puts it back to False |
False |
ConflictResolved |
The last conflict that the agent found since it started was resolved by the policy, also one by followRemote, which keeps your version of a file in a ref that is never pushed |
The Conflict check names the policy, the counts and where the commits are kept |
False |
NoConflict |
The agent knows of no conflict that waits, and has resolved none since it started. It is also the answer for a pull Treebind, which has no conflict to resolve: an update that it cannot take, Diverged among them, makes Synced False |
Nothing |
Unknown |
As Synced |
Conflict is Unknown whenever Synced is, for a Treebind that only pulls too, with the same reason and message |
See Synced |
The agent keeps what it knows of a conflict in memory. After a restart the Conflict check is skipped until a conflict has
been resolved, so Conflict can say NoConflict before a pull has run, while Synced is False for another step, even though the pull
before the restart could not resolve a conflict. The next pull that finds the conflict again makes it True.
When the sync pod is ready, Ready is False with the reason NotSynced only when Synced is False for the current spec
and its reason is one that a person puts right. The message names the reason of Synced. For the reasons that the sync puts
right by itself Ready stays True, while Synced still says them, because Ready is what kubectl wait and the health
checks of a GitOps controller act on, and a Git host that is down should not turn every Treebind that uses it not ready
(ADR 0030).
Reason of Synced False |
Ready |
|---|---|
FetchFailed, PushFailed |
Stays True: the Git host did not answer, and the agent asks again with a wait that grows |
NonFastForward and Blocked, for a Treebind that syncs in both directions |
Stays True: the next pull brings the commits that the push lacked, and the next scan commits the edit that was in the way of the update |
Any other, SyncFailed too, and Blocked for a Treebind that only pulls |
False with NotSynced: a file, a branch, the volume, a limit of the spec or a rule of the repository has to change |
Unknown never makes Ready False, and neither does a Synced of an earlier generation, which is what a change of the spec
leaves in place until the next poll. Conflict is not an input: a conflict that cannot be resolved is a failed step, so
Synced says its reason, and Ready follows that.
Every sync pod is replaced once when the operator is upgraded to the release that writes these conditions. The pod template
gains the variable TREEBIND_TEMPLATE_HASH, the hash of the rest of the template, which the agent reports so that the operator
can tell a report of the current spec from one of the spec before. While a pod is replaced Ready says SyncPodNotReady, and
Synced and Conflict turn Unknown until the new pod has pulled: with AgentOutdated while the operator reads the old pod,
and with SyncPending once it reads the new one. After that no pod is replaced for a change that the agent does not see, such as
writing out mountPath: /work, which is the default.
The operator calls the sync pod on port 8080. In a namespace with a default-deny
network policy, or in a service mesh that does not let the call through, that call
fails, and the condition says ConnectionFailed after 3 minutes. The sync itself is
not affected, and the logs and metrics of the sync pod keep working. Examples of
policies that allow the operator are tracked in #117.
The endpoint answers only a token of the operator's service account whose audience is the Treebind, so a plain request gets 401. To read the report by hand, ask for such a token and call the pod from a pod in the cluster:
TOKEN=$(kubectl -n <operator namespace> create token <operator service account> \
--audience=<API group of the CRD>/<namespace>/<name> --duration=10m)
# from any pod in the cluster that has curl or wget:
curl -H "Authorization: Bearer $TOKEN" \
http://<name>-sync-0.<name>-sync.<namespace>.svc:8080/status
The agent's probes need no token: /healthz and /readyz on the same port, which the next section
describes.
The kubelet asks the sync pod two questions on port 8080 every 10 seconds, with a timeout of 2 seconds, and a probe that fails three times in a row counts as failed. Neither needs a token and neither says more than its word.
| Probe | Path | Answers 200 | Answers 503 |
|---|---|---|---|
| Readiness | /readyz |
A pull has passed since the agent started, or, for a Treebind that syncs in both directions, a push has worked | Neither has happened yet |
| Liveness | /healthz |
The loop of the agent has been heard from within what it promised | It has not |
Ready means the agent has synced. The first pull that ends Passed makes it ready: the checkout was at the tip of the
branch (UpToDate), was brought to it (Advanced), has commits that the repository does not have yet (Ahead), or had a conflict with it that the policy resolved (Resolved). For a
Treebind that syncs in both directions the first push that works makes it ready as well, whichever of the two comes first,
so a Treebind on an empty repository is ready as soon as its first commit is pushed, and does not wait for a second pull. A
push that is rejected, that fails or that finds nothing to push does not make it ready. The Pull and Push checks in the
report say Passed before the pod is ready, and the agent logs one line when it turns ready. The first pull comes up to one
interval after the checkout (pulling), and the kubelet sees the agent ready at its next probe, up to 10 seconds
after that. The operator turns the Ready condition of the Treebind on when the sync pod is ready, so
kubectl wait --for=condition=Ready treebind/<name> waits for the first pull or the first push.
ADR 0033 has the reasons.
It stays ready while the agent runs. A pull that fails later (the repository does not answer, a file is in the way,
the branches diverged, the update would remove too many files) does not make the pod not ready, because the files on the
volume are as they were, and a Git host that is down for an hour should not turn every Treebind that uses it
not ready. The Pull check says what the last pull found, and Synced says it in the Treebind: it turns Ready False only
for a reason that a person puts right (below). A container that restarts starts not ready, because nothing in its
memory says that the one before it synced, and is ready again after its first pull.
Alive means the loop is not stuck. The loop of the agent beats, and each beat says how long it is until the next:
the length of the wait before a pull, a scan or a retry; the timeout of a Git command while one runs; and 5 minutes for the
code between them. /healthz answers 503 when the loop has been silent for longer than it promised and a grace of 30
seconds, and the kubelet restarts the container, 20 to 30 seconds later. A long interval, a long wait after failed pulls, a
fetch of a large repository, and a wait for the writer lock that another agent holds are all promised, so none of them is
taken for a stuck loop. A pull that fails, or a volume check that fails, is not either: the loop goes on, and the report
says what failed. An agent that has nothing more to do (no lock, checkout or pulls to run) is alive for good. The log
says the loop of the agent did not beat within what it promised, with how late it is, at most once a minute.
ADR 0030 has the reasons.
| What you see | What it means | What to check |
|---|---|---|
The pod is 0/1, and Ready is False with SyncPodNotReady, for less than one interval after it started |
The first pull is not due yet | Wait |
| The same, for longer | No pull has passed | The Pull check: its reason says what is in the way, and pulling says what to do |
The same, with BranchGone |
The repository has no such branch, or no commit at all yet | Put a commit on the branch, or set spec.repository.branch to one that exists. A Treebind that syncs in both directions turns ready by itself when its first commit is pushed |
The same, and the Pull check is Skipped with NotChecked |
The volume, the lock or the checkout has not passed | The check that failed, in the same report |
There is no sync pod, and Ready is False with UnsupportedRepositoryScheme |
spec.repository.url has the scheme http://, which the agent refuses, so the operator creates no sync pod. A sync pod that the Treebind had is left as it was, and Synced says AgentOutdated for it |
Use an ssh:// or https:// address: the checkout says why |
The pod is 1/1, and Ready is False with NotSynced |
A step of the sync failed for a reason that a person puts right | Synced: its reason and message, then the check of the same name in the report (Synced and Ready) |
The container restarts, and kubectl describe pod shows Liveness probe failed: HTTP probe failed with statuscode: 503 |
The loop was stuck: a step took longer than it promised, most often a call on a volume that does not answer | The log of the container before the restart (kubectl logs --previous), for the line about the loop and how late it was, and the volume |
The container restarts, and Ready is False with SyncPodOOMKilled |
The container was killed for using more memory than its limit, which the message names. Git needed it, for a large file, and every restart is killed again on the same pull | Large files |
The pod is Pending, and Ready is False with SyncPodUnschedulable |
The scheduler cannot place the sync pod, and the message gives its words. After a drain of the node of a claim of local-path they say volume node affinity conflict and were unschedulable: only that node can mount the volume, and it is cordoned. Nothing is synced while the pod waits: AgentUnreachable says AgentNotRunning, and after 3 minutes Synced is Unknown with AgentUnreachable |
What the message says no node has. For a drained node, kubectl uncordon <node> once it may run pods again |
The pod is Running, or Terminating, on a node that is lost, and Ready is False with SyncPodNodeNotReady |
The node of the sync pod is not ready, and the message names the node and the pod. The pod cannot end there, so it is not replaced. After 3 minutes AgentUnreachable is True with ConnectionFailed, and Synced is Unknown with AgentUnreachable |
Bring the node back. If it is shut down, give it the taint node.kubernetes.io/out-of-service with the effect NoExecute: Kubernetes deletes the pod and makes a new one, which a claim that only that node can mount keeps Pending (SyncPodUnschedulable). Take the taint away once the node is back |
While the pod is not ready, kubectl describe pod shows the event Readiness probe failed: HTTP probe failed with statuscode: 503. That is the probe doing its work and not a fault of its own. A repository that has no commit yet says
BranchGone with the words "has no branch ... any more", which is also what a branch that was deleted says.
The sync container has a memory limit of 128 MiB, and spec.agent.resources does not change it yet
(#96). Git streams a file larger than 16 MiB between the Git host and the
disk instead of holding it in memory, so a file that is new to the branch needs no more memory for being large: one of 200 MB
syncs with the default limit. A file larger than 16 MiB is not stored as a delta, so every change to it is sent whole on a
push. A change of a large file that a pull brings can need more memory: when the Git host sends the new version as a delta of
the old one, Git builds it in memory from the old one, with about four times the size of the file in all, so with the default limit
such a change works for a file of up to about 25 MB. When Git needs more than the limit, the container is killed, every restart
is killed again on the same pull, and Ready is False with the reason SyncPodOOMKilled and a message that names the limit.
While no sync pod is ready the operator looks at the pod about every 30 seconds, so Ready says it within about half a minute
of the kill, and it names a kill that ended at most 10 minutes before for a container that runs again and is not ready. A later
commit that removes the file does not help, because a pull fetches every commit of the branch.
The agent checks the operator's token against the cluster's public signing keys. The
operator reads them from the API server and writes them to the ConfigMap
<name>-sync-keys, which the Treebind owns and which the sync pod mounts. It writes
the keys again when they change and every 10 minutes. When an agent refuses the
token, the operator reads the keys again at once, because that is what a rotation of
the cluster's keys looks like before the new keys have reached the pod. The kubelet
takes about a minute to show a changed ConfigMap in a running pod, so after a
rotation PollFailing for a short time is normal.
The operator may create and patch ConfigMaps in every namespace for this, and nothing
else: it reads no ConfigMap and changes only one that the Treebind owns. A ConfigMap
of the name <name>-sync-keys that someone else made is left alone, and the
condition says KeysUnavailable when that is why the agent refuses the token.
The report lists the agent's checks, in the order the agent runs them, each with an outcome
(Passed, Failed or Skipped), a reason when it did not pass, and a message:
| Check | What it is | More |
|---|---|---|
Mount |
The claim is a mounted volume | Pod security |
Writable |
The agent can write to it | Pod security |
GitDir |
The directories where the agent keeps its Git directory are its own and private | The Git directory |
Lock |
The agent holds the writer lock of the volume, so that no other agent writes to it. It waits while another holds it | ADR 0023 |
Checkout |
The checkout of the repository, or of the directory of it that spec.repository.path names, is made, or the one that is there is opened |
The checkout, the directory of the repository |
Pull |
The last pull of the commits that the repository gained: at the tip, advanced, or why it did not work, for example TooManyDeletions. It is skipped until the first pull |
Pulling, the deletion guard |
Changes |
The last scan of your directory for what the application changed: how many files, how many have settled, what is left out, and what the events of the file system cannot do. Only for a Treebind that syncs in both directions. It is skipped until the first scan | Local changes |
Commit |
The last commit of the files that the scans found settled: how many and the short id, that there was nothing to commit, or why it failed (CommitFailed, or TooManyCommits when the limit of commits in an hour is reached). Only for a Treebind that syncs in both directions. It is skipped until a file settles, and while an update that was cut off waits for a pull to put it right |
Local changes, echo loops |
Push |
The last push of the commits of the checkout: how many and the two ids, that there is nothing to push, or why it failed (NonFastForward, PushRejected with the words of the host, PushFailed). Only for a Treebind that syncs in both directions. It is skipped until the first scan |
Local changes |
Conflict |
What the last resolution of a conflict between your directory and the repository did: the policy, how many commits each side had, how many files had the winner's version, how many were kept from the other side, the commit that was made and, for followRemote, the ref that keeps the commits of the directory. It is Passed with the reason ConflictResolved, and stays so until the next resolution. Only for a Treebind that syncs in both directions. It is skipped, saying that no conflict has been resolved since the agent started, until a conflict has been resolved. A resolution that could not be made makes it Failed, with the reason of the update (Blocked, TooManyDeletions, TooManyCommits, Refused, PullFailed), and the Pull check fails with the same reason and a message that says that the conflict was not resolved. The next pull that passes without a conflict puts the check back to what it said before: the last resolution, or Skipped. It does not change whether the agent is ready, and the operator derives the Conflict condition from it |
Conflicts |
A check that cannot be tried because one before it failed, or that waits, is Skipped, with the reason
NotChecked and the check that failed in the message. The operator shows what the checks say of the
sync as the conditions Synced and Conflict (above). The checks themselves,
with their messages, which name files and quote the Git host, are in the report and in the agent's log.