introspection: regenerate UUID if state is empty

The /var/lib/containerd/io.containerd.grpc.v1.introspection/uuid file
stores a UUID to identify the particular containerd daemon responding to
requests.  The file should either exist with a UUID, or not exist.
However, it has been observed that the file can be truncated with 0
bytes, which will then fail to be parsed as a valid UUID.

As a defensive practice, detect a 0-length file and overwrite with a new
UUID rather than failing.

Fixes: https://github.com/containerd/containerd/issues/10491
Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
Samuel Karp 2024-07-24 16:30:44 -07:00
parent c3bed76eeb
commit 0dcc51aedf
No known key found for this signature in database
GPG Key ID: 997C5A3CD3167CB5

View File

@ -153,6 +153,9 @@ func (l *Local) getUUID() (string, error) {
}
return "", err
}
if len(data) == 0 {
return l.generateUUID()
}
u := string(data)
if _, err := uuid.Parse(u); err != nil {
return "", err