Skip to content

Add test case for k8s cleanup container#18404

Closed
lixiaoyuner wants to merge 8 commits intosonic-net:masterfrom
lixiaoyuner:dev/yunli1/add-cleanup-to-container-upgrade-test
Closed

Add test case for k8s cleanup container#18404
lixiaoyuner wants to merge 8 commits intosonic-net:masterfrom
lixiaoyuner:dev/yunli1/add-cleanup-to-container-upgrade-test

Conversation

@lixiaoyuner
Copy link
Contributor

@lixiaoyuner lixiaoyuner commented May 14, 2025

Description of PR

Add the test case for cleanup container, this test case will verify the cleanup container functionality.
Cleanup container is to help cleanup the old version container images during container upgrade via k8s.

  • This test will be only called by container upgrade test framework, will be skipped for other scenarios
  • The test code logic is to check if the cleanup container is running, if watchdog script exits with 0, if report disk size log and kubesonic cleanup related error log exist in syslog.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411

Approach

What is the motivation for this PR?

Need test case to verify the cleanup container's functionality.

How did you do it?

Call this test case in container upgrade test framework.

How did you verify/test it?

Run it in testbed

Any platform specific information?

No

Supported testbed topology if it's a new test case?

Yes

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lixiaoyuner lixiaoyuner changed the title Add kubesonic cleanup test case Add test case for k8s cleanup container May 14, 2025
@lixiaoyuner lixiaoyuner marked this pull request as ready for review May 14, 2025 12:59
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

--skip_sanity --disable_loganalyzer \
--log-file={log_file} --junit-xml={log_xml}"
--log-file={log_file} --junit-xml={log_xml} \
--containers={containers}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you verify this change doesn't affect other containers/testcases that don't need this as part of their tests? I don't think it would but just to confirm.

exec_watchdog_cmd = f"docker exec {CLEANUP_CONTAINER_NAME} /watchdog.sh"
exec_watchdog_status = duthost.shell(exec_watchdog_cmd, module_ignore_errors=True)
if exec_watchdog_status["rc"] != 0:
pytest.fail("Kubesonic cleanup container watchdog script exited with non-zero status")
Copy link
Contributor

Choose a reason for hiding this comment

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

non-zero

Do you want to add the rc into the failing message?

exec_cleanup_script_cmd = f"docker exec {CLEANUP_CONTAINER_NAME} /image_cleanup.sh"
exec_cleanup_script_status = duthost.shell(exec_cleanup_script_cmd, module_ignore_errors=True)
if exec_cleanup_script_status["rc"] != 0:
pytest.fail("Kubesonic cleanup container cleanup script exited with non-zero status")
Copy link
Contributor

Choose a reason for hiding this comment

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

non-zero status

Same question, Do you want to add the rc into the failing message?

"docker-bmp-watchdog": {
"parameters": "--pid=host --net=host -v /etc/localtime:/etc/localtime:ro -v /etc/sonic:/etc/sonic:ro"
},
"kubesonic-cleanup": {
Copy link
Contributor

Choose a reason for hiding this comment

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

kubesonic-cleanup

Where is the container defined?

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

if not containers:
pytest.skip("Skipping test as this test is not called from container upgrade test")

if CLEANUP_CONTAINER_IMAGE not in containers:
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps you can check docker images or running dockers to see if kubesonic cleanup container was installed directly instead of seeing if its a parameter to a test? Does this satisfy your use case? Container upgrade test should have installed this container before you run this test.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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