Skip to content

Commit

Permalink
fix(jolokia): Order consistently Jolokia agent options when encoded a…
Browse files Browse the repository at this point in the history
…s environment variable
  • Loading branch information
astefanutti committed Jan 14, 2020
1 parent 1d38815 commit cc1d24b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/trait/jolokia.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package trait

import (
"fmt"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -172,9 +173,18 @@ func (t *jolokiaTrait) Apply(e *Environment) (err error) {
addToJolokiaOptions(options, "useSslClientAuthentication", t.UseSslClientAuthentication)

// Lastly set the AB_JOLOKIA_OPTS environment variable from the fabric8/s2i-java base image
optionValues := make([]string, 0, len(options))
for k, v := range options {
optionValues = append(optionValues, k+"="+v)
// Options must be sorted so that the environment variable value is consistent over iterations,
// otherwise the value changes which results in triggering a new deployment.
optionKeys := make([]string, len(options))
i := 0
for k := range options {
optionKeys[i] = k
i++
}
sort.Strings(optionKeys)
optionValues := make([]string, len(options))
for i, k := range optionKeys {
optionValues[i] = k + "=" + options[k]
}
envvar.SetVal(&container.Env, "AB_JOLOKIA_OPTS", strings.Join(optionValues, ","))

Expand Down

0 comments on commit cc1d24b

Please sign in to comment.