-
Notifications
You must be signed in to change notification settings - Fork 276
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
Added check if the node is rebooted before the networks is deleted on windows #6437
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6437 +/- ##
==========================================
+ Coverage 25.23% 25.25% +0.01%
==========================================
Files 33 33
Lines 2829 2831 +2
==========================================
+ Hits 714 715 +1
- Misses 2068 2070 +2
+ Partials 47 46 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
pkg/windows/calico.go
Outdated
@@ -302,7 +302,8 @@ func (c *Calico) Start(ctx context.Context) error { | |||
|
|||
// generateCalicoNetworks creates the overlay networks for internode networking | |||
func (c *Calico) generateCalicoNetworks() error { | |||
if err := deleteAllNetworks(); err != nil { | |||
cmd := exec.Command("powershell.exe", "C:\\var\\lib\\rancher\\rke2\\bin\\node-calico.ps1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have in the past pushed back on just having golang call out to powershell to do things. If we wanted to do this, we could just use upstream's powershell scripts in the first place, instead of handling cni setup in golang. Why do we need a powershell script to check a registry key and reinitialize hns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to check the latest reboot. If Calico os starting after a reboot it has to clean the network if it's after a restart of RKE2 the network shouldn't be cleaned. I can try to do the check inside golang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
d08776a
to
7af5676
Compare
pkg/windows/utils.go
Outdated
func isNodeRebooted(ctx context.Context) (bool, error) { | ||
path, err := exec.LookPath("powershell") | ||
if err == nil { | ||
cmd := exec.CommandContext(ctx, path, "-NoProfile", "-NonInteractive", "@(Get-CimInstance Win32_OperatingSystem).LastBootUpTime.ToString(\"G\")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're still execing powershell. You should be able to do this using pure go. See for example: https://gistlib.com/go/get-system-boot-time-in-milliseconds-in-go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was searching for something similar but it seems that syscall
it's not working properly on windows. I tried that code and it's not building. I'll try to check if there is something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something similar using a different function. Now I'm not using any exec command so I also removed the context and left as it was before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit on storing time in the registry.
8b5ec0d
to
258b4db
Compare
Signed-off-by: Roberto Bonafiglia <[email protected]>
Proposed Changes
This PR move the delete of all networks on a script that does as Calico that checks if the node is rebooted only.
The fix right now works only if the other version has already the new script check updating from an older version requires a node reboot and the bug is fixed from the next version updates.
Types of Changes
Verification
Testing
Linked Issues
#5551
User-Facing Change
Further Comments