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

Adding a new feature to use commit timer #416

Open
wants to merge 61 commits into
base: main
Choose a base branch
from

Conversation

veyloster
Copy link

SUMMARY

This is about adding a new feature to use commit timer when deploying new config.
Right now there's no option to use it and this is a good mechanism to rollback if a bad configuration is pushed.

ISSUE TYPE

  • Feature Pull Request

ADDITIONAL INFORMATION

Adding a new timer field in the eos_config module which let you set how long you want it to be (Ex: 1m, 30s ...)
You then need to combine this with another task to commit the ansible session.
Other task can be added in between like doing an ssh reset to make sure the device is still reachable after getting the new config.

Copy link
Contributor

@sc68cal sc68cal left a comment

Choose a reason for hiding this comment

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

This should be merged

@sc68cal
Copy link
Contributor

sc68cal commented Jul 11, 2023

This fixes #375

@sc68cal
Copy link
Contributor

sc68cal commented Jul 12, 2023

I think this is failing the tests because you only implemented support for the timer in just the HTTP API class. I think you also need to add it to the CLI class in plugins/cliconf/eos.py

@sc68cal
Copy link
Contributor

sc68cal commented Jul 14, 2023

@veyloster if you are available I would like to connect and discuss. I am on the ansiblenetwork.slack.com slack

@innerhippy
Copy link

@veyloster if you are available I would like to connect and discuss. I am on the ansiblenetwork.slack.com slack

He's on leave until next Tuesday - happy to help if you need

@sc68cal
Copy link
Contributor

sc68cal commented Jul 18, 2023

@innerhippy @veyloster

I have opened veyloster#5 in your fork

@rohitthakur2590 rohitthakur2590 self-requested a review July 20, 2023 05:45
@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/f692dbd509ae43a2a1016b9b3259fa8b

ansible-test-network-integration-eos-httpapi-python39-stable214 FAILURE in 36m 49s
ansible-test-network-integration-eos-httpapi-python39-stable213 FAILURE in 34m 12s
ansible-test-network-integration-eos-httpapi-python39-stable212 FAILURE in 33m 28s
ansible-test-network-integration-eos-httpapi-python39-stable211 FAILURE in 39m 58s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 35m 07s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 RETRY_LIMIT in 1m 05s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 35m 20s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 32m 43s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 32m 55s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 33m 15s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 38m 00s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 32m 25s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 38m 03s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 SUCCESS in 33m 07s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 32m 30s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 33m 20s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 RETRY_LIMIT in 1m 36s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 34m 20s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 31m 44s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 32m 43s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 41s
✔️ ansible-tox-linters SUCCESS in 10m 43s
✔️ ansible-galaxy-importer SUCCESS in 4m 43s

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/03c8b98150994854b0125a815963b386

ansible-test-network-integration-eos-httpapi-python39-stable214 FAILURE in 38m 04s
ansible-test-network-integration-eos-httpapi-python39-stable213 FAILURE in 38m 57s
ansible-test-network-integration-eos-httpapi-python39-stable212 FAILURE in 39m 42s
ansible-test-network-integration-eos-httpapi-python39-stable211 FAILURE in 39m 10s
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 FAILURE in 27m 37s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 FAILURE in 31m 59s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 FAILURE in 27m 58s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 FAILURE in 36m 40s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 FAILURE in 32m 08s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 RETRY_LIMIT in 5m 34s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 FAILURE in 33m 11s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 FAILURE in 30m 55s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 RETRY_LIMIT in 5m 04s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 FAILURE in 31m 41s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 RETRY_LIMIT in 5m 39s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 FAILURE in 31m 32s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 FAILURE in 27m 26s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 FAILURE in 31m 13s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 FAILURE in 27m 56s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 FAILURE in 32m 13s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 49s
ansible-tox-linters FAILURE in 10m 43s
✔️ ansible-galaxy-importer SUCCESS in 4m 37s

@sc68cal
Copy link
Contributor

sc68cal commented Jul 22, 2023

Looks like I goofed on my PR, let me fix

@innerhippy
Copy link

Failure is due to referencing self in non class function

@@ -193,7 +193,9 @@ def edit_config(
commit=True,
replace=None,
comment=None,
**kwargs,
Copy link
Contributor

@sc68cal sc68cal Jul 24, 2023

Choose a reason for hiding this comment

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

my only concern around this change is the fact that the only keyword argument that exists is timer - and i think i would rather refactor all the calls to edit_config rather than introduce kwargs to this function.

Copy link

@innerhippy innerhippy Jul 24, 2023

Choose a reason for hiding this comment

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

I agree it's a bit ugly, but if we change the interface and deviate from CliconfBase, then pylint fails. Not sure if the object instance has any state that contains the timer details?

Copy link
Contributor

Choose a reason for hiding this comment

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

I asked @Qalthos on Slack and they replied with a bit of insight:

https://ansiblenetwork.slack.com/archives/CEXQ0U2RH/p1689792762886269

Choose a reason for hiding this comment

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

Looks like we might be able to do this in edit_config

timer = self.get_option("timer")

But not sure how to test this specific code path.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, I will try out that API call and make a PR to update it, if successful

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/b9dab26e2a38402e9bbd5ddc950c6ada

ansible-test-network-integration-eos-httpapi-python39-stable214 FAILURE in 12m 36s
ansible-test-network-integration-eos-httpapi-python39-stable213 FAILURE in 13m 48s
ansible-test-network-integration-eos-httpapi-python39-stable212 FAILURE in 13m 32s
ansible-test-network-integration-eos-httpapi-python39-stable211 FAILURE in 13m 36s
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 FAILURE in 11m 37s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 FAILURE in 12m 12s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 FAILURE in 12m 07s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 FAILURE in 12m 03s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 FAILURE in 13m 08s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 FAILURE in 12m 33s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 FAILURE in 11m 16s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 FAILURE in 11m 34s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 FAILURE in 11m 09s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 FAILURE in 11m 44s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 FAILURE in 11m 36s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 FAILURE in 11m 34s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 FAILURE in 11m 36s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 FAILURE in 11m 57s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 FAILURE in 11m 20s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 FAILURE in 11m 47s (non-voting)
✔️ build-ansible-collection SUCCESS in 9m 44s
✔️ ansible-tox-linters SUCCESS in 10m 47s
✔️ ansible-galaxy-importer SUCCESS in 4m 19s

@@ -402,6 +423,7 @@ def main():
diff_ignore_lines=dict(type="list", elements="str"),
running_config=dict(aliases=["config"]),
intended_config=dict(),
timer=dict(),
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs a type definition, and if required default value.
timer=dict(type="str" default="")

@@ -171,7 +178,8 @@ def load_config(self, commands, commit=False, replace=False):
"""Loads the config commands onto the remote device"""
conn = self._get_connection()
try:
response = conn.edit_config(commands, commit, replace)
timer = parse_timer(self._module)
response = conn.edit_config(commands, commit, replace, None, timer)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
response = conn.edit_config(commands, commit, replace, None, timer)
response = conn.edit_config(commands, commit, replace,None, timer=timer)

@@ -491,6 +504,35 @@ def get_capabilities(self):
return json.loads(capabilities)


def parse_timer(module):
Copy link
Contributor

Choose a reason for hiding this comment

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

Better place for this would be utils.

@rohitthakur2590
Copy link
Contributor

@veyloster thanks for the work on this feature, I would like to bring more inputs to this,
With this approach if any existing(legacy or resource modules) or new modules want to use this feature we need to expose the timer ; An alternate approach could be having this part of cliconf as an option, which makes it accessible to other modules like eos_banner, user, etc (the ones that are seeing integration test failures).

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

Successfully merging this pull request may close these issues.

4 participants