Skip to content

cmd: policy trace src/dst eID, secid, k8s-pod options#1124

Merged
tgraf merged 1 commit intomasterfrom
1005-cilium-policy-trace-usability
Aug 8, 2017
Merged

cmd: policy trace src/dst eID, secid, k8s-pod options#1124
tgraf merged 1 commit intomasterfrom
1005-cilium-policy-trace-usability

Conversation

@ianvernon
Copy link
Copy Markdown
Member

@ianvernon ianvernon commented Jul 14, 2017

Add capability to pass in a source / destination endpoint, k8s pod, and security identities to cilium policy trace.

Signed-off by: Ian Vernon ian@covalent.io

Partially addresses #1005

Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var dstSecurityIdLabels should be dstSecurityIDLabels

Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var srcSecurityIdLabels should be srcSecurityIDLabels

Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

const defaultSecurityId should be defaultSecurityID

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch 8 times, most recently from 8496945 to 6ece0a0 Compare July 21, 2017 00:19
Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

func parameter epId should be epID

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch 2 times, most recently from 6e807bb to d61a609 Compare July 24, 2017 18:05
Comment thread pkg/option/option.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported method BoolOptions.GetModel should have comment or be unexported

Comment thread pkg/option/option.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported method BoolOptions.GetMutableModel should have comment or be unexported

Comment thread pkg/option/option.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported method BoolOptions.GetImmutableModel should have comment or be unexported

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from ea7dd3c to 61f3b51 Compare July 25, 2017 02:35
Comment thread cilium/cmd/policy_trace.go Outdated
}

return inLabels, nil
secId := p.GetAnnotations()["cilium-identity"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var secId should be secID

Comment thread cilium/cmd/policy_trace.go Outdated
if resp == nil {
return nil, fmt.Errorf("ID %s not found", id)
}
func getSecIdFromK8s(podName string) (string, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

func getSecIdFromK8s should be getSecIDFromK8s

Comment thread cilium/cmd/policy_trace.go Outdated
func parseAllowedSlice(slice []string) ([]string, error) {
inLabels := []string{}
id := ""
func appendEpLabelsToSlice(epId string, labelSlice []string) []string {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

func parameter epId should be epID

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from 0607376 to e5a3e38 Compare July 27, 2017 17:31
Comment thread daemon/daemon.go
return d.conf.Opts.IsEnabled(endpoint.OptionDebug)
}

func (d *Daemon) AnnotateEndpoint(e *endpoint.Endpoint, annotationKey, annotationValue string) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported method Daemon.AnnotateEndpoint should have comment or be unexported

Comment thread cilium/cmd/policy_trace.go Outdated
return "", fmt.Errorf("unable to get pod %s in namespace %s", namespace, pod)
}

secId := p.GetAnnotations()["cilium-identity"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var secId should be secID

Comment thread cilium/cmd/policy_trace.go Outdated
if err != nil {
Fatalf("Cannot get security id from k8s pod name: %s", err)
}
convertedId, err := strconv.ParseInt(id, 0, 64)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var convertedId should be convertedID

Comment thread cilium/cmd/policy_trace.go Outdated
if err != nil {
Fatalf("Cannot get security id from k8s pod name: %s", err)
}
convertedId, err := strconv.ParseInt(id, 0, 64)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var convertedId should be convertedID

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from e5a3e38 to d30c11a Compare August 1, 2017 22:39
Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var secId should be secID

Comment thread cilium/cmd/policy_trace.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

var secId should be secID

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from ede56b3 to 8775e5b Compare August 2, 2017 18:51
@ianvernon
Copy link
Copy Markdown
Member Author

Between commit 5dfd8b1 and commit 364d72ec43ecb0bd6546bc9a3d25dc402ac80b4f, the adding of the annotation failed in the K8s case:

20:47:47 [K8s multi node Tests] time="2017-08-06T20:47:41Z" level=error msg="k8s: unable to update pod default:app2-4193432878-blhq1 with \"cilium-identity\" annotation: pods \"app2-4193432878-blhq1\" is forbidden: unexpected operation UPDATE, retrying..." 
20:47:47 [K8s multi node Tests] time="2017-08-06T20:47:41Z" level=error msg="k8s: unable to update pod default:app3-3595226997-mq28v with \"cilium-identity\" annotation: pods \"app3-3595226997-mq28v\" is forbidden: unexpected operation UPDATE, retrying..." 
20:47:47 [K8s multi node Tests] time="2017-08-06T20:47:41Z" level=error msg="k8s: unable to update pod default:app1-2242192615-84jwr with \"cilium-identity\" annotation: pods \"app1-2242192615-84jwr\" is forbidden: unexpected operation UPDATE, retrying..." 
20:47:47 [K8s multi node Tests] time="2017-08-06T20:47:41Z" level=error msg="k8s: unable to update pod default:app1-2242192615-wrdqw with \"cilium-identity\" annotation: pods \"app1-2242192615-wrdqw\" is forbidden: unexpected operation UPDATE, retrying..." 

The only change was to add nodes to the list of objects that allow for updates in the RBAC YAML file. I'm not sure why this would happen? Will investigate...

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch 2 times, most recently from 72c8e87 to fa9e1fb Compare August 8, 2017 04:15
Comment thread common/const.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

exported const CiliumIdentityAnnotation should have comment (or a comment on this block) or be unexported

@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from fa9e1fb to 9f992ff Compare August 8, 2017 04:17
@ianvernon ianvernon changed the title WIP - cmd: policy trace src / dst eID and secid options cmd: policy trace src/dst eID, secid, k8s-pod options Aug 8, 2017
@ianvernon ianvernon added the wip label Aug 8, 2017
Add capability to pass in a source / destination endpoint, k8s pod, and security identities to `cilium policy trace`.

Signed-off by: Ian Vernon <ian@covalent.io>
@ianvernon ianvernon force-pushed the 1005-cilium-policy-trace-usability branch from abca452 to 0285330 Compare August 8, 2017 04:46
@ianvernon ianvernon requested a review from tgraf August 8, 2017 15:22
inLabels := []string{}
id := ""
// Returns the labels for security identity ID and an error if the labels cannot be retrieved.
func getLabelsFromIdentity(ID int64) ([]string, error) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am going to refactor this function into pkg/client/identity.go

@tgraf tgraf merged commit 31266bd into master Aug 8, 2017
@tgraf tgraf deleted the 1005-cilium-policy-trace-usability branch August 8, 2017 15:34
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