Skip to content

Conversation

@tamilmani1989
Copy link
Member

@tamilmani1989 tamilmani1989 commented Jul 9, 2019

What this PR does / why we need it:
This PR added support for host to NC communication and NC to host communication. These are controlled by two dnc fields AllowHostToNCCommunication and AllowNCToHostCommunication. If both are true it allows two way communication.

Created iptable package and updated all places that used iptable commands.
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

@codecov
Copy link

codecov bot commented Jul 9, 2019

Codecov Report

Merging #374 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #374   +/-   ##
=======================================
  Coverage   40.01%   40.01%           
=======================================
  Files          25       25           
  Lines        3546     3546           
=======================================
  Hits         1419     1419           
  Misses       1927     1927           
  Partials      200      200

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e9525c...1b6c562. Read the comment docs.

@tamilmani1989 tamilmani1989 changed the title Added host to NC communication support and vice-versa Added host to NC communication support in Linux and vice-versa Jul 9, 2019
@tamilmani1989 tamilmani1989 changed the title Added host to NC communication support in Linux and vice-versa Added Host NC communication support in Linux Jul 9, 2019
Copy link
Contributor

@jaer-tsun jaer-tsun left a comment

Choose a reason for hiding this comment

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

general comments

AllowInboundFromNCToHost bool
NetworkNameSpace string `json:",omitempty"`
ContainerID string
PODName string `json:",omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

PodName or Podname

Copy link
Member Author

Choose a reason for hiding this comment

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

i didn't change this..so not changing it

EnableMultiTenancy bool
AllowInboundFromHostToNC bool
AllowInboundFromNCToHost bool
PODName string
Copy link
Contributor

Choose a reason for hiding this comment

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

PodName or Podname

Copy link
Member Author

Choose a reason for hiding this comment

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

i didn't change this..so not changing it

AllowInboundFromHostToNC bool
AllowInboundFromNCToHost bool
PODName string
PODNameSpace string
Copy link
Contributor

Choose a reason for hiding this comment

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

PodNamespace

Copy link
Member Author

Choose a reason for hiding this comment

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

i didn't change this..so not changing it

IfName: ep.IfName,
ContainerID: ep.ContainerID,
NetNsPath: ep.NetworkNameSpace,
PODName: ep.PODName,
Copy link
Contributor

Choose a reason for hiding this comment

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

uncaps POD (see comments above)

Copy link
Contributor

@ninzavivek ninzavivek left a comment

Choose a reason for hiding this comment

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

One generic comment, changes lack documentation. I recommend a line or two where you can do.

}

func RuleExists(tableName, chainName, match, target string) bool {
cmd := fmt.Sprintf("iptables -w 60 -t %s -C %s %s -j %s", tableName, chainName, match, target)
Copy link
Contributor

Choose a reason for hiding this comment

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

60?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is lock timeout. So if iptable couldn't grab lock for 60 seconds, it will exit. i can move that to constant

return nil
}

cmd := fmt.Sprintf("iptables -w 60 -t %s -I %s 1 %s -j %s", tableName, chainName, match, target)
Copy link
Contributor

Choose a reason for hiding this comment

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

I will recommend defining a constant for iptables command? It seems like you are using it at multiple places.

Copy link
Member Author

Choose a reason for hiding this comment

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

will do

@tamilmani1989
Copy link
Member Author

One generic comment, changes lack documentation. I recommend a line or two where you can do.

sure will do it.

jaer-tsun
jaer-tsun previously approved these changes Jul 15, 2019
Copy link
Contributor

@jaer-tsun jaer-tsun left a comment

Choose a reason for hiding this comment

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

/lgtm

ninzavivek
ninzavivek previously approved these changes Jul 16, 2019

import (
"fmt"

Copy link
Contributor

Choose a reason for hiding this comment

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

line?

Copy link
Member Author

Choose a reason for hiding this comment

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

goformat automatically does that

if action == iptables.Insert {
err = iptables.InsertIptableRule(iptables.Filter, chainName, matchCondition, target)
} else if action == iptables.Append {
err = iptables.AppendIptableRule(iptables.Filter, chainName, matchCondition, target)
Copy link
Contributor

Choose a reason for hiding this comment

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

case statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

@jaer-tsun jaer-tsun left a comment

Choose a reason for hiding this comment

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

/lgtm

@tamilmani1989 tamilmani1989 merged commit edabc6d into Azure:master Jul 17, 2019
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.

3 participants