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

Add OVS driver installation in initContainer for Antrea Windows agent #6312

Merged
merged 1 commit into from
May 24, 2024

Conversation

XinShuYang
Copy link
Contributor

By integrating the OVS driver installation into an initContainer, we ensure that the necessary driver is installed before the main containers start, and the driver's presence is checked only once during the pod's lifecycle.

@XinShuYang
Copy link
Contributor Author

/test-windows-all

@XinShuYang
Copy link
Contributor Author

/test-windows-e2e

@XinShuYang
Copy link
Contributor Author

/test-windows-containerd-e2e

@XinShuYang XinShuYang requested a review from wenyingd May 11, 2024 07:28
@@ -34,6 +34,23 @@ data:
cp $mountPath/etc/antrea/antrea-cni.conflist c:/etc/cni/net.d/10-antrea.conflist
mkdir -force c:/k/antrea/bin
cp $mountPath/k/antrea/bin/antctl.exe c:/k/antrea/bin/antctl.exe
Copy link
Contributor

Choose a reason for hiding this comment

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

You should add this script to path "build/yamls/windows/containerd-with-ovs" and update containerd-with-ovs.yml to enforce generating the final manifest with make actions, rather than directly modify the final yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will update it.

# Install OVS Driver
netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt
}
# Update Ovs Driver
Copy link
Contributor

Choose a reason for hiding this comment

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

Why shall we copy the driver to Windows host? I remember you mentioned that Windows host can load the installed driver even if the file is not persistent on disk.

BTW, even if we have to copy the driver files, it should be taken in Install-OVSDriver-Containerd.ps1 rather than in Run-AntreaOVS-Containerd.ps1 right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The file path in the initcontainer cannot be shared with the OVS container. Therefore, after installing the driver in the initcontainer, we copy the driver file to the host to ensure it persists. Once the OVS container starts, it copies the driver from the host to its own file path. This ensures that the driver used is the same one installed in the initcontainer.

@XinShuYang
Copy link
Contributor Author

/test-windows-containerd-e2e

@XinShuYang
Copy link
Contributor Author

/test-windows-containerd-e2e

@XinShuYang
Copy link
Contributor Author

/test-windows-containerd-e2e

@@ -1,5 +1,24 @@
apiVersion: v1
data:
Install-OVSDriver-Containerd.ps1: |
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel not necessary to highlight "Containerd" in the name by now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will update all related script name.

@@ -0,0 +1,18 @@
$ErrorActionPreference = "Stop"
mkdir -force c:/openvswitch/driver
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to create this directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems we don't have this folder in the container..

Copy link
Contributor

@wenyingd wenyingd May 21, 2024

Choose a reason for hiding this comment

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

This command is trying to create directory on the host as your are using path "C:/openvswitch", and I didn't find any consumption of the path in your change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got you points, will remove it, thanks.


# Check if OVSExt driver is already installed
$driverStatus = netcfg -q ovsext
if ($driverStatus -like '*not installed*') {
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 have a plan to install certificates including the self-signed certs in the init-container when installing OVS driver?

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 recall our discussion on related topic: for the officially signed OVS, Antrea requires no additional actions. However, for other OVS releases, it is the user's responsibility to add the certificate before running Antrea. We have already highlighted this in the current documentation(https://github.com/gran-vmv/antrea/blob/ipam-e2e-k8s/docs/windows.md#1-optional-install-ovs-provided-by-antrea-or-your-own)

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, then we may need to cover the possible failure if user tries to install unsigned OVS on Windows host.

if ($driverStatus -like '*not installed*') {
# Install OVS Driver
$result = netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt
if ($result -like '*failed*') {
Copy link
Contributor

Choose a reason for hiding this comment

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

($result -like 'failed') is checking whether the variable $result contains the word "failed", it will enter here only when error message contains failed, we might want to add another else to capture any unknown errors
else {
# Handle unexpected output
Write-Host "Unexpected output from netcfg: $result"
exit 1
}
and can prefer to move Write-Host "OVSExt driver has been installed" at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can only determine whether it's a success or a failure from the result of netcfg (It doesn't return typical error message which can be handled by "try-catch"). In testing, I found that netcfg always returns the 'failed' when it fails, which means it can serve as a basis for determining if the command has failed. For the else branch, I agree we can move it at the end for easier maintenance.

By integrating the OVS driver installation into an initContainer, we ensure that
the necessary driver is installed before the main containers start, and the driver's
presence is checked only once during the pod's lifecycle.

Signed-off-by: Shuyang Xin <gavinx@vmware.com>
$driverStatus = netcfg -q ovsext
if ($driverStatus -like '*not installed*') {
# Install OVS Driver
$result = netcfg -l $OVSDriverDir/ovsext.inf -c s -i OVSExt
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we have a try on a fresh Windows host which didn't install OVS driver before? I asked this because I remember that if we install the unsigned OVS driver on a Windows host for the first time, a pop-up window is given. But if we operate with powershell silently, we may not catch the signal. Then what would be the result? Is it containing "failed" in the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After discussion with @wenyingd , we decided to create another PR to enhance the features related to certificates and the OVS driver installation. I created an issue for further discussion in #6358. This PR will not affect the existing driver installation method, and we hope to prioritize its merging because PR #6311 also depends on the modifications in this PR.

@luolanzone luolanzone added the area/OS/windows Issues or PRs related to the Windows operating system. label May 22, 2024
@XinShuYang
Copy link
Contributor Author

/test-windows-all

Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

LGTM

@antoninbas antoninbas merged commit 925f510 into antrea-io:main May 24, 2024
52 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/OS/windows Issues or PRs related to the Windows operating system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants