-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding fix for restic init container index on restores. #3011
Adding fix for restic init container index on restores. #3011
Conversation
d5f83f1
to
c86a89b
Compare
Signed-off-by: Piper Dougherty <[email protected]>
c86a89b
to
1119e2d
Compare
Signed-off-by: Piper Dougherty <[email protected]>
Signed-off-by: Piper Dougherty <[email protected]>
Signed-off-by: Piper Dougherty <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the bug report and the fix! This makes a lot of sense to me, and I definitely agree with having a warning instead of silently failing.
The ramifications of not being first in all cases is a little hard to predict as we don't know what might mutate the pod, but I think this is more correct than the previous behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks for the PR @doughepi 🎉
{ | ||
name: "pod with restic init container as first initContainer should return 0", | ||
pod: &corev1api.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: "ns-1", | ||
Name: "pod-1", | ||
}, | ||
Spec: corev1api.PodSpec{ | ||
InitContainers: []corev1api.Container{ | ||
{ | ||
Name: restic.InitContainer, | ||
}, | ||
{ | ||
Name: "non-restic-init", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: 0, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@doughepi It's a duplicated test case 😃
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
* Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
…#3011) * Adding handling of restic-wait init container at any order with warning. Signed-off-by: Piper Dougherty <[email protected]> * Adding newline at end of files to match convention. Signed-off-by: Piper Dougherty <[email protected]> * Formatting. Signed-off-by: Piper Dougherty <[email protected]> * Update copyright year on modified files. Signed-off-by: Piper Dougherty <[email protected]>
Allows the
restic-wait
init container to exist in any order in the pod being restored. Prints a warning message in the case where therestic-wait
container isn't the first container in the list of initialization containers.As it stands right now, there's no indication that your restore is held up by the
restic-wait
container being anywhere other than the first initialization container. This attempts to complete the restore, and warns if therestic-wait
container is anywhere other than the first container.I believe this is the better strategy because there are many cases where—despite Velero's best effort—other containers will be injected before it. Our breaking example was the
istio-validate
container. Velero is correctly placing the initialization container at index 0, but the istio mutating webhook will always be evaluated after this. I believe all mutating webhooks that try to place their initialization containers at position 0 will break restores in the same manner.The warning serves to warn the user. I don't think initialization containers coming before the
restic-wait
container are an error state—just that they could affect the restore if they do something weird with the mounted volumes. Either way, I believe this behavior is better than a silent failure.fixes: #3008
Signed-off-by: Piper Dougherty [email protected]