parent
							
								
									69af2d60e5
								
							
						
					
					
						commit
						2886027516
					
				| 
						 | 
					@ -342,7 +342,7 @@ func (c *Cluster) compareStatefulSetWith(statefulSet *v1beta1.StatefulSet) *comp
 | 
				
			||||||
	if c.Statefulset.Spec.Template.Spec.ServiceAccountName != statefulSet.Spec.Template.Spec.ServiceAccountName {
 | 
						if c.Statefulset.Spec.Template.Spec.ServiceAccountName != statefulSet.Spec.Template.Spec.ServiceAccountName {
 | 
				
			||||||
		needsReplace = true
 | 
							needsReplace = true
 | 
				
			||||||
		needsRollUpdate = true
 | 
							needsRollUpdate = true
 | 
				
			||||||
		reasons = append(reasons, "new statefulset's serviceAccountName service asccount name doesn't match the current one")
 | 
							reasons = append(reasons, "new statefulset's serviceAccountName service account name doesn't match the current one")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if *c.Statefulset.Spec.Template.Spec.TerminationGracePeriodSeconds != *statefulSet.Spec.Template.Spec.TerminationGracePeriodSeconds {
 | 
						if *c.Statefulset.Spec.Template.Spec.TerminationGracePeriodSeconds != *statefulSet.Spec.Template.Spec.TerminationGracePeriodSeconds {
 | 
				
			||||||
		needsReplace = true
 | 
							needsReplace = true
 | 
				
			||||||
| 
						 | 
					@ -462,16 +462,16 @@ func (c *Cluster) compareContainers(description string, setA, setB []v1.Containe
 | 
				
			||||||
func compareResources(a *v1.ResourceRequirements, b *v1.ResourceRequirements) bool {
 | 
					func compareResources(a *v1.ResourceRequirements, b *v1.ResourceRequirements) bool {
 | 
				
			||||||
	equal := true
 | 
						equal := true
 | 
				
			||||||
	if a != nil {
 | 
						if a != nil {
 | 
				
			||||||
		equal = compareResoucesAssumeFirstNotNil(a, b)
 | 
							equal = compareResourcesAssumeFirstNotNil(a, b)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if equal && (b != nil) {
 | 
						if equal && (b != nil) {
 | 
				
			||||||
		equal = compareResoucesAssumeFirstNotNil(b, a)
 | 
							equal = compareResourcesAssumeFirstNotNil(b, a)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return equal
 | 
						return equal
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func compareResoucesAssumeFirstNotNil(a *v1.ResourceRequirements, b *v1.ResourceRequirements) bool {
 | 
					func compareResourcesAssumeFirstNotNil(a *v1.ResourceRequirements, b *v1.ResourceRequirements) bool {
 | 
				
			||||||
	if b == nil || (len(b.Requests) == 0) {
 | 
						if b == nil || (len(b.Requests) == 0) {
 | 
				
			||||||
		return len(a.Requests) == 0
 | 
							return len(a.Requests) == 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -875,7 +875,7 @@ func (c *Cluster) initInfrastructureRoles() error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// resolves naming conflicts between existing and new roles by chosing either of them.
 | 
					// resolves naming conflicts between existing and new roles by choosing either of them.
 | 
				
			||||||
func (c *Cluster) resolveNameConflict(currentRole, newRole *spec.PgUser) spec.PgUser {
 | 
					func (c *Cluster) resolveNameConflict(currentRole, newRole *spec.PgUser) spec.PgUser {
 | 
				
			||||||
	var result spec.PgUser
 | 
						var result spec.PgUser
 | 
				
			||||||
	if newRole.Origin >= currentRole.Origin {
 | 
						if newRole.Origin >= currentRole.Origin {
 | 
				
			||||||
| 
						 | 
					@ -969,7 +969,7 @@ func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) e
 | 
				
			||||||
	// signal the role label waiting goroutine to close the shop and go home
 | 
						// signal the role label waiting goroutine to close the shop and go home
 | 
				
			||||||
	close(stopCh)
 | 
						close(stopCh)
 | 
				
			||||||
	// wait until the goroutine terminates, since unregisterPodSubscriber
 | 
						// wait until the goroutine terminates, since unregisterPodSubscriber
 | 
				
			||||||
	// must be called before the outer return; otherwsise we risk subscribing to the same pod twice.
 | 
						// must be called before the outer return; otherwise we risk subscribing to the same pod twice.
 | 
				
			||||||
	wg.Wait()
 | 
						wg.Wait()
 | 
				
			||||||
	// close the label waiting channel no sooner than the waiting goroutine terminates.
 | 
						// close the label waiting channel no sooner than the waiting goroutine terminates.
 | 
				
			||||||
	close(podLabelErr)
 | 
						close(podLabelErr)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -329,7 +329,7 @@ func tolerations(tolerationsSpec *[]v1.Toleration, podToleration map[string]stri
 | 
				
			||||||
	return []v1.Toleration{}
 | 
						return []v1.Toleration{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// isBootstrapOnlyParameter checks asgainst special Patroni bootstrap parameters.
 | 
					// isBootstrapOnlyParameter checks against special Patroni bootstrap parameters.
 | 
				
			||||||
// Those parameters must go to the bootstrap/dcs/postgresql/parameters section.
 | 
					// Those parameters must go to the bootstrap/dcs/postgresql/parameters section.
 | 
				
			||||||
// See http://patroni.readthedocs.io/en/latest/dynamic_configuration.html.
 | 
					// See http://patroni.readthedocs.io/en/latest/dynamic_configuration.html.
 | 
				
			||||||
func isBootstrapOnlyParameter(param string) bool {
 | 
					func isBootstrapOnlyParameter(param string) bool {
 | 
				
			||||||
| 
						 | 
					@ -1366,7 +1366,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
 | 
				
			||||||
		return nil, fmt.Errorf("could not generate pod template for logical backup pod: %v", err)
 | 
							return nil, fmt.Errorf("could not generate pod template for logical backup pod: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// overwrite specifc params of logical backups pods
 | 
						// overwrite specific params of logical backups pods
 | 
				
			||||||
	podTemplate.Spec.Affinity = &podAffinity
 | 
						podTemplate.Spec.Affinity = &podAffinity
 | 
				
			||||||
	podTemplate.Spec.RestartPolicy = "Never" // affects containers within a pod
 | 
						podTemplate.Spec.RestartPolicy = "Never" // affects containers within a pod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -361,7 +361,7 @@ func (c *Cluster) updateService(role PostgresRole, newService *v1.Service) error
 | 
				
			||||||
	// TODO: check if it possible to change the service type with a patch in future versions of Kubernetes
 | 
						// TODO: check if it possible to change the service type with a patch in future versions of Kubernetes
 | 
				
			||||||
	if newService.Spec.Type != c.Services[role].Spec.Type {
 | 
						if newService.Spec.Type != c.Services[role].Spec.Type {
 | 
				
			||||||
		// service type has changed, need to replace the service completely.
 | 
							// service type has changed, need to replace the service completely.
 | 
				
			||||||
		// we cannot use just pach the current service, since it may contain attributes incompatible with the new type.
 | 
							// we cannot use just patch the current service, since it may contain attributes incompatible with the new type.
 | 
				
			||||||
		var (
 | 
							var (
 | 
				
			||||||
			currentEndpoint *v1.Endpoints
 | 
								currentEndpoint *v1.Endpoints
 | 
				
			||||||
			err             error
 | 
								err             error
 | 
				
			||||||
| 
						 | 
					@ -369,7 +369,7 @@ func (c *Cluster) updateService(role PostgresRole, newService *v1.Service) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if role == Master {
 | 
							if role == Master {
 | 
				
			||||||
			// for the master service we need to re-create the endpoint as well. Get the up-to-date version of
 | 
								// for the master service we need to re-create the endpoint as well. Get the up-to-date version of
 | 
				
			||||||
			// the addresses stored in it before the service is deleted (deletion of the service removes the endpooint)
 | 
								// the addresses stored in it before the service is deleted (deletion of the service removes the endpoint)
 | 
				
			||||||
			currentEndpoint, err = c.KubeClient.Endpoints(c.Namespace).Get(c.endpointName(role), metav1.GetOptions{})
 | 
								currentEndpoint, err = c.KubeClient.Endpoints(c.Namespace).Get(c.endpointName(role), metav1.GetOptions{})
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return fmt.Errorf("could not get current cluster %s endpoints: %v", role, err)
 | 
									return fmt.Errorf("could not get current cluster %s endpoints: %v", role, err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue