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

fix importing grafana admin user / password from ansible #937

Merged
merged 6 commits into from
Nov 30, 2020

Conversation

AstroProfundis
Copy link
Contributor

What problem does this PR solve?

Fix #932

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has persistent data change

Related changes

  • Need to cherry-pick to the release branch

Release notes:

fix: custom grafana admin username / password not imported from ansible deployed cluster

@AstroProfundis AstroProfundis added the type/bug-fix Categorizes PR as a bug-fix label Nov 25, 2020
@AstroProfundis AstroProfundis added this to the v1.2.5 milestone Nov 25, 2020
@AstroProfundis AstroProfundis self-assigned this Nov 25, 2020
@codecov-io
Copy link

codecov-io commented Nov 25, 2020

Codecov Report

Merging #937 (0a1cf91) into master (5366a48) will increase coverage by 3.00%.
The diff coverage is 42.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #937      +/-   ##
==========================================
+ Coverage   22.94%   25.94%   +3.00%     
==========================================
  Files         200      236      +36     
  Lines       16011    17743    +1732     
==========================================
+ Hits         3674     4604     +930     
- Misses      11831    12413     +582     
- Partials      506      726     +220     
Flag Coverage Δ
integrate 16.81% <9.09%> (?)
tiup 16.81% <9.09%> (?)
unittest 22.98% <48.27%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cluster/spec/grafana.go 19.37% <0.00%> (-0.79%) ⬇️
pkg/cluster/template/config/grafana.go 0.00% <0.00%> (ø)
pkg/cluster/ansible/inventory.go 54.74% <30.76%> (+0.58%) ⬆️
components/dm/ansible/import.go 62.69% <100.00%> (+0.71%) ⬆️
pkg/cluster/embed/autogen_pkger.go 100.00% <100.00%> (ø)
pkg/cluster/module/wait_for.go 0.00% <0.00%> (ø)
pkg/cluster/module/systemd.go 0.00% <0.00%> (ø)
pkg/cluster/clusterutil/cluster_name.go 0.00% <0.00%> (ø)
pkg/cluster/template/systemd/system.go 0.00% <0.00%> (ø)
pkg/cluster/template/config/prometheus.go 0.00% <0.00%> (ø)
... and 59 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5366a48...0a1cf91. Read the comment docs.

@9547
Copy link
Contributor

9547 commented Nov 27, 2020

@AstroProfundis Please add a test case. :)

@AstroProfundis
Copy link
Contributor Author

This case is already added in the test-data/inventory.ini, it's not a whole new test, but two new fields in the test inventory.

@9547
Copy link
Contributor

9547 commented Nov 27, 2020

Should we apply username/password for DM's case?

case "grafana_admin_user":
case "grafana_admin_password":
or
case "grafana_servers":
for _, host := range group.Hosts {
// Do not fetch the truly used config file of Grafana,
// get port directly from ansible ini files.
port := 3000
if v, ok := host.Vars["grafana_port"]; ok {
if iv, err := strconv.Atoi(v); err == nil {
port = iv
}
}
srv := spec.GrafanaSpec{
Host: host.Vars["ansible_host"],
SSHPort: ansible.GetHostPort(host, cfg),
Port: port,
}
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_grafana.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
}
_, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
}
for k, v := range flags {
// Ignore
_ = v
switch k {
}
}
srv.DeployDir = instancDeployDir(spec.ComponentGrafana, srv.Port, host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir)
topo.Grafanas = append(topo.Grafanas, srv)

@@ -119,10 +119,10 @@ check_for_updates = true
#################################### Security ####################################
[security]
# default admin user, created on startup
;admin_user = admin
admin_user = {{.Username}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the Username is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be set to admin during unmarshal, the default value is set in spec tag

@lucklove lucklove modified the milestones: v1.2.5, v1.2.6 Nov 30, 2020
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 30, 2020
@lucklove
Copy link
Member

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 30, 2020
@lucklove
Copy link
Member

/merge

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 30, 2020
@ti-chi-bot
Copy link
Member

Can merge label has been added.

Git tree hash: 0a1cf91

@ti-chi-bot
Copy link
Member

@AstroProfundis: Your PR has out-of-dated and I have automatically updated it for you.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the tidb-community-bots/ti-community-prow repository.

@ti-chi-bot ti-chi-bot merged commit 7d602d5 into pingcap:master Nov 30, 2020
@AstroProfundis AstroProfundis deleted the fix-932 branch December 1, 2020 03:12
@lucklove lucklove modified the milestones: v1.2.6, v1.3.0 Dec 15, 2020
@AstroProfundis AstroProfundis added the category/monitoring Categorizes issue or PR related to monitoring components. label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/monitoring Categorizes issue or PR related to monitoring components. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/bug-fix Categorizes PR as a bug-fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User defined Grafana username and password not imported from Ansible
5 participants