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

Replace ec2-user with gcp-user (demisto-sdk) #3828

Merged
merged 33 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
253c2ab
Replace ec2-user with gcp-user
samuelFain Nov 28, 2023
971f52c
update poetry.lock
samuelFain Dec 20, 2023
460b6df
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Dec 20, 2023
eb69da3
checkout poetry.lock from master
samuelFain Dec 20, 2023
1cc0965
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Dec 20, 2023
fe2010b
checkout poetry.lock from master
samuelFain Dec 20, 2023
0b21b4c
testing logging in mock_server.py
samuelFain Dec 21, 2023
0aa87d1
add logs to mock_server_py
samuelFain Dec 21, 2023
d9d4b2c
Add logs
samuelFain Dec 21, 2023
763da33
Change lo_warning to log_info
samuelFain Dec 24, 2023
dc830b3
Add logs
samuelFain Dec 25, 2023
e9fec8e
Add logs
samuelFain Dec 25, 2023
dc4367e
Add logs to move_mock_file_to_repo
samuelFain Dec 25, 2023
eb5d720
Fix broken logs
samuelFain Dec 25, 2023
7081075
Add commit_mock_file function logs
samuelFain Dec 25, 2023
171b48e
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Dec 25, 2023
c993b5a
Add logs
samuelFain Dec 26, 2023
8fee659
Update mock repo on all branches and not just master
samuelFain Dec 26, 2023
01e0164
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Dec 26, 2023
5b75ec0
Add logs to push_mock_files
samuelFain Dec 27, 2023
f1ebe8d
Remove log that caused attribute error
samuelFain Dec 27, 2023
0452d04
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Dec 27, 2023
16e4b21
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Mar 6, 2024
5230cbf
Revert init changes in MITMProxy
samuelFain Mar 14, 2024
708c054
Remove debug logs
samuelFain Mar 14, 2024
310d9df
Remove redundant debugging logs and variables
samuelFain Mar 14, 2024
2608cb1
Revert redundant spacing
samuelFain Mar 14, 2024
ed5c908
Remove redundant import
samuelFain Mar 17, 2024
880663a
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Mar 17, 2024
0f214f9
Add changelog file
samuelFain Mar 17, 2024
86119a9
Remove misleading log; Format
samuelFain Mar 17, 2024
9656e04
Merge branch 'master' into devbug/CIAC-8955/replace-ec3-user-in-demis…
samuelFain Mar 17, 2024
5324015
Update 3828.yml
samuelFain Mar 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/3828.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Update file paths in test_content from ec2-user to gcp-user.
type: fix
pr_number: 3828
2 changes: 1 addition & 1 deletion demisto_sdk/commands/test_content/Docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _build_stats_cmd(cls, server_ip, docker_images):
"""Builds docker stats and grep command string.

Example of returned value:
ssh -o StrictHostKeyChecking=no ec2-user@server_ip
ssh -o StrictHostKeyChecking=no gcp-user@server_ip
'sudo docker stats --no-stream --no-trunc --format "{{json .}}" | grep -Ei "demistopython33.7.2.214--"'
Grep is based on docker images names regex.

Expand Down
9 changes: 6 additions & 3 deletions demisto_sdk/commands/test_content/mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def push_mock_files(self):
f"Failed pushing mock files with error: {exc}", real_time=True
)
finally:
self.logging_module.debug(
"Successfully pushed new/updated mock files to mock git repo.", real_time=True
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually know it was successful if it is in the finally section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't. While there are logs for when an Exception is caught, we can't reliably confirm the success of the push, which might be misleading. Removing this log.

)
self.content_data_lock.release()

def configure_proxy_in_demisto(
Expand Down Expand Up @@ -403,7 +406,7 @@ def normalize_mock_file(self, playbook_or_integration_id: str, path: str = None)
path, get_log_file_path(playbook_or_integration_id, record=True)
)
command = (
"/home/ec2-user/.local/bin/mitmdump -ns ~/timestamp_replacer.py "
f"/home/{SSH_USER}/.local/bin/mitmdump -ns ~/timestamp_replacer.py "
f"--set script_mode=clean --set keys_filepath={problem_keys_filepath}"
f" -r {mock_file_path} -w {cleaned_mock_filepath} | sudo tee -a {log_file}"
)
Expand Down Expand Up @@ -501,7 +504,7 @@ def prepare_proxy_start(
Writes proxy server run configuration options to the remote host, the details of which include:
- Creating new tmp directory on remote machine if in record mode and moves the problematic keys file in to it
- Creating the mitmdump_rc file that includes the script mode, keys file path, mock file path and log file path
for the mitmdump service and puts it in '/home/ec2-user/mitmdump_rc' in the remote machine.
for the mitmdump service and puts it in '/home/gcp-user/mitmdump_rc' in the remote machine.
- starts the systemd mitmdump service

Args:
Expand Down Expand Up @@ -555,7 +558,7 @@ def _write_mitmdump_rc_file_to_host(self, file_content: str) -> bool:
"""
Does all needed preparation for starting the proxy service which include:
- Creating the mitmdump_rc file that includes the script mode, keys file path, mock file path and log file path
for the mitmdump service and puts it in '/home/ec2-user/mitmdump_rc' in the remote machine.
for the mitmdump service and puts it in '/home/gcp-user/mitmdump_rc' in the remote machine.

Args:
file_content: The content of the mitmdump_rc file that includes the script mode, keys file path,
Expand Down
3 changes: 2 additions & 1 deletion demisto_sdk/commands/test_content/tests/test_tools.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from subprocess import CalledProcessError

from demisto_sdk.commands.test_content.tools import is_redhat_instance
from demisto_sdk.commands.test_content.constants import SSH_USER


def raise_exception():
raise CalledProcessError(1, "ls -l /home/ec2-user/rhel_ami".split())
raise CalledProcessError(1, f"ls -l /home/{SSH_USER}/rhel_ami".split())


class CheckOutputMock:
Expand Down
4 changes: 2 additions & 2 deletions demisto_sdk/commands/test_content/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def update_server_configuration(

def is_redhat_instance(instance_ip: str) -> bool:
"""
As part of the AMI creation - in case the AMI is RHEL a file named '/home/ec2-user/rhel_ami' is created as
As part of the AMI creation - in case the AMI is RHEL a file named '/home/gcp-user/rhel_ami' is created as
an indication.
If not
Args:
instance_ip: The instance IP to check.

Returns:
True if the file '/home/ec2-user/rhel_ami' exists on the instance, else False
True if the file '/home/gcp-user/rhel_ami' exists on the instance, else False
"""
try:
check_output(
Expand Down