mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-08 00:57:19 +00:00
feat: support backup hooks on native sidecars (#9403)
Run the E2E test on kind / get-go-version (push) Failing after 51s
Run the E2E test on kind / build (push) Has been skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / get-go-version (push) Successful in 10s
Main CI / Build (push) Failing after 25s
Close stale issues and PRs / stale (push) Successful in 9s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m28s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 55s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m2s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m1s
Run the E2E test on kind / get-go-version (push) Failing after 51s
Run the E2E test on kind / build (push) Has been skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / get-go-version (push) Successful in 10s
Main CI / Build (push) Failing after 25s
Close stale issues and PRs / stale (push) Successful in 9s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m28s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 55s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m2s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m1s
* feat: support backup hooks on sidecars Add support for configuring Kubernates native Sidecars as target containrs for Backup Hooks commands. This is purely a validation level patch as the actual pods/exec API doesn't make any distinction between standard and sidecar containers. Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com> * test: extend unit tests Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com> * chore: changelog Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com> * style: fix linter issues Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com> --------- Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/url"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -184,10 +185,22 @@ func (e *defaultPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, it
|
||||
}
|
||||
|
||||
func ensureContainerExists(pod *corev1api.Pod, container string) error {
|
||||
for _, c := range pod.Spec.Containers {
|
||||
if c.Name == container {
|
||||
return nil
|
||||
}
|
||||
existsAsMainContainer := slices.ContainsFunc(pod.Spec.Containers, func(c corev1api.Container) bool {
|
||||
return c.Name == container
|
||||
})
|
||||
|
||||
if existsAsMainContainer {
|
||||
return nil
|
||||
}
|
||||
|
||||
existsAsSidecar := slices.ContainsFunc(pod.Spec.InitContainers, func(c corev1api.Container) bool {
|
||||
return c.RestartPolicy != nil &&
|
||||
*c.RestartPolicy == corev1api.ContainerRestartPolicyAlways &&
|
||||
c.Name == container
|
||||
})
|
||||
|
||||
if existsAsSidecar {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.Errorf("no such container: %q", container)
|
||||
|
||||
Reference in New Issue
Block a user