Skip to content

Removed dev_timeout from junos_cli - #63812

Closed
codekuu wants to merge 5 commits into
saltstack:masterfrom
codekuu:patch-2
Closed

codekuu wants to merge 5 commits into
saltstack:masterfrom
codekuu:patch-2

Conversation

@codekuu

@codekuu codekuu commented Mar 3, 2023

Copy link
Copy Markdown

Removed dev_timeout from junos_cli which passes None as a variable. max() does not like None variable which makes this input mandatory when using junos_cli in salt.

Did also merge the __timeout_decorator and __timeout_decorator_cleanargs into one with comments and more readable code.
This sovles the issue with problems running junos_cli and other commands where the __pubs are exposed and max() is breaking the function since dev_timeout is provided all the time (as None) even if not provided in cli.

What does this PR do?

Fix issues related to napalm junos_cli and other methods.

What issues does this PR fix or reference?

Fixes: #63599 #58108

Previous Behavior

junos_cli was breaking due to timeout_decorator was provided with value None from the dev_timeout variable used in max()

New Behavior

Working

Merge requirements satisfied?

Commits signed with GPG?

No

Removed dev_timeout from junos_cli which passes None as a variable. max() does not like None variable which makes this input mandatory when using junos_cli in salt.

Fixes and related to #63599 #58108
@codekuu
codekuu requested a review from a team as a code owner March 3, 2023 16:53
@codekuu
codekuu requested review from garethgreenaway and removed request for a team March 3, 2023 16:53
Fix issues related to timeout decorator breaking when dev_timeout or timeout variable is a none int.

Merged the timeout_decorator and timeout_decorator_cleankwargs
@codekuu

codekuu commented Mar 3, 2023

Copy link
Copy Markdown
Author

Tests and documentation is already correct for these fixes therefor no new tests or docs.

twangboy
twangboy previously approved these changes Mar 7, 2023
@twangboy twangboy added this to the Sulfur v3006.0 milestone Mar 7, 2023
@codekuu

codekuu commented Apr 19, 2023

Copy link
Copy Markdown
Author

Pinging this

Comment thread salt/modules/junos.py Outdated
Comment on lines +188 to +189
except:
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
except:
raise

Don't catch exceptions just to raise them afterwards without doing anything with that information.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It was done like that before therefor I keept the same functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have to disagree.
Neither this chunk, nor this has an exception caught just to be raised immediately.
There's code that runs, before raising the exception again.

Please remove that bare except, you're not doing anything with it.

@s0undt3ch s0undt3ch added the backport:3006.x Backport PR to 3006.x branch label Apr 27, 2023
@codekuu
codekuu requested a review from s0undt3ch April 28, 2023 13:33
Comment thread salt/modules/junos.py Outdated
Comment on lines +188 to +189
except:
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have to disagree.
Neither this chunk, nor this has an exception caught just to be raised immediately.
There's code that runs, before raising the exception again.

Please remove that bare except, you're not doing anything with it.

Removed except: raise block since it doesn't do anything. Keeping the finalyl since it adds back the kwargs that is needed and sets the timeout to the old timeout.
@codekuu

codekuu commented Apr 28, 2023

Copy link
Copy Markdown
Author

Removed the except: raise part but kept the finally

@codekuu
codekuu requested a review from s0undt3ch April 30, 2023 07:41

@s0undt3ch s0undt3ch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We also need test coverage, the bare minimum is unit testing the decorator code path.

Comment thread salt/modules/junos.py
@wraps(function)
def wrapper(*args, **kwargs):
timeout_changed = False
old_kwargs = kwargs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You actually need to create a copy, most likely, even a copy.deepcopy of the dictionary, otherwise changing kwargs will also change old_kwargs

@codekuu
codekuu temporarily deployed to ci April 30, 2023 09:09 — with GitHub Actions Inactive
@codekuu
codekuu temporarily deployed to ci April 30, 2023 09:09 — with GitHub Actions Inactive
@codekuu
codekuu temporarily deployed to ci April 30, 2023 09:10 — with GitHub Actions Inactive
@codekuu
codekuu temporarily deployed to ci April 30, 2023 12:18 — with GitHub Actions Inactive
@codekuu
codekuu temporarily deployed to ci April 30, 2023 12:18 — with GitHub Actions Inactive
@codekuu
codekuu temporarily deployed to ci April 30, 2023 12:18 — with GitHub Actions Inactive
@anilsil anilsil modified the milestones: Sulfur v3006.1, Sulfur v3006.2 May 3, 2023
@codekuu codekuu closed this by deleting the head repository Oct 11, 2023

This branch was previously deployed

1 inactive deployment
ci — 5e5a8051 Deployed Apr 30, 2023 by codekuu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:3006.x Backport PR to 3006.x branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Deltaproxy and napalm.junos_cli

4 participants