Apisix-dashboard: bug: manager-api -p doesn't work

Created on 29 Dec 2020  Â·  11Comments  Â·  Source: apache/apisix-dashboard

Bug report

Describe the bug

manager-api -p parameter doesn't work, it will prompt panic: fail to read configuration: ./conf/conf.yaml

  1. move output to another dir
  2. use ln -s create manager-api soft links to /usr/bin
  3. use manager-api -p /path/to/output
  4. it will prompt panic: fail to read configuration: ./conf/conf.yaml

@nic-chen

backend bug

Most helpful comment

+1 for same issue.

After digging deeper into this issue, I found that conf.WorkDir would always be ., cause the config initialization process defined in the init() function under github.com/apisix/manager-api/internal/log package would be definitely executed in prior to setting Cobra command flags.

So I could get through with this via commenting out https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/conf/conf.go#L103-L106 .

While if proceed, I would still got the following error:

➜  apache-apisix ./manager-api -p output
panic: couldn't open sink "logs/error.log": open logs/error.log: no such file or directory
goroutine 1 [running]:
github.com/apisix/manager-api/internal/log.fileWriter(0x1010200, 0x1650e252fc378834, 0xc00039fdf0)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:98 +0x208
github.com/apisix/manager-api/internal/log.GetLogger(0x0, 0x14)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:38 +0x3f
github.com/apisix/manager-api/internal/log.InitLogger(...)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:35
github.com/apisix/manager-api/internal/log.init.0()
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:32 +0x26

The reason of this log error is the same as conf.WorkDir . So I commented out https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/log/zap.go#L30-L33

Then I added log.InitLogger() after the line of code: https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/cmd/managerapi.go#L59

After done all the above, the bugs gone and everything worked fine. While honestly speaking, I'm not quite sure about the relationship between the integration tests and those two init() functions (See the TODO comments above the original code). You will be much appreciated if anyone can elaborate on it? Thanks.

All 11 comments

image

The conf path will append the conf/conf.yaml, it's not the filename of configuration, but the super path of it.

We may need to change it, it's not so intuitive.

Will this be addressed in M2.3?

Will this be addressed in M2.3?

confirm

who is going to take this?

@nic-chen @tokers What is your opinion?

@nic-chen @tokers What is your opinion?

yes,we need to fix in M2.3

+1 for same issue.

After digging deeper into this issue, I found that conf.WorkDir would always be ., cause the config initialization process defined in the init() function under github.com/apisix/manager-api/internal/log package would be definitely executed in prior to setting Cobra command flags.

So I could get through with this via commenting out https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/conf/conf.go#L103-L106 .

While if proceed, I would still got the following error:

➜  apache-apisix ./manager-api -p output
panic: couldn't open sink "logs/error.log": open logs/error.log: no such file or directory
goroutine 1 [running]:
github.com/apisix/manager-api/internal/log.fileWriter(0x1010200, 0x1650e252fc378834, 0xc00039fdf0)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:98 +0x208
github.com/apisix/manager-api/internal/log.GetLogger(0x0, 0x14)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:38 +0x3f
github.com/apisix/manager-api/internal/log.InitLogger(...)
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:35
github.com/apisix/manager-api/internal/log.init.0()
    /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:32 +0x26

The reason of this log error is the same as conf.WorkDir . So I commented out https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/log/zap.go#L30-L33

Then I added log.InitLogger() after the line of code: https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/cmd/managerapi.go#L59

After done all the above, the bugs gone and everything worked fine. While honestly speaking, I'm not quite sure about the relationship between the integration tests and those two init() functions (See the TODO comments above the original code). You will be much appreciated if anyone can elaborate on it? Thanks.

Hi, @imjoey

I'm not quite sure about the relationship between the integration tests and those two init() functions

Because we did not have E2E testing before, it is a quick solution to integrate ETCD directly in the unit test.

PR is welcome. You could just fix this bug, because we need more time to completely remove the integration of ETCD in the unit test.

@nic-chen @tokers How to fix this bug in M2.3? any suggested steps are welcome.

Hi, @imjoey

I'm not quite sure about the relationship between the integration tests and those two init() functions

Because we did not have E2E testing before, it is a quick solution to integrate ETCD directly in the unit test.

PR is welcome. You could just fix this bug, because we need more time to completely remove the integration of ETCD in the unit test.

@nic-chen thanks for your guide. OK, I will propose a PR to fix this first.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Applenice picture Applenice  Â·  4Comments

imjoey picture imjoey  Â·  6Comments

membphis picture membphis  Â·  6Comments

chenyicai picture chenyicai  Â·  4Comments

moonming picture moonming  Â·  6Comments