Fix Pod Disruption Budget null pointer exception
This commit is contained in:
		
							parent
							
								
									a1deae198b
								
							
						
					
					
						commit
						661b141849
					
				|  | @ -231,6 +231,12 @@ func (c *Cluster) Create() error { | |||
| 	} | ||||
| 	c.logger.Infof("secrets have been successfully created") | ||||
| 
 | ||||
| 	pdb, err := c.createPodDisruptionBudget() | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("could not create pod disruption budget: %v", err) | ||||
| 	} | ||||
| 	c.logger.Infof("pod disruption budget %q has been successfully created", util.NameFromMeta(pdb.ObjectMeta)) | ||||
| 
 | ||||
| 	ss, err = c.createStatefulSet() | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("could not create statefulset: %v", err) | ||||
|  | @ -261,12 +267,6 @@ func (c *Cluster) Create() error { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	pdb, err := c.createPodDisruptionBudget() | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("could not create pod disruption budget: %v", err) | ||||
| 	} | ||||
| 	c.logger.Infof("pod disruption budget %q has been successfully created", util.NameFromMeta(pdb.ObjectMeta)) | ||||
| 
 | ||||
| 	err = c.listResources() | ||||
| 	if err != nil { | ||||
| 		c.logger.Errorf("could not list resources: %v", err) | ||||
|  |  | |||
|  | @ -278,6 +278,11 @@ func (c *Cluster) syncVolumes() error { | |||
| } | ||||
| 
 | ||||
| func (c *Cluster) samePDBWith(pdb *policybeta1.PodDisruptionBudget) (match bool, reason string) { | ||||
| 	if c.PodDisruptionBudget == nil { | ||||
| 		match = false | ||||
| 		reason = "pdb does not exist" | ||||
| 		return | ||||
| 	} | ||||
| 	match = reflect.DeepEqual(pdb.Spec, c.PodDisruptionBudget.Spec) | ||||
| 	if !match { | ||||
| 		reason = "new service spec doesn't match the current one" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue