Check for dns annotation of the service

This commit is contained in:
Murat Kabilov 2017-06-07 16:41:39 +02:00 committed by GitHub
parent dc36c4ca12
commit 292a9bda05
1 changed files with 11 additions and 4 deletions

View File

@ -242,15 +242,22 @@ func (c *Cluster) Create() error {
func (c *Cluster) sameServiceWith(role PostgresRole, service *v1.Service) (match bool, reason string) { func (c *Cluster) sameServiceWith(role PostgresRole, service *v1.Service) (match bool, reason string) {
//TODO: improve comparison //TODO: improve comparison
match = true match = true
old := c.Service[role].Spec.LoadBalancerSourceRanges oldSourceRanges := c.Service[role].Spec.LoadBalancerSourceRanges
new := service.Spec.LoadBalancerSourceRanges newSourceRanges := service.Spec.LoadBalancerSourceRanges
/* work around Kubernetes 1.6 serializing [] as nil. See https://github.com/kubernetes/kubernetes/issues/43203 */ /* work around Kubernetes 1.6 serializing [] as nil. See https://github.com/kubernetes/kubernetes/issues/43203 */
if (len(old) == 0) && (len(new) == 0) { if (len(oldSourceRanges) == 0) && (len(newSourceRanges) == 0) {
return true, "" return true, ""
} }
if !reflect.DeepEqual(old, new) { if !reflect.DeepEqual(oldSourceRanges, newSourceRanges) {
return false, fmt.Sprintf("new %s service's LoadBalancerSourceRange doesn't match the current one", role) return false, fmt.Sprintf("new %s service's LoadBalancerSourceRange doesn't match the current one", role)
} }
oldDNSAnnotation := c.Service[role].Annotations[constants.ZalandoDNSNameAnnotation]
newDNSAnnotation := service.Annotations[constants.ZalandoDNSNameAnnotation]
if oldDNSAnnotation != newDNSAnnotation {
return false, fmt.Sprintf("new %s service's '%s' annotation doesn't match the current one", role, constants.ZalandoDNSNameAnnotation)
}
return true, "" return true, ""
} }