1
0
Fork 0

feat(rancher): added constraint management for rancher provider

This commit is contained in:
Youcef Yekhlef 2017-05-02 16:51:02 +02:00 committed by Fernandez Ludovic
parent b5283391dd
commit 8de107866f
4 changed files with 34 additions and 0 deletions

View file

@ -234,6 +234,7 @@ func getenv(key, fallback string) string {
// Provide allows the rancher provider to provide configurations to traefik
// using the given configuration channel.
func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error {
p.Constraints = append(p.Constraints, constraints...)
safe.Go(func() {
operation := func() error {
@ -485,6 +486,14 @@ func (p *Provider) serviceFilter(service rancherData) bool {
return false
}
constraintTags := strings.Split(service.Labels["traefik.tags"], ",")
if ok, failingConstraint := p.MatchConstraints(constraintTags); !ok {
if failingConstraint != nil {
log.Debugf("Filtering service %s with constraint %s", service.Name, failingConstraint.String())
}
return false
}
// Only filter services by Health (HealthState) and State if EnableServiceHealthFilter is true
if p.EnableServiceHealthFilter {