Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Ansible metrics address flag #3489

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions changelog/fragments/ansible-metrics-addr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
entries:
- description: >
Added `--metrics-addr` flag to ansible operator to make it configurable, and
changed the default from `:8383` to `:8080`

kind: "change"

# Is this a breaking change?
breaking: true

migration:
header: Default ansible operator metrics port changed
body: >
To continue using port 8383, specify `--metrics-addr=:8383` when you start the operator.

3 changes: 1 addition & 2 deletions cmd/ansible-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
var (
metricsHost = "0.0.0.0"
log = logf.Log.WithName("cmd")
metricsPort int32 = 8383
healthProbePort int32 = 6789
)

Expand Down Expand Up @@ -76,7 +75,7 @@ func main() {
// TODO: probably should expose the host & port as an environment variables
options := manager.Options{
HealthProbeBindAddress: fmt.Sprintf("%s:%d", metricsHost, healthProbePort),
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
MetricsBindAddress: f.MetricsAddress,
NewClient: func(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error) {
c, err := client.New(config, options)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/ansible/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Flags struct {
AnsibleVerbosity int
AnsibleRolesPath string
AnsibleCollectionsPath string
MetricsAddress string
}

const AnsibleRolesPathEnvVar = "ANSIBLE_ROLES_PATH"
Expand Down Expand Up @@ -75,4 +76,10 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
"",
"Path to installed Ansible Collections. If set, collections should be located in {{value}}/ansible_collections/. If unset, collections are assumed to be in ~/.ansible/collections or /usr/share/ansible/collections.",
)
flagSet.StringVar(&f.MetricsAddress,
"metrics-addr",
":8080",
"The address the metric endpoint binds to",
)

}