Skip to content

Conversation

@hassankh148
Copy link
Contributor

No description provided.

@hassankh148 hassankh148 requested a review from oshribr April 17, 2024 12:04

@app.route('/batch_execute', methods=['POST'])
def batch_execute():
all_succeeded = True
Copy link

Choose a reason for hiding this comment

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

Instead of returning a boolean, it's better to count successes or failures.
However, since all responses are returned in a dictionary, we don't need this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am following the convention used in all others and already used in single execute command. here success=True indicates that all commands have succeeded, and False otherwise.

app.py Outdated

@app.route('/execute', methods=['POST'])
def execute():
def _execute(request_as_string: str):
Copy link

Choose a reason for hiding this comment

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

Suggested change
def _execute(request_as_string: str):
def _execute(command: str, *arg: str):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conn.execute_command() receives all its arguments as *args including the command itself, so no point in splitting the given full command as command+args.

Copy link

@zcahana zcahana Apr 24, 2024

Choose a reason for hiding this comment

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

I agree with both of you so propose a middleground:

def _execute(command: str):
  • command is the term we use all over the place
  • The as_string suffix is redundant
  • No need for separate command and args

except Exception as err:
response = 'Exception: %s' % str(err)
app.logger.exception("execute err")
return response, success
Copy link

Choose a reason for hiding this comment

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

It might be a good idea to change the return value of success to an error message as a string. In this case, an empty string would indicate success, much like the way Golang handles errors.

Note: by doing so, you will need to fix the web_cli.

https://github.com/RedisLabs/redis-enterprise-operator/blob/main/integration_tests/src/webcli/redis_web_cli_client.py#L52

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea and I agree, but out of scope of this ticket, especially since there are other calls that already follow this convention.

Copy link

@zcahana zcahana left a comment

Choose a reason for hiding this comment

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

Approved with one minor naming suggestion.

app.py Outdated

@app.route('/execute', methods=['POST'])
def execute():
def _execute(request_as_string: str):
Copy link

@zcahana zcahana Apr 24, 2024

Choose a reason for hiding this comment

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

I agree with both of you so propose a middleground:

def _execute(command: str):
  • command is the term we use all over the place
  • The as_string suffix is redundant
  • No need for separate command and args



@app.route('/batch_execute', methods=['POST'])
def batch_execute():
Copy link

Choose a reason for hiding this comment

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

I'm wondering whether this synchronous batch execution model would solve the connection problems we tried to avoid with this change. I thought we'll do an asynchronous batch request and then collect the results. However, let's give it a chance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this synchronous approach was suggested because the flakiness occurred in the integration tests' part, the fix is two-fold, having the batch_execute and reverting redis-webcli-client to use K8s proxy to service. this way we use the more "stable" option and at the same time not overload K8s proxy with 50 requests for each read/write during test_upgrade

app.py Outdated
@app.route('/batch_execute', methods=['POST'])
def batch_execute():
all_succeeded = True
responses = dict()
Copy link

Choose a reason for hiding this comment

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

Actually, a dict is not ideal here because there could be multiple input commands which are similar.
I'd just use a list of responses, with their index matching the index of the input command.

Copy link

@zcahana zcahana left a comment

Choose a reason for hiding this comment

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

Don't forget to rebuild the image (and open a ticket to move it to redislabs/web-cli).

@hassankh148 hassankh148 merged commit 1e651a3 into master Apr 25, 2024
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.

4 participants