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

Config error handling #301

Merged
merged 5 commits into from
Apr 4, 2024
Merged

Config error handling #301

merged 5 commits into from
Apr 4, 2024

Conversation

kthare10
Copy link
Collaborator

@kthare10 kthare10 commented Apr 4, 2024

Addresses following issues:
#300
#299

@kthare10 kthare10 self-assigned this Apr 4, 2024
@kthare10 kthare10 linked an issue Apr 4, 2024 that may be closed by this pull request
@kthare10 kthare10 requested review from paul-ruth and sajith April 4, 2024 15:20
@kthare10 kthare10 merged commit 00a072c into main Apr 4, 2024
14 checks passed
@kthare10 kthare10 linked an issue Apr 4, 2024 that may be closed by this pull request
@kthare10 kthare10 deleted the config-error-handling branch April 4, 2024 17:58
Copy link
Member

@sajith sajith left a comment

Choose a reason for hiding this comment

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

Some minor comments, but hopefully should be okay even without addressing them.

I was also wondering if validate_config() (or the new equivalent) should be done in two steps: generate_ssh_keys() and then verify_config(). This way:

  • The steps would be explicit rather than implicit (no surprises when a validate method attempts to write files); and
  • If someone has ssh keys they've generated themselves, they can still benefit from verify_config().

Comment on lines +798 to +805
dir_path = os.path.dirname(bastion_ssh_config_file)
if not os.path.exists(dir_path):
msg = (
f"Directory {dir_path} does not exist, can not create ssh_config file!"
)
print(msg)
logging.error(msg)
raise Exception(msg)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can attempt to do an os.mkdirs(dir_path) or pathlib.Path(dir_path).mkdir(parents=True) here, and then fail?

)
print(msg)
logging.error(msg)
raise Exception(msg)
Copy link
Member

Choose a reason for hiding this comment

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

Same as previous comment -- we could perhaps attempt to create the directory before failing? Would that be somehow risky?

@sajith
Copy link
Member

sajith commented Apr 4, 2024

Oops, this got merged when I wandered away for a few minutes. :-)

@sajith
Copy link
Member

sajith commented Apr 4, 2024

@kthare10 I will file some issues and start a PR if my suggestions make sense. What do you think?

@kthare10
Copy link
Collaborator Author

kthare10 commented Apr 4, 2024

Agree on attempting to create directory before failing.
Regarding separate verify_config and generate_ssh_keys call.

  • instead have two verify and configure
  • Verify just validates like you suggested
  • configure does all things involving generation of files (keys/ssh_config) or any additional things

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 8557097546

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 17 (17.65%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 21.995%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fabrictestbed_extensions/fablib/fablib.py 3 17 17.65%
Totals Coverage Status
Change from base Build 8232198391: -0.03%
Covered Lines: 1160
Relevant Lines: 4699

💛 - Coveralls

@kthare10 kthare10 restored the config-error-handling branch April 18, 2024 22:08
@kthare10 kthare10 deleted the config-error-handling branch April 18, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants