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

Build UI Error #244

Closed
KincaidYang opened this issue Apr 21, 2024 · 6 comments · Fixed by #247
Closed

Build UI Error #244

KincaidYang opened this issue Apr 21, 2024 · 6 comments · Fixed by #247
Assignees
Labels
accepted Issue is confirmed and will be worked on bug Confirmed bug or unexpected behavior fixed-in-next-release Issue has already been fixed in the next release

Comments

@KincaidYang
Copy link

Hi @thatmattlove , I encountered some issues. When running for the first time with docker compose up, everything was normal. However, when I stopped it and started again with systemctl start hyperglass, I ran into this problem. The output from systemctl status hyperglass showed that it was running normally, but in reality, it was unusable. Later, after stopping the service, I tried running it again with docker compose up and encountered the following error. I believe that when a file already exists, it should be overwritten or skipped instead of throwing an exception.

root@rttw /www/wwwroot/hyperglass # docker compose up
[+] Running 1/1
 ✔ Network hyperglass_default         Created                                                                                                                                     0.1s 
 ⠋ Container hyperglass-redis-1       Created                                                                                                                                     0.1s 
 ⠋ Container hyperglass-hyperglass-1  Created                                                                                                                                     0.1s 
Attaching to hyperglass-1, redis-1
redis-1       | 1:C 21 Apr 2024 00:55:28.963 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1       | 1:C 21 Apr 2024 00:55:28.963 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1       | 1:C 21 Apr 2024 00:55:28.963 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-1       | 1:M 21 Apr 2024 00:55:28.963 * monotonic clock: POSIX clock_gettime
redis-1       | 1:M 21 Apr 2024 00:55:28.964 * Running mode=standalone, port=6379.
redis-1       | 1:M 21 Apr 2024 00:55:28.964 * Server initialized
redis-1       | 1:M 21 Apr 2024 00:55:28.964 * Ready to accept connections tcp
hyperglass-1  | [INFO] 20240421 00:55:30 | Starting hyperglass {'version': '2.0.0-dev', 'listening': 'http://0.0.0.0:8001', 'workers': 16}
hyperglass-1  | [INFO] 20240421 00:55:31 | Starting UI build {}
hyperglass-1  | [CRITICAL] 20240421 00:56:26 | [Errno 17] File exists: '/etc/hyperglass/static/ui' {}
hyperglass-1  | ╭───────────────────── Traceback (most recent call last) ──────────────────────╮
hyperglass-1  | │ /opt/hyperglass/hyperglass/cli/main.py:61 in _start                          │
hyperglass-1  | │                                                                              │
hyperglass-1  | │    58 │   │   │   if build_complete:                                         │
hyperglass-1  | │    59 │   │   │   │   run(workers)                                           │
hyperglass-1  | │    60 │   │   else:                                                          │
hyperglass-1  | │ ❱  61 │   │   │   run(workers)                                               │
hyperglass-1  | │    62 │                                                                      │
hyperglass-1  | │    63 │   except (KeyboardInterrupt, SystemExit) as err:                     │
hyperglass-1  | │    64 │   │   error_message = str(err)                                       │
hyperglass-1  | │                                                                              │
hyperglass-1  | │ ╭───────────────────── locals ─────────────────────╮                         │
hyperglass-1  | │ │    build = False                                 │                         │
hyperglass-1  | │ │ build_ui = <function build_ui at 0x7f75196f9bc0> │                         │
hyperglass-1  | │ │   kwargs = {'workers': None}                     │                         │
hyperglass-1  | │ │      run = <function run at 0x7f75196f9b20>      │                         │
hyperglass-1  | │ │  workers = None                                  │                         │
hyperglass-1  | │ ╰──────────────────────────────────────────────────╯                         │
hyperglass-1  | │                                                                              │
hyperglass-1  | │ /opt/hyperglass/hyperglass/main.py:180 in run                                │
hyperglass-1  | │                                                                              │
................
╰──────────────────────────────────────────────────────────────────────────────╯
hyperglass-1  | FileExistsError: [Errno 17] File exists: '/etc/hyperglass/static/ui'
hyperglass-1 exited with code 1
@KincaidYang KincaidYang added the possible-bug Something isn't working label Apr 21, 2024
@maluueu
Copy link
Contributor

maluueu commented May 19, 2024

Can be fixed by deleting the build dir before copying to it. I will open a PR @thatmattlove

diff --git a/hyperglass/frontend/__init__.py b/hyperglass/frontend/__init__.py
index 2fe338e..cd0ce5b 100644
--- a/hyperglass/frontend/__init__.py
+++ b/hyperglass/frontend/__init__.py
@@ -131,6 +131,7 @@ async def build_ui(app_path: Path):
         log.error(err)
         raise RuntimeError(str(err)) from err

+    shutil.rmtree(build_dir)
     shutil.copytree(out_dir, build_dir)
     log.bind(src=out_dir, dst=build_dir).debug("Migrated Next.JS build output")

@thatmattlove
Copy link
Owner

Hey @maluueu - Apologies for not merging #246 directly; I was working on a number of other changes and forgot to merge your change beforehand. I did modify your change slightly by using the dirs_exist_ok=True argument to shutil.copytree, but the result is the same. This should be fixed now.

@thatmattlove thatmattlove self-assigned this May 27, 2024
@thatmattlove thatmattlove added accepted Issue is confirmed and will be worked on bug Confirmed bug or unexpected behavior fixed-in-next-release Issue has already been fixed in the next release and removed possible-bug Something isn't working labels May 27, 2024
@maluueu
Copy link
Contributor

maluueu commented May 27, 2024

Hey @maluueu - Apologies for not merging #246 directly; I was working on a number of other changes and forgot to merge your change beforehand. I did modify your change slightly by using the dirs_exist_ok=True argument to shutil.copytree, but the result is the same. This should be fixed now.

Hey @thatmattlove, no worries. Regarding the issue, are you sure that dirs_exist_ok=True fixes it completely?
Consider the following scenario:

  • File A exists in source code
  • project gets build
  • File A is being removed in source
  • project gets build for the new version

Wouldn't this cause File A to still exist in the output dir, rather than being removed fully?

@thatmattlove
Copy link
Owner

Ya know, you're right. If you don't mind, open another PR against the current commit and I'll merge it. Thank you!

@maluueu
Copy link
Contributor

maluueu commented May 29, 2024

Ya know, you're right. If you don't mind, open another PR against the current commit and I'll merge it. Thank you!

sure, will do!

@maluueu
Copy link
Contributor

maluueu commented May 29, 2024

@thatmattlove
done (#247), also set exist_dir to False as that should never happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue is confirmed and will be worked on bug Confirmed bug or unexpected behavior fixed-in-next-release Issue has already been fixed in the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants