8000 initial impl of running export/import without serving by DGuhr · Pull Request #15056 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

initial impl of running export/import without serving - #15056

Merged
pedroigor merged 2 commits into
keycloak:mainfrom
DGuhr:10815_avoid_httpserver_start
Jan 12, 2023
Merged

pedroigor merged 2 commits into
keycloak:mainfrom
DGuhr:10815_avoid_httpserver_start

Conversation

@DGuhr
@DGuhr DGuhr commented Oct 20, 2022
Copy link
Copy Markdown
Contributor

draft pr for solving discussion #10815 - tested the following scenarios manually for now:

use-case 1:

  1. start keycloak in prod mode w/ postgres on port 8080 and http enabled (no strict/strict-https), config set via keycloak.conf (to be able to export from external database). add some test data to realm
  2. stop keycloak
  3. run python3 -m http.server 8080 to bind the port
  4. open localhost:8080 to see that current dir is served instead of keycloak (just to make sure)
  5. run ./kc.sh export --dir=../export
  6. check results -> output does not show http related error, yay! the generated files are also where they should be, double-yay.

use-case 2:

  1. delete export directory
  2. start keycloak as before in prod mode
  3. in another shell window, run the export command again while keycloak is working
  4. see the files are generated correctly, no error is thrown.

use-case 3:
Generally: importing when port is bound via python3 -m http.server 8080 and keycloak is not running
=> works as expected

use-case 4:
importing when keycloak is running (manually added a client to the export json) => works also (which might create some problems?)

@pedroigor PTAL if this moves in the right direction and/or if you miss sth. I don't have much time to look further this week, but I don't think it's that important atm. Happy if anyone wants to take this over from here btw, cc @yeroc @psachmann @vmuzikar

@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch from dd3b03d to 0dcdf34 Compare October 20, 2022 10:01
@pedroigor
Copy link
Copy Markdown
Contributor

I did not try it out but it looks good to me. Thanks for this initial work.

I can take it over and add a test. I think that is what is missing, basically.

@pedroigor
pedroigor self-requested a review October 20, 2022 11:43
@pedroigor pedroigor self-assigned this Oct 20, 2022
@DGuhr
DGuhr commented Oct 20, 2022 •
Copy link
Copy Markdown
Contributor Author

@pedroigor yeh, basically that's it, but there are some assumptions from my side for it to be "okay":

  • the startup logs still state that we're serving when starting up in import/export mode, but we're not, so maybe we want to check and add a msg instead
  • it is ok to export/import on a running kc instance (i don't exactly know the current behaviour without these changes, tbh) -> if not, we may want to somehow check if kc is already running and not allow to import (at least), but that may get a bit tricky

When you say these are fine, then it's really just a missing test (assuming CI gets green)

edit: The failing test is btw flaky for months, see e.g. here

@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch from 0dcdf34 to 23cd706 Compare October 21, 2022 06:15
@pedroigor
Copy link
Copy Markdown
Contributor

@DGuhr Not sure what entry in the logs indicates that we're serving requests. The Listening on message is not there so I think we are fine.

I don't think we should check if an instance is already running when exporting/importing. As you said, it would be a bit tricky to achieve it.

I updated the tests here pedroigor@836b979. If you can update this PR, I think we can move it forward.

@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch 2 times, most recently from 836b979 to 0107c9b Compare October 25, 2022 05:55
@DGuhr
DGuhr commented Oct 25, 2022
Copy link
Copy Markdown
Contributor Author

@pedroigor updated, thanks!

  • you are right, "Listening on" is not shown. I really thought I had seen it when I tried, but just double-checked and it works. :)
    One could also think about changing the 2022-10-25 07:57:41,173 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: Base URL: <unset>, Hostname: <request>, Strict HTTPS: false, Path: <request>, Strict BackChannel: false, Admin URL: <unset>, Admin: <request>, Port: -1, Proxied: false log message to show sth like "Keycloak does not serve requests in this mode" instead of what's shown here, but I don't think that's important, wdyt?

  • Agree to the import behaviour. As long as it doesn't change the current behaviour (which it does not, so it's generally possible to import/export when kc is running, but not recommended to do so because of possible side-effects, just checked it and we clearly state it in the importExport doc - "Your Keycloak server instance must not be started when invoking this command.") we're fine and I'll put this PR out of draft state.

@DGuhr
DGuhr marked this pull request as ready for review October 25, 2022 06:07
@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch 2 times, most recently from fb28172 to 197290a Compare October 26, 2022 15:27
@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch 2 times, most recently from 7e0591f to 04f99c8 Compare November 10, 2022 15:56
@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch from 04f99c8 to 0381428 Compare November 23, 2022 11:58
@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch from 0381428 to e164ebd Compare January 11, 2023 16:35
@DGuhr
DGuhr commented Jan 11, 2023
Copy link
Copy Markdown
Contributor Author

@pedroigor this one went stale, I just updated it to fix the merge conflicts. feel free to give it another try after CI hopefully turns green, and happy new year :)

@pedroigor pedroigor left a comment
Copy link
Copy Markdown
Contributor
< 8000 a href="#pullrequestreview-1244535792" class="d-none">

Choose a reason for hiding this comment

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

Hey @DGuhr, thanks for the update. Glad you are still around.

LGTM and we can have it once GHA is happy.

@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch 2 times, most recently from 2f30ee2 to eb896af Compare January 12, 2023 07:46
@DGuhr
DGuhr force-pushed the 10815_avoid_httpserver_start branch from eb896af to c0af1f7 Compare January 12, 2023 08:44
@pedroigor
pedroigor merged commit 6ac65f6 into keycloak:main Jan 12, 2023
@pedroigor
Copy link
Copy Markdown
Contributor

@DGuhr Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0