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

feat(runtime): Adds conditional compilation for windows #240

Merged
merged 2 commits into from
May 21, 2020

Conversation

thomastaylor312
Copy link
Contributor

This adds conditional compilation for the SIGINT interrupts. Due
to the macro, this is mostly a copy/paste job with one version
for windows

@nightkr
Copy link
Member

nightkr commented May 14, 2020

  1. Can't we just provide a dummy SIGTERM never-Future on Windows, rather than duplicating everything else?
  2. Might want to enable CI for Windows. Evidently nobody really cares about Windows support at the moment, so regressions seem fairly likely.
  3. You might interested in my proposal for a ::runtime redesign, which does away with "self-driving" and signal listeners entirely: Create a Controller<K> runtime #148 (comment)

@nightkr nightkr added bug Something isn't working runtime controller runtime related labels May 14, 2020
@thomastaylor312
Copy link
Contributor Author

Hmmm...so as for the dummy SIGTERM, let me give it a whirl. Should I enable CI as part of this PR or do it in another once this is merged?

With regards to the runtime work, is it going to be done soon enough that this PR won't be worth it? I am fine waiting if it is going to be done relatively soon, otherwise, I'd love to get this in

@nightkr
Copy link
Member

nightkr commented May 14, 2020

Should I enable CI as part of this PR or do it in another once this is merged?

Should be fine to do it in this PR.

With regards to the runtime work, is it going to be done soon enough that this PR won't be worth it? I am fine waiting if it is going to be done relatively soon, otherwise, I'd love to get this in

watcher and reflector are already complete enough that they can replace kube::runtime::{Informer, Reflector}. controller could do with some more polish (notably, event deduplication) but kube doesn't have an equivalent abstraction anyway.

This adds conditional compilation for the SIGINT interrupts. Due
to the macro, this is mostly a copy/paste job with one version
for windows
@thomastaylor312 thomastaylor312 force-pushed the feat/conditional_compile branch from 1a415ec to fb966e0 Compare May 14, 2020 17:33
@thomastaylor312
Copy link
Contributor Author

Ok, I just pushed a fix to use a dummy channel for the sigterm. Working on enabling windows support in CI. If you honestly feel like this work is probably not worth it given the incoming refactor, I am fine closing this

@thomastaylor312 thomastaylor312 force-pushed the feat/conditional_compile branch 8 times, most recently from 2308dee to f51ea3f Compare May 15, 2020 16:58
@thomastaylor312
Copy link
Contributor Author

I'll do some more digging about why the ring build is failing next week (I think I need to use the msvc target, but not entirely sure as gnu seemed to work for me when using cross). This is my first time I've really been building a Rust project for windows, so if anyone has pointers, feel free to drop them here

@nightkr
Copy link
Member

nightkr commented May 15, 2020

IMO it's fine if some optional features are broken, considering that the current state is "doesn't even build at all".

- checkout
- run:
name: "HACK: remove gitconfig to prevent ssh fetches from cargo"
command: rm ~/.gitconfig
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is strange. Why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cargo tries to pull using git urls instead of https. Couldn't find another workaround

@clux
Copy link
Member

clux commented May 17, 2020

Ok, I just pushed a fix to use a dummy channel for the sigterm. Working on enabling windows support in CI. If you honestly feel like this work is probably not worth it given the incoming refactor, I am fine closing this

Even if we are likely changing the way this is done, the hack is completely fine for now.

Having a working CI solution on windows would be the real benefit here, since it's not a platform that gets tested a lot. So if you are able to get circle to accept it, then this would be great 👍

@@ -59,10 +62,18 @@ where
// local development needs listening for ctrl_c
let ctrlc_fut = ctrl_c().fuse();
// kubernetes apps need to listen for SIGTERM (30s warning)
use signal::unix::{signal, SignalKind}; // TODO: conditional compile
#[cfg(not(target_family = "windows"))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to create a new scope and conditionally compile that scope to make this easier to read:

 #[cfg(not(target_family = "windows"))]
 let sigterm_fut = {
  use signal::unix::{signal, SignalKind};
  let mut sigterm = signal(SignalKind::terminate()).unwrap();
  sigterm.recv().fuse()
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet, I was wondering how I could do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it looks like this doesn't work because recv borrows the receiver and then that borrow doesn't last outside the scope

@thomastaylor312 thomastaylor312 force-pushed the feat/conditional_compile branch 8 times, most recently from 4be37e8 to a4a2b60 Compare May 20, 2020 17:23
@thomastaylor312 thomastaylor312 force-pushed the feat/conditional_compile branch from a4a2b60 to b6469aa Compare May 20, 2020 17:28
@thomastaylor312 thomastaylor312 force-pushed the feat/conditional_compile branch from b6469aa to a2e030d Compare May 20, 2020 17:37
@thomastaylor312
Copy link
Contributor Author

@clux @teozkr I think this is ready to go! Sorry for all of the notifications you probably got from all the force pushes while testing the windows build, but now the build seems to be working great.

@clux
Copy link
Member

clux commented May 21, 2020

Sorry for all of the notifications you probably got from all the force pushes while testing the windows build, but now the build seems to be working great.

Not a problem at all! Thanks a lot for the PR.

@clux clux merged commit 36cb773 into kube-rs:master May 21, 2020
@thomastaylor312 thomastaylor312 deleted the feat/conditional_compile branch May 21, 2020 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime controller runtime related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants