Skip to content

Conversation

@atoniolo76
Copy link

Fixes #7874

The warning about misaligned client/server config was appearing twice per command execution. This adds a per-run_id cache to deduplicate warnings within a single command while still showing them for new commands.

Tested:

  • Ran 'sky show-gpus --infra k8s' successfully
  • Warning now appears once instead of twice
  • Later commands with a different run_id still show the warning
  • Created _WARNED_DISALLOWED_KEYS_CACHE and lock to keep track of warnings logged for a run_id
  • Changed override_skypilot_config() function so that before logging a warning, it checks a little cache keyed by the current command’s run_id
  • Resets when run_id changes

Tested (run the relevant ones):

  • [*] Code formatting: install pre-commit (auto-check on commit) or bash format.sh
  • [*] Any manual or new tests for this PR (please specify below)
    sky show-gpus --infra k8s
  • All smoke tests: /smoke-test (CI) or pytest tests/test_smoke.py (local)
  • Relevant individual tests: /smoke-test -k test_name (CI) or pytest tests/test_smoke.py::test_name (local)
  • Backward compatibility: /quicktest-core (CI) or pytest tests/smoke_tests/test_backward_compat.py (local)

Fixes skypilot-org#7874

The warning about misaligned client/server config was appearing twice
per command execution. This adds a per-run_id cache to deduplicate
warnings within a single command while still showing them for new
commands.

Tested:
- Manually verified with 'sky show-gpus --infra k8s'
- Warning now appears once instead of twice
- Subsequent commands still show the warning (different run_id)
@Michaelvll
Copy link
Collaborator

Thanks @atoniolo76! Could you help fix the CI failure and add a unit test for your implementation?

@atoniolo76
Copy link
Author

@Michaelvll Good to go!

Copy link
Collaborator

@SeungjinYang SeungjinYang left a comment

Choose a reason for hiding this comment

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

Thanks @atoniolo76! Couple of minor comments, and the PR should be ready to go.

'and will be ignored. Remove these keys to disable this warning. '
'If you want to specify it, please modify it on server side or '
'contact your administrator.')
run_id = os.environ.get(usage_constants.USAGE_RUN_ID_ENV_VAR)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about using common_utils.get_usage_run_id here instead?

Copy link
Author

Choose a reason for hiding this comment

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

Env var is always set but I agree this is cleaner

Fixes skypilot-org#7874

The warning about misaligned client/server config was appearing twice
per command execution. This adds a per-run_id cache to deduplicate
warnings within a single command while still showing them for new
commands.

Tested:
- Manually verified with 'sky show-gpus --infra k8s'
- Warning now appears once instead of twice
- Subsequent commands still show the warning (different run_id)
…clearing when it exceeds 1000 warning entries
@atoniolo76 atoniolo76 force-pushed the fix-duplicate-config-warning branch from 2b76478 to 55fc731 Compare December 3, 2025 20:27
@atoniolo76
Copy link
Author

@SeungjinYang I have implemented your suggestions and updated the associated unit test. Ready to merge?

@SeungjinYang
Copy link
Collaborator

SeungjinYang commented Dec 4, 2025

@SeungjinYang I have implemented your suggestions and updated the associated unit test. Ready to merge?

There's something that I'm hesitant about with merging this PR. Cache in this case is in-memory, so its state are not shared between processes. In cases such as sky exec as referenced in the issue, the reason the warning message prints twice is because the CLI submits two API requests to the server (one to exec, another to tail the execution log), and there is no guarantee that the two request lands on the same server process. If the two requests don't land on the same server process, then in the perspective of each server process, it would be encountering the run id for the first time - and still print two warning messages.

The part that perplexed me was the fact that the unit test clearly works, and your local test clearly works. Given the explanation above, it makes sense why unit test introduced may not be testing the case where two API request lands on two different processes. As for local test, I believe local API uses a single server process by default, so a locally spun up API server would not run into the issue described above.

A remotely deployed team API server, on the other hand, can and do have multiple server processes, and I think the change proposed may not function reliably in such cases.

I believe to guard against this scenario, the cache would have to be set up in a way that multiple processes can share the cache state.

@atoniolo76
Copy link
Author

@SeungjinYang Didn't think about the remote scenario, moved to a shared solution. Made a new pr too, closing this one

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.

[UX] Hint for misaligned config from client and server appear twice

3 participants