Check kubeClient nil in Kubelet and bugfix
This commit is contained in:
		@@ -1533,10 +1533,14 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
 | 
				
			|||||||
				key := envVar.ValueFrom.ConfigMapKeyRef.Key
 | 
									key := envVar.ValueFrom.ConfigMapKeyRef.Key
 | 
				
			||||||
				configMap, ok := configMaps[name]
 | 
									configMap, ok := configMaps[name]
 | 
				
			||||||
				if !ok {
 | 
									if !ok {
 | 
				
			||||||
 | 
										if kl.kubeClient == nil {
 | 
				
			||||||
 | 
											return result, fmt.Errorf("Couldn't get configMap %v/%v, no kubeClient defined", pod.Namespace, name)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
					configMap, err = kl.kubeClient.Core().ConfigMaps(pod.Namespace).Get(name)
 | 
										configMap, err = kl.kubeClient.Core().ConfigMaps(pod.Namespace).Get(name)
 | 
				
			||||||
					if err != nil {
 | 
										if err != nil {
 | 
				
			||||||
						return result, err
 | 
											return result, err
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
										configMaps[name] = configMap
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				runtimeVal, ok = configMap.Data[key]
 | 
									runtimeVal, ok = configMap.Data[key]
 | 
				
			||||||
				if !ok {
 | 
									if !ok {
 | 
				
			||||||
@@ -1547,10 +1551,14 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
 | 
				
			|||||||
				key := envVar.ValueFrom.SecretKeyRef.Key
 | 
									key := envVar.ValueFrom.SecretKeyRef.Key
 | 
				
			||||||
				secret, ok := secrets[name]
 | 
									secret, ok := secrets[name]
 | 
				
			||||||
				if !ok {
 | 
									if !ok {
 | 
				
			||||||
 | 
										if kl.kubeClient == nil {
 | 
				
			||||||
 | 
											return result, fmt.Errorf("Couldn't get secret %v/%v, no kubeClient defined", pod.Namespace, name)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
					secret, err = kl.kubeClient.Core().Secrets(pod.Namespace).Get(name)
 | 
										secret, err = kl.kubeClient.Core().Secrets(pod.Namespace).Get(name)
 | 
				
			||||||
					if err != nil {
 | 
										if err != nil {
 | 
				
			||||||
						return result, err
 | 
											return result, err
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
										secrets[name] = secret
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				runtimeValBytes, ok := secret.Data[key]
 | 
									runtimeValBytes, ok := secret.Data[key]
 | 
				
			||||||
				if !ok {
 | 
									if !ok {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user