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

P4Runtime : Status Code additions #545

Merged
merged 8 commits into from
Nov 19, 2021
Merged

Conversation

donNewtonAlpha
Copy link
Contributor

This PR adds batch operation functions and additional Status Codes necessary for the updated API coming in the follow on PR.

bocon13
bocon13 previously approved these changes Oct 22, 2021
@bocon13
Copy link
Contributor

bocon13 commented Oct 22, 2021

cc: @mint570 @ravi861 @prsunny

// In set(), the op is ignored.
void set(const std::vector<KeyOpFieldsValuesTuple>& values);

void del(const std::vector<std::string>& keys);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add unit test on these two new APIs?
We can add the test in redis_state_ut.cpp or redis_piped_state_ut.cpp.
(I can help in this if needed.)

Copy link
Contributor

Choose a reason for hiding this comment

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

@donNewtonAlpha
We have provided the unit test for these. Please integrate them into this pr when you have time. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

these APIs are removed

@prsunny
Copy link
Contributor

prsunny commented Oct 23, 2021

Please give a link to HLD for this change.

@bocon13
Copy link
Contributor

bocon13 commented Oct 25, 2021

Please give a link to HLD for this change.

Batch updates are introduced and required by the P4Orch:
https://github.com/pins/SONiC/blob/master/doc/pins/p4orch_hld.md#p4orch-managers

@bocon13
Copy link
Contributor

bocon13 commented Oct 27, 2021

@qiluo-msft what do you think about this new API?

@qiluo-msft
Copy link
Contributor

qiluo-msft commented Nov 8, 2021

Please change the PR title to more descriptive. People in the swss-common context do not know PINS, Pr2, batch ops.


In reply to: 963379161

@donNewtonAlpha donNewtonAlpha changed the title PINS: Pr2 batch ops P4Runtime : Status Code additions Nov 8, 2021
* Add batch set/delete() to ProducerStateTable
* Add StatusCode enum and functions to convert between
  string and enum values.
* Allow exists() to check for whitespace.
  This is only to allow whitespace when we check for
  existence. We can already create entries with whitespace.
* Add SWSS return code SWSS_RC_UNIMPLEMENTED
* Fix json error, refer to nlohmann/json#590

Submission containing materials of a third party:
    Copyright Google LLC; Licensed under Apache 2.0

Co-authored-by: Akarsh Gupta <[email protected]>
Co-authored-by: Jay Hu <[email protected]>
Co-authored-by: Manali Kumar <[email protected]>
Co-authored-by: Robert J. Halstead <[email protected]>
Co-authored-by: Runming Wu <[email protected]>
Co-authored-by: Yilan Ji <[email protected]>

Signed-off-by: Don Newton [email protected]
common/producerstatetable.h Outdated Show resolved Hide resolved
@@ -5394,7 +5394,7 @@ class basic_json
{
assert(lhs.m_value.array != nullptr);
assert(rhs.m_value.array != nullptr);
return *lhs.m_value.array < *rhs.m_value.array;
return (*lhs.m_value.array) < *rhs.m_value.array;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a fix from upstream: nlohmann/json#590

@@ -1,6 +1,7 @@
#pragma once

#include <memory>
#include <vector>
Copy link
Contributor

@bocon13 bocon13 Nov 9, 2021

Choose a reason for hiding this comment

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

This is missing import. std::vector is used below.

Comment on lines 630 to 634
if (key.find_first_of(" \t") != string::npos)
{
SWSS_LOG_ERROR("EXISTS failed, invalid space or tab in single key: %s", key.c_str());
throw runtime_error("EXISTS failed, invalid space or tab in single key");
}
Copy link
Contributor

@bocon13 bocon13 Nov 9, 2021

Choose a reason for hiding this comment

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

@mint570 @rhalstea I don't think we have any whitespace in our keys. Can/should we revert this change? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Reverted

@bocon13
Copy link
Contributor

bocon13 commented Nov 9, 2021

@qiluo-msft this PR is cleaned up now. Please take a look

namespace swss {

enum class StatusCode {
SWSS_RC_SUCCESS,
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 9, 2021

Choose a reason for hiding this comment

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

SWSS_RC_SUCCESS

Which repoes will use the constants in this file? if only swss, we can move this file to swss repo. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Also p4rt (pins-infra repo)

SWSS_RC_UNKNOWN,
};

static std::map<StatusCode, std::string> statusCodeMapping = {
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 9, 2021

Choose a reason for hiding this comment

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

Also add const ? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

{"SWSS_RC_UNKNOWN", StatusCode::SWSS_RC_UNKNOWN},
};

inline std::string statusCodeToStr(const StatusCode& status) {
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 9, 2021

Choose a reason for hiding this comment

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

inline

also add static #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Done


enum class StatusCode {
SWSS_RC_SUCCESS,
SWSS_RC_INVALID_PARAM,
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 9, 2021

Choose a reason for hiding this comment

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

The repo is using 4-space indentation. Please follow with similar code. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

@donNewtonAlpha
Copy link
Contributor Author

@qiluo-msft @prsunny @bocon13
Hi Prince, Qi,
All the tests have passed on this PR, can we get this merged?
Don

@qiluo-msft
Copy link
Contributor

Please resolve the conflicts. Possibly by rebase your PR to latest master branch.

@donNewtonAlpha
Copy link
Contributor Author

@qiluo-msft This now shows able to merge the tests are re-running.

@qiluo-msft
Copy link
Contributor

Please check the build failure

saiaclschema_ut.cpp:1:10: fatal error: gmock/gmock.h: No such file or directory
 #include <gmock/gmock.h>
          ^~~~~~~~~~~~~~~

@donNewtonAlpha
Copy link
Contributor Author

donNewtonAlpha commented Nov 17, 2021 via email

@StephenWangGoogle
Copy link

I was just looking at that but it doesn't make sense to me. In azure-pipelines.yml we definitely add that. Is there something else we need to do? sudo apt-get install -y python3-pip sudo pip3 install pytest sudo apt-get install -y python sudo apt-get install cmake libgtest-dev sudo apt-get install cmake libgtest-dev libgmock-dev cd /usr/src/gtest && sudo cmake . && sudo make displayName: "Install dependencies" - script: |

On Wed, Nov 17, 2021 at 4:29 PM Qi Luo @.***> wrote: Please check the build failure saiaclschema_ut.cpp:1:10: fatal error: gmock/gmock.h: No such file or directory #include <gmock/gmock.h> ^~~~~~~~~~~~~~~ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#545 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ4SJM7QHIVPIDBOIOB4DTUMQNCNANCNFSM5GQYHZUA .

Hmm, this file is not added by this PR. Is the tip of the tree broken?

@donNewtonAlpha
Copy link
Contributor Author

donNewtonAlpha commented Nov 17, 2021 via email

@bocon13
Copy link
Contributor

bocon13 commented Nov 17, 2021

Hmm, this file is not added by this PR. Is the tip of the tree broken?

Yes, #556 seems to have broken master. Somehow gmock is missing from the buildimage container.

Update: master and 202012 share a tag, so our builder container reverted and we lost the dependency.
https://github.com/Azure/sonic-buildimage/blob/5a56659b61ccbc7eec4e18bdadc0a151b33d4b28/.azure-pipelines/docker-sonic-slave-template.yml#L91

@donNewtonAlpha
Copy link
Contributor Author

donNewtonAlpha commented Nov 17, 2021 via email

@donNewtonAlpha
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@donNewtonAlpha
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bocon13
Copy link
Contributor

bocon13 commented Nov 18, 2021

Probably what needs to be done is the sonic-buildimage commit that adds in gmock should be backported to all active branches Don

Asked for the backport here:
sonic-net/sonic-buildimage#8950 (comment)

@StephenWangGoogle
Copy link

/azpw run

1 similar comment
@donNewtonAlpha
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenWangGoogle
Copy link

@qiluo-msft can you approve again? The rebase removed the approval

@donNewtonAlpha
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@donNewtonAlpha
Copy link
Contributor Author

@qiluo-msft @prsunny all tests have passed can we get this merged now?

@qiluo-msft qiluo-msft merged commit 1dfe06f into sonic-net:master Nov 19, 2021
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.

None yet

7 participants