Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove FLEET_SERVER_POLICY_NAME from container command #25149

Merged
merged 5 commits into from
Apr 22, 2021
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
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- Set --inscure in container when FLEET_SERVER_ENABLE and FLEET_INSECURE set {pull}25137[25137]
- Fixed: limit for retries to Kibana configurable {issue}25063[25063]
- Fix issue with status and inspect inside of container {pull}25204[25204]
- Remove FLEET_SERVER_POLICY_NAME env variable as it was not used {pull}25149[25149]

==== New features

Expand Down
20 changes: 8 additions & 12 deletions x-pack/elastic-agent/pkg/agent/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ The following actions are possible and grouped based on the actions.
FLEET_SERVER_ELASTICSEARCH_PASSWORD - elasticsearch password for Fleet Server [$ELASTICSEARCH_PASSWORD]
FLEET_SERVER_ELASTICSEARCH_CA - path to certificate authority to use with communicate with elasticsearch [$ELASTICSEARCH_CA]
FLEET_SERVER_SERVICE_TOKEN - service token to use for communication with elasticsearch
FLEET_SERVER_POLICY_NAME - name of policy for the Fleet Server to use for itself [$FLEET_TOKEN_POLICY_NAME]
FLEET_SERVER_POLICY_ID - policy ID for Fleet Server to use for itself ("Default Fleet Server policy" used when undefined)
FLEET_SERVER_HOST - binding host for Fleet Server HTTP (overrides the policy)
FLEET_SERVER_PORT - binding port for Fleet Server HTTP (overrides the policy)
Expand Down Expand Up @@ -337,9 +336,6 @@ func buildEnrollArgs(cfg setupConfig, token string, policyID string) ([]string,
if cfg.FleetServer.Elasticsearch.ServiceToken != "" {
args = append(args, "--fleet-server-service-token", cfg.FleetServer.Elasticsearch.ServiceToken)
}
if policyID == "" {
policyID = cfg.FleetServer.PolicyID
}
if policyID != "" {
args = append(args, "--fleet-server-policy", policyID)
}
Expand Down Expand Up @@ -456,15 +452,17 @@ func kibanaClient(cfg kibanaConfig) (*kibana.Client, error) {
}

func findPolicy(cfg setupConfig, policies []kibanaPolicy) (*kibanaPolicy, error) {
policyID := ""
policyName := cfg.Fleet.TokenPolicyName
if cfg.FleetServer.Enable {
policyName = cfg.FleetServer.PolicyName
policyID = cfg.FleetServer.PolicyID
}
for _, policy := range policies {
if policy.Status != "active" {
continue
}
if policyName != "" {
if policyID != "" {
if policyID == policy.ID {
return &policy, nil
}
} else if policyName != "" {
ruflin marked this conversation as resolved.
Show resolved Hide resolved
if policyName == policy.Name {
return &policy, nil
}
Expand Down Expand Up @@ -836,7 +834,6 @@ type fleetServerConfig struct {
Host string `config:"host"`
InsecureHTTP bool `config:"insecure_http"`
PolicyID string `config:"policy_id"`
PolicyName string `config:"policy_name"`
Port string `config:"port"`
}

Expand Down Expand Up @@ -889,8 +886,7 @@ func defaultAccessConfig() (setupConfig, error) {
Enable: envBool("FLEET_SERVER_ENABLE"),
Host: envWithDefault("", "FLEET_SERVER_HOST"),
InsecureHTTP: envBool("FLEET_SERVER_INSECURE_HTTP"),
PolicyID: envWithDefault("", "FLEET_SERVER_POLICY_ID"),
PolicyName: envWithDefault("", "FLEET_SERVER_POLICY_NAME", "FLEET_TOKEN_POLICY_NAME"),
PolicyID: envWithDefault("", "FLEET_SERVER_POLICY_ID", "FLEET_SERVER_POLICY"),
Port: envWithDefault("", "FLEET_SERVER_PORT"),
},
Kibana: kibanaConfig{
Expand Down