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

feat: Remove automate in main #95

Merged
merged 6 commits into from
May 4, 2023
Merged

feat: Remove automate in main #95

merged 6 commits into from
May 4, 2023

Conversation

gretelliz
Copy link
Contributor

@gretelliz gretelliz commented Apr 28, 2023

Closes #77

Summary

According to main.py, as well as TRIGGER_SCHEDULE_TRACES, TRIGGER_IMPORTANT_CIRCUITS and FIND_CIRCUITS_IN_FLOWS set to False, automate.py does not seem to be needed. So, this is to remove the dependency of main.py to automate.py.
Then, automate.py won't be used anymore and issue #39 is not needed.
Instead, a timeout has been added to the requests from stored_flows to flow_manager.

Local Tests

Everything seems to continue working well.

2023-04-28 14:47:37,787 - INFO [kytos.napps.kytos/mef_eline] (mef_eline) EVC(6875c026f20a4b, epl) was deployed.
2023-04-28 14:47:37,788 - INFO [kytos.napps.kytos/mef_eline] (mef_eline) EVC(5b1147f173c84a, epl) enabled but inactive - redeploy

/traces call example:

[
    {
        "trace": {
            "switch": {
                "dpid": "00:00:00:00:00:00:00:01",
                "in_port": 1
            },
            "eth": {
      "         dl_vlan": 10
            }
        }
  }
]

{
    "result": [
        [
            {
                "dpid": "00:00:00:00:00:00:00:01",
                "port": 1,
                "time": "2023-04-28 14:42:30.554977",
                "type": "starting"
            },
            {
                "dpid": "00:00:00:00:00:00:00:02",
                "out": null,
                "port": 2,
                "time": "2023-04-28 14:42:30.555051",
                "type": "incomplete"
            }
        ]
    ]
}

End-to-End Tests

N/A

@gretelliz gretelliz requested a review from a team as a code owner April 28, 2023 19:14
automate.py Outdated Show resolved Hide resolved
settings.py Outdated Show resolved Hide resolved
utils.py Outdated Show resolved Hide resolved
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

It's almost there @gretelliz, asked minor changes.

Also, when locally exploring it, make sure that you've seen the @retry decorator work at least once. The easiest way you can keep a local code change raising one of the retried exceptions like raise Timeout(...) and observing. Finally, please, add a unit test simulating a side effect raising http 424, and then ensuring that /traces and /trace will return the expected response.

main.py Outdated Show resolved Hide resolved
tests/unit/test_utils.py Outdated Show resolved Hide resolved
utils.py Outdated Show resolved Hide resolved
@viniarck
Copy link
Member

viniarck commented May 3, 2023

@gretelliz nicely done, looks good to me.

Did you run a local exploratory test to see the retry decorator working at least once? It looks good, but waiting for this confirmation before approving. Also, unfortunately you'll need to solve some git conflicts since chore/starlette has landed #94.

@gretelliz
Copy link
Contributor Author

@viniarck, I temporarily modified flow_manager to sleep(100) before returning stored_flows.
Then, with /traces:

{
     "description": "It couldn't get stored_flows",
     "code": 424
}
2023-05-04 12:51:00,490 - WARNING [kytos.core.retry] (AnyIO worker thread) Retry #1 for get_stored_flows, args: (), kwargs: {}, seconds since start: 20.01
2023-05-04 12:51:20,660 - WARNING [kytos.core.retry] (AnyIO worker thread) Retry #2 for get_stored_flows, args: (), kwargs: {}, seconds since start: 40.18

I had to change mef_eline to catch Timeout, because it just caught ConnectTimeout and it failed in the local test.
Now:

2023-05-04 13:14:41,933 - WARNING [kytos.core.retry] (AnyIO worker thread) Retry #1 for get_stored_flows, args: (), kwargs: {}, seconds since start: 20.00
2023-05-04 13:14:51,901 - ERROR [kytos.napps.kytos/mef_eline] (mef_eline) Request has timed out: HTTPConnectionPool(host='localhost', port=8181): Read timed out. (read timeout=30)
2023-05-04 13:15:02,080 - WARNING [kytos.core.retry] (AnyIO worker thread) Retry #2 for get_stored_flows, args: (), kwargs: {}, seconds since start: 40.15

Note that I merged master and PR#94 is considered.
Now, when I start kytos I get this error:

2023-05-04 13:29:08,907 - ERROR [kytos.napps.kytos/mef_eline] (MainThread) Could not load EVC: dict={...

Do you have any ideas?

@viniarck
Copy link
Member

viniarck commented May 4, 2023

2023-05-04 13:29:08,907 - ERROR [kytos.napps.kytos/mef_eline] (MainThread) Could not load EVC: dict={...


Do you have any ideas?

@gretelliz, overall looks good.

Do you have the rest of error content? It's coming from _evc_from_dict, I wouldn't expect it to fail.

@viniarck viniarck self-requested a review May 4, 2023 20:18
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

Nicely done @gretelliz.

It turns out the mentioned error wasn't related to this PR, it was the order that the NApp was loading, so running a touch kytos.json solved it.

@gretelliz gretelliz merged commit ad70c00 into master May 4, 2023
@gretelliz gretelliz deleted the feature/housekeeping branch May 4, 2023 20:20
@gretelliz
Copy link
Contributor Author

Thank you, @viniarck

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.

Review the use case for scheduled traces and housekeeping
2 participants