optimize getPullSecretsForPod() and syncPod()

Since getPullSecretsForPod() will never return err,we do not need the second return value,and modify syncPod() function.
This commit is contained in:
NickrenREN 2016-12-26 18:41:14 +08:00 committed by NickrenREN
parent 4aa9168536
commit 2f89a6bda6
2 changed files with 4 additions and 8 deletions

View File

@ -1551,16 +1551,12 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
}
// Fetch the pull secrets for the pod
pullSecrets, err := kl.getPullSecretsForPod(pod)
if err != nil {
glog.Errorf("Unable to get pull secrets for pod %q: %v", format.Pod(pod), err)
return err
}
pullSecrets := kl.getPullSecretsForPod(pod)
// Call the container runtime's SyncPod callback
result := kl.containerRuntime.SyncPod(pod, apiPodStatus, podStatus, pullSecrets, kl.backOff)
kl.reasonCache.Update(pod.UID, result)
if err = result.Error(); err != nil {
if err := result.Error(); err != nil {
return err
}

View File

@ -672,7 +672,7 @@ func (kl *Kubelet) makePodDataDirs(pod *v1.Pod) error {
// getPullSecretsForPod inspects the Pod and retrieves the referenced pull
// secrets.
func (kl *Kubelet) getPullSecretsForPod(pod *v1.Pod) ([]v1.Secret, error) {
func (kl *Kubelet) getPullSecretsForPod(pod *v1.Pod) []v1.Secret {
pullSecrets := []v1.Secret{}
for _, secretRef := range pod.Spec.ImagePullSecrets {
@ -685,7 +685,7 @@ func (kl *Kubelet) getPullSecretsForPod(pod *v1.Pod) ([]v1.Secret, error) {
pullSecrets = append(pullSecrets, *secret)
}
return pullSecrets, nil
return pullSecrets
}
// Returns true if pod is in the terminated state ("Failed" or "Succeeded").