Skip to content

Commit

Permalink
issue fix 4874 update
Browse files Browse the repository at this point in the history
Signed-off-by: Lyndon-Li <[email protected]>
  • Loading branch information
Lyndon-Li committed Sep 9, 2022
1 parent 30a70cb commit 409b6d5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5319-lyndon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue 4874 and 4752: check the daemonset pod is running in the node where the workload pod resides before running the PVB for the pod
6 changes: 3 additions & 3 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,11 @@ var defaultRestorePriorities = []string{
}

func (s *server) initRestic() error {
// warn if restic daemonset does not exist
// warn if node agent does not exist
if err := nodeagent.IsRunning(s.ctx, s.kubeClient, s.namespace); err == nodeagent.DaemonsetNotFound {
s.logger.Warn("Velero restic daemonset not found; restic backups/restores will not work until it's created")
s.logger.Warn("Velero node agent not found; pod volume backups/restores will not work until it's created")
} else if err != nil {
s.logger.WithError(errors.WithStack(err)).Warn("Error checking for existence of velero restic daemonset")
s.logger.WithError(errors.WithStack(err)).Warn("Error checking for existence of velero node agent")
}

// ensure the repo key secret is set up
Expand Down
4 changes: 2 additions & 2 deletions pkg/nodeagent/node_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

const (
// daemonSet is the name of the Velero restic daemonset.
// daemonSet is the name of the Velero node agent daemonset.
daemonSet = "restic"
)

Expand All @@ -48,7 +48,7 @@ func IsRunning(ctx context.Context, kubeClient kubernetes.Interface, namespace s
}
}

// IsRunningInNode checks if the node agent daemonset pod is running properly in a specified node. If not, return the error found
// IsRunningInNode checks if the node agent pod is running properly in a specified node. If not, return the error found
func IsRunningInNode(ctx context.Context, namespace string, nodeName string, podClient corev1client.PodsGetter) error {
if nodeName == "" {
return errors.New("node name is empty")
Expand Down
2 changes: 1 addition & 1 deletion pkg/podvolume/backupper.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (b *backupper) BackupPodVolumes(backup *velerov1api.Backup, pod *corev1api.
return nil, []error{err}
}

err = IsPodQualified(pod)
err = isPodQualified(pod)
if err != nil {
return nil, []error{err}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/podvolume/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ func GetPodVolumesUsingRestic(pod *corev1api.Pod, defaultVolumesToRestic bool) [
return podVolumes
}

// IsPodQualified checks if the pod's status is qualified for a PVB/PVR to backup/restore its volumes.
// isPodQualified checks if the pod's status is qualified for a PVB/PVR to backup/restore its volumes.
// If no, return the error found
func IsPodQualified(pod *corev1api.Pod) error {
func isPodQualified(pod *corev1api.Pod) error {
if pod.Spec.NodeName == "" {
return errors.Errorf("pod is not scheduled, name=%s, namespace=%s, status=%s", pod.Name, pod.Namespace, pod.Status.Phase)
return errors.Errorf("pod is not scheduled, name=%s, namespace=%s, phase=%s", pod.Name, pod.Namespace, pod.Status.Phase)
}

if pod.Status.Phase != corev1api.PodRunning {
return errors.Errorf("pod is not running, name=%s, namespace=%s, status=%s", pod.Name, pod.Namespace, pod.Status.Phase)
return errors.Errorf("pod is not running, name=%s, namespace=%s, phase=%s", pod.Name, pod.Namespace, pod.Status.Phase)
}

return nil
Expand Down

0 comments on commit 409b6d5

Please sign in to comment.