Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Do not skip bridge creation if bridge exists #3204

Merged
merged 9 commits into from
Jan 9, 2018

Conversation

brb
Copy link
Contributor

@brb brb commented Dec 18, 2017

I recommend to review each commit separately.

This PR does a few things:

  • Removes create_bridge from the weave script. As a consequence, weave attach $CIDR $CONTAINER is no longer possible without running weaver.
  • Removes unnecessary create_bridge from weave expose and weave hide.
  • Makes net/bridge.go:EnsureBridge do not skip creation of the bridge if such already exists, and also makes the function idempotent.

Part of the #3133 fix; going to add netlink subscribe for changes to the bridge in a separate PR.

brb added 6 commits December 14, 2017 16:56
To include LinkNotFoundError.
Both cmds depend on running weaver which creates the bridge
during its initialization. So, calling "create_bridge"
during execution of the cmds is redundant.
"weave attach $CIDR $CONTAINER_ID" is no longer possible w/o
running weaver. This feature was undocumented and complicated
the weave script, as "weave attach" required to call "create_bridge".
Removing the feature allows us to eliminate the bridge creation
from the script.

Running "weave attach" w/o weaver results in the following err:

    bridge "weave" not present; did you launch weave?

Also, this commit simplifies the "attach-container" cmd from
weaveutil by removing "mtu" as a param. The cmd is used
only by "weave attach", and a mtu is value for an attached
container interface is exactly the same as one of the weave bridge.
No longer needed in the weave script and thus, in weaveutil.
EnsureBridge used to skip creation and initialization of the weave
bridge and friends if such existed. This caused problems when
EnsureBridge failed before completing all init steps and so, subsequent
weaver could not work without "weave reset".

This change makes EnsureBridge idempotent.
@brb brb added this to the 2.2 milestone Dec 18, 2017
@deitch
Copy link
Contributor

deitch commented Dec 18, 2017

As commented on the other issue, thank you very much for this. The “reboot bug” bit us more than once.

@deitch
Copy link
Contributor

deitch commented Dec 18, 2017

On my phone, so hard to read, but does this also ensure iptables correctness?

@brb
Copy link
Contributor Author

brb commented Dec 18, 2017

On my phone, so hard to read, but does this also ensure iptables correctness?

Yep, it should.

If you want to do an early testing, please let me know - I could build images for you.

@deitch
Copy link
Contributor

deitch commented Dec 19, 2017

I’d be happy to test. We have an infra sandbox where we setup and tear down clusters all the time (automated through terraform) so more than happy to run tests there if you can provide an image.

@brb brb force-pushed the issues/3133-idempotent-bridge branch from f2972fd to 14768d6 Compare December 22, 2017 09:42
@brb brb changed the title WIP: do not skip bridge creation if bridge exists Do not skip bridge creation if bridge exists Dec 22, 2017
@brb
Copy link
Contributor Author

brb commented Dec 22, 2017

@deitch Cool, thanks! You can start using the fixed version (for testing purpose) by replacing weaveworks/weave-{kube,npc}:latest with weaveworks/weave-{kube,npc}:git-a7ea71bd in https://github.com/weaveworks/weave/blob/master/prog/weave-kube/weave-daemonset-k8s-1.7.yaml

@brb
Copy link
Contributor Author

brb commented Dec 22, 2017

PTAL

@deitch
Copy link
Contributor

deitch commented Dec 23, 2017

Will do @brb, thank you.

@deitch
Copy link
Contributor

deitch commented Dec 23, 2017

  1. upgraded weave to the specific image,
  2. First test: manually recreated the problem: weave bridge down and WEAVE rules removed from iptables. Killed pod, let daemonset restore it. Everything came back perfectly.
  3. Second test: Same as first, but reboot. Everything came back perfectly.

Looks good to me! Please do tag version here when it is merged in and released.

@brb
Copy link
Contributor Author

brb commented Dec 28, 2017

@deitch Thanks! I'm waiting for someone to review the PR.

@bboreham
Copy link
Contributor

I have read through the code, and that all seems fine.
I would like to know more about what it will do under different failure conditions, e.g. if some of the iptables rules are present and some are absent.

@deitch
Copy link
Contributor

deitch commented Jan 2, 2018

I have read through the code, and that all seems fine

I certainly am excited for this. It makes weave far more resilient. Instead of "works from nothing" and "works when it already works", it becomes, "always ensure good state on startup".

@brb brb force-pushed the issues/3133-idempotent-bridge branch 5 times, most recently from 7d72764 to bcc8968 Compare January 6, 2018 11:43
@brb brb force-pushed the issues/3133-idempotent-bridge branch from bcc8968 to 1d67e2f Compare January 6, 2018 12:23
@brb
Copy link
Contributor Author

brb commented Jan 6, 2018

@bboreham It will restore iptables rules. The filter/FORWARD rules are restored in a correct order. Also, I've extended the 191 integration test to test restoration of iptables rules.

PTAL - two new commits since your review.

for _, rs := range rulespecs {
// If any is missing, then delete all, as we need to preserve the order of
// given rules. Ignore errors, as rule might not exist.
if !allFound {

This comment was marked as abuse.

@bboreham
Copy link
Contributor

bboreham commented Jan 8, 2018

I like the table of rules - in future we should be able to use the same table to remove them on weave reset, and take that code out of the shell script.

@bboreham bboreham merged commit 6cfb208 into master Jan 9, 2018
@deitch
Copy link
Contributor

deitch commented Jan 9, 2018

Fabulous! What version will it (did it?) go into?

@bboreham
Copy link
Contributor

bboreham commented Jan 9, 2018

2.2; I'd like to get #3210 in too

@bboreham bboreham deleted the issues/3133-idempotent-bridge branch January 9, 2018 17:38
@deitch
Copy link
Contributor

deitch commented Jan 9, 2018

Thanks @bboreham. Is there an ETA?

@deitch
Copy link
Contributor

deitch commented Jan 22, 2018

Nice #3210 is merged too. So 2.2?

@brb
Copy link
Contributor Author

brb commented Jan 23, 2018

We are experiencing some integration test failures, so we would like to fix those before doing 2.2.

@deitch
Copy link
Contributor

deitch commented Jan 25, 2018

We are experiencing some integration test failures, so we would like to fix those before doing 2.2.

Thanks @brb. Not that I have any cycles, but we have gotten bit by this one several times now. If there is anything we can do to help move it along, let us know?

@bboreham
Copy link
Contributor

Weave Net release 2.2 just out https://github.com/weaveworks/weave/releases/tag/v2.2.0

@deitch
Copy link
Contributor

deitch commented Jan 30, 2018

Really great! Thanks to all!

Does it automatically get pushed to docker hub?

@bboreham
Copy link
Contributor

Yes, it's there on Docker Hub now

@deitch
Copy link
Contributor

deitch commented Jan 30, 2018

Ah, got it. By default, it only shows scanned tags, not unscanned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants