Skip to content

quark: Fix race condition between the two container write paths - #438

Open
christos68k wants to merge 1 commit into
fix-container-linkfrom
ck/container-link
Open

christos68k wants to merge 1 commit into
fix-container-linkfrom
ck/container-link

Conversation

@christos68k

Copy link
Copy Markdown
Member

Summary

A container created without a Pod through the API would later fail an update and Pod link by kube-talker as it'd appear as a duplicate. Note that the reverse order (kube-talker first then API) would result in different (but correct) state as the container would exist and be linked to Pod metainformation.

With this fix, both write path orderings should result in exactly the same state provided both writers report the same metadata, which they should as they receive them from the same container runtime.

A failed image demux no longer deletes the container as it is no longer solely owned by kube-talker. The partial object is now left in place, to avoid destroying shared state, and hopefully completed by the next pod update.

Also see:

A container created without a Pod through the API would later
fail an update and Pod link by kube-talker as it'd appear as
a duplicate. Note that the reverse order (kube-talker first then
API) would result in different (but correct) state as the container
would exist linked to Pod metainformation.

With this fix, both write path orderings should result in exactly
the same state provided both writers report the same metadata,
which they should as they receive them from the same container runtime.

A failed image demux no longer deletes the container as it is no longer
solely owned by kube-talker. The partial object is now left in place,
to avoid destroying shared state, and hopefully completed by the next
pod update.
Comment thread quark.c
* the full image demux instead of leaving it half done.
*/
if (demux_image(container) == -1) {
container_delete(qq, container);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a second write path, kube-talker is not the sole owner so we shouldn't destroy associated state on demux_image failures (memory allocation failure which, if triggered, should be transient). We can clear the metadata and let a future pod update retry.

Comment thread quark.c
return (n);
}

static struct quark_container *

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed any more.

Comment thread quark.c
qwarnx("unknown container state, ignoring");
return (-1);
}
container = pod_lookup_container(pod, containerID->valuestring);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would return NULL for a container previously inserted without a pod.

Comment thread quark.c
container = quark_container_get(qq, containerID->valuestring,
pod != NULL ? pod->uid : NULL);
if (container == NULL) {
container = quark_container_create(qq,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fail with EEXIST for containers without a pod.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants