Skip to content
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

Merged
merged 4 commits into from
Oct 21, 2020

Conversation

doughepi
Copy link
Contributor

@doughepi doughepi commented Oct 16, 2020

Allows the restic-wait init container to exist in any order in the pod being restored. Prints a warning message in the case where the restic-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 the restic-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 doughertypiper@gmail.com

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
Piper Dougherty added 2 commits October 15, 2020 23:27
Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
@doughepi doughepi marked this pull request as ready for review October 16, 2020 04:18
Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
Copy link
Contributor

@nrb nrb left a 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.

Copy link
Member

@ashish-amarnath ashish-amarnath left a 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 🎉

@ashish-amarnath ashish-amarnath merged commit 60ff351 into vmware-tanzu:main Oct 21, 2020
Comment on lines +675 to +695
{
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,
},
}
Copy link
Contributor

@jenting jenting Nov 4, 2020

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 😃

georgettica pushed a commit to georgettica/velero that referenced this pull request Dec 23, 2020
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
zubron pushed a commit that referenced this pull request Jan 14, 2021
* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
georgettica pushed a commit to georgettica/velero that referenced this pull request Jan 26, 2021
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
vadasambar pushed a commit to vadasambar/velero that referenced this pull request Feb 3, 2021
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
dharmab pushed a commit to dharmab/velero that referenced this pull request May 25, 2021
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
ywk253100 pushed a commit to ywk253100/velero that referenced this pull request Jun 29, 2021
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
gyaozhou pushed a commit to gyaozhou/velero-read that referenced this pull request May 14, 2022
…#3011)

* Adding handling of restic-wait init container at any order with warning.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Adding newline at end of files to match convention.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Formatting.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>

* Update copyright year on modified files.

Signed-off-by: Piper Dougherty <doughertypiper@gmail.com>
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.

Restoration fails in clusters with injected InitContainers because of order.
4 participants