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

make acl_policy_path fatal if policy.path is not set #2041

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

kradalby
Copy link
Collaborator

@kradalby kradalby commented Aug 2, 2024

this commit changes and streamlines the dns_config into a new
key, dns. It removes a combination of outdates and incompatible
configuration options that made it easy to confuse what headscale
could and could not do, or what to expect from ones configuration.

It has to go in after #2034 with a rebase as it contains that commit because of
some helpers used there.

Fixes #2024

Signed-off-by: Kristoffer Dalby [email protected]

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration file to manage network policies and database settings, enhancing overall system capabilities.
    • Updated DNS settings in the configuration to improve clarity and accuracy.
  • Bug Fixes

    • Corrected typographical errors in the configuration documentation, improving user understanding.
  • Tests

    • Added a new test case to ensure proper loading of configuration files and validation of policy settings.
  • Chores

    • Renamed ACL policy path key for better clarity and consistency in configuration management.

Copy link

@Greek Greek left a comment

Choose a reason for hiding this comment

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

just a tiny change to config comments

config-example.yaml Outdated Show resolved Hide resolved
@kradalby kradalby force-pushed the kradalby/policy-path branch from e7e8943 to 8cc239e Compare August 19, 2024 07:31
@kradalby kradalby force-pushed the kradalby/policy-path branch from 8cc239e to b6a3012 Compare August 19, 2024 09:44
Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Walkthrough

The recent changes focus on enhancing configuration management within the codebase. Key modifications include correcting documentation typos, enforcing stricter checks for deprecated configuration keys, and introducing new test cases for policy path validation. Additionally, several environment variable keys have been renamed for clarity, reflecting a broader restructuring in how policies are managed. These updates aim to improve system reliability and documentation accuracy, ensuring better user experience and maintenance.

Changes

Files Change Summary
config-example.yaml Fixed typographical errors and updated DNS configuration option from --accept-ds=true to --accept-dns=true.
hscontrol/types/config.go Changed handling of deprecated configuration keys in LoadConfig from warning to fatal error.
hscontrol/types/config_test.go Added a new test case to validate loading of policy path from a configuration file.
hscontrol/types/testdata/policy-path-is-loaded.yaml Introduced a new YAML file with network policy configurations, including security and database settings.
integration/hsic/config.go Renamed environment variable key for ACL policy path from "HEADSCALE_ACL_POLICY_PATH" to "HEADSCALE_POLICY_PATH".
integration/hsic/hsic.go Updated the environment variable key in the WithACLPolicy function from "HEADSCALE_ACL_POLICY_PATH" to "HEADSCALE_POLICY_PATH".

Assessment against linked issues

Objective Addressed Explanation
Ensure ACL policy works post-update (Issue #2024) Changes primarily focus on configuration management and renaming keys; it's unclear if this resolves the specific issue with ACL functionality.

🐇 In the meadow, changes bloom bright,
Configs refined, bringing delight!
Policies now clearer, tests in place,
A safer network, a faster pace.
With hops of joy, we celebrate this feat,
For every fix makes our code complete! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

The alias manager in Cobra has some sharp edges and it seem to
not work as we expect, causing it to have some silent failures with
both config files and ENV. This commits makes the new policy.path
variable mandatory and fixes the issue where the config file would
not load.

Signed-off-by: Kristoffer Dalby <[email protected]>
@kradalby kradalby force-pushed the kradalby/policy-path branch from b6a3012 to 6a4546e Compare August 19, 2024 09:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ac8491e and 6a4546e.

Files selected for processing (6)
  • config-example.yaml (1 hunks)
  • hscontrol/types/config.go (1 hunks)
  • hscontrol/types/config_test.go (1 hunks)
  • hscontrol/types/testdata/policy-path-is-loaded.yaml (1 hunks)
  • integration/hsic/config.go (1 hunks)
  • integration/hsic/hsic.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • config-example.yaml
  • integration/hsic/hsic.go
Additional comments not posted (4)
hscontrol/types/testdata/policy-path-is-loaded.yaml (1)

1-18: Configuration file looks good.

This new YAML file provides a clear and consistent configuration template for testing purposes, aligning with the PR's objectives to manage policy configurations effectively.

integration/hsic/config.go (1)

16-16: Verify the usage of the renamed configuration key.

The key "HEADSCALE_ACL_POLICY_PATH" has been renamed to "HEADSCALE_POLICY_PATH". Ensure that all references to the old key have been updated throughout the codebase to maintain consistency.

Verification successful

Renaming of Configuration Key Verified Successfully

The old key HEADSCALE_ACL_POLICY_PATH has been removed, and the new key HEADSCALE_POLICY_PATH is consistently used in the codebase. The references in integration/hsic/config.go and integration/hsic/hsic.go confirm the successful update.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the renamed configuration key have been updated.

# Test: Search for the old key. Expect: No occurrences of the old key.
rg --type go $'HEADSCALE_ACL_POLICY_PATH'

Length of output: 40


Script:

#!/bin/bash
# Description: Verify the usage of the new configuration key.

# Test: Search for the new key. Expect: Occurrences of the new key.
rg --type go $'HEADSCALE_POLICY_PATH'

Length of output: 193

hscontrol/types/config_test.go (1)

164-182: New test case is well-implemented.

The "policy-path-is-loaded" test case effectively verifies the loading of policy configurations, enhancing the test coverage for configuration management.

hscontrol/types/config.go (1)

295-295: Stricter configuration management is a positive change.

The shift from warnings to fatal errors for deprecated configuration keys enforces stricter adherence to updated configurations, enhancing reliability.

Ensure that this change is communicated to users to prevent unexpected failures due to deprecated configurations.

@kradalby kradalby merged commit 84cb5d0 into juanfont:main Aug 19, 2024
111 checks passed
@masterwishx
Copy link

Beta2 is working fine

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.

[Bug] ACL policy not working after update to v23.0 beta1
4 participants