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

Refactoring + Cleanup to scheduler +utils for modularizing checkServiceAffinity. #34624

Merged
merged 1 commit into from Oct 14, 2016

Conversation

jayunit100
Copy link
Member

@jayunit100 jayunit100 commented Oct 12, 2016

Part 1 of pr for scheduler modularization specifically supporting CheckServiceAffinity improvements #33763.

These are some innoccous changes which help separate the predicate injection machinery from the cleanup parts of CheckServiceAffinity

@timothysc @wojtek-t

  • changes to metadata.go are for the follow on pr
  • changes to prio/pred stuff is all passing unit tests

hoping to grease this through and then the interesting part is in the follow on pr.


This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Oct 12, 2016
@wojtek-t wojtek-t assigned wojtek-t and unassigned davidopp Oct 12, 2016
@timothysc timothysc added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Oct 12, 2016
@jayunit100 jayunit100 force-pushed the scheduler-checksvc-1 branch 2 times, most recently from 1ce8291 to f0164a8 Compare October 12, 2016 18:34
@jayunit100
Copy link
Member Author

Just rebased

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit f0164a8. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@jayunit100
Copy link
Member Author

@k8s-bot gci gke e2e test this #33175

import "k8s.io/kubernetes/pkg/api"

// findLabelsInSet gets as many constraints as possible from the pod itself.
func findLabelsInSet(labelsToKeep []string, nodeSelector labels.Set) map[string]string {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why these are private, as they seem generally useful?

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 felt like this was made as a utility for making the nodeSelection stuff more understandable, and the semantics weren't defined well (i.e. findLabelsInSet vs filterLabelsFromMap vs ...) and it wasnt thought-out enough to generalize. In any case, happy to make it public.... what are your thoughts ? im +0 to public but can do if you still feel like we should.

// The pod is checked for the labels and any missing labels are then checked in the node
// that hosts the service pods (peers) for the given pod.
// The checkServiceAffinity predicate matches nodes in such a way to force that
// ServiceAffinity.labels are homogenous for pods added to a node.
//
Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this 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.

The line is to separate the concise definition from the drivel :):). But yeah I can delete.


// ExampleUtils is a https://blog.golang.org/examples styled unit test.
func ExamplefindLabelsInSet() {

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this empty line

@@ -39,7 +39,8 @@ type PriorityMapFunction func(pod *api.Pod, meta interface{}, nodeInfo *schedule
type PriorityReduceFunction func(pod *api.Pod, result schedulerapi.HostPriorityList) error

// MetdataProducer is a function that computes metadata for a given pod.
type MetadataProducer func(pod *api.Pod) interface{}
// In some cases NodeInfo is required in order for certain types of metadata caching, but leaving nil may be ok in many cases also.
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this comment, because it basically says "nodeNameToInfo may be required, but may also not be required" (which basically doesn't say anything)

Copy link
Member Author

Choose a reason for hiding this comment

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

True, but remember the odd thing is that this interface is used for different factorIes. I guess I can directly say that in the comment rather

// will_see_this
// label1=value1,label2=value2,label3=will_see_this
// [&TypeMeta{Kind:,APIVersion:,} &TypeMeta{Kind:,APIVersion:,}]

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this empty line

addUnsetLabelsToMap(labelSubset, []string{"label1", "label2", "label3"}, nsPods[0].ObjectMeta.Labels)

fmt.Println(labelSubset)

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this empty line

return filtered
}

// createSelectorFromLabels is used to define the final selector which we will use to decide wether a pod
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't mention pod or node here - it is pretty generic function.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm i think the semantics are really only useful to predicates and pods (even though its generalizable, it probably will never be used outside this package)... but i guess...


{}, // a third pod which will have no effect on anything.
}

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this empty line

fmt.Println(findLabelsInSet([]string{"label1", "label2", "label3"}, nsPods[0].ObjectMeta.Labels)["label3"])

addUnsetLabelsToMap(labelSubset, []string{"label1", "label2", "label3"}, nsPods[0].ObjectMeta.Labels)

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove this empty line

// Output:
// will_see_this
// label1=value1,label2=value2,label3=will_see_this
// [&TypeMeta{Kind:,APIVersion:,} &TypeMeta{Kind:,APIVersion:,}]
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't give any information (we don't know which pods were filtered out). So maybe just print the number of pods that are in this namespace?

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 considered that, but this is simpler to maintain if we expand the pod meta data for the test ...

Copy link
Member

Choose a reason for hiding this comment

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

So let's print those pods so that we know what pods they are. This doesn't provide much value now.

// the match.
// Otherwise:
// Create an "implicit selector" which backfills node label selectors for a pod, such that it will land with
// matching labelled nodes to pre-existing pods.
Copy link
Member

Choose a reason for hiding this comment

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

It's probably due to my english, but I'm lost in this sentence. Can you please clarify?

@k8s-ci-robot
Copy link
Contributor

Jenkins verification failed for commit dce89117a0f296012168ca82a53c315973f0c184. Full PR test history.

The magic incantation to run this job again is @k8s-bot verify test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Copy link
Member

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

One minor outstanding comment. other than that lgtm

@wojtek-t
Copy link
Member

Also please fix "Jenkins verification"

…ation for

predicate injection support, Update metadata struct
Namespace: "ns1",
},
},

Copy link
Member Author

Choose a reason for hiding this comment

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

blank line here intentional : to separate the third pod from the other two for readability

@jayunit100
Copy link
Member Author

i believe all comments addressed now...

@jayunit100
Copy link
Member Author

i think jenkins verify looks ok to me ?

@wojtek-t
Copy link
Member

lgtm

@wojtek-t wojtek-t added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2016
@timothysc timothysc added this to the v1.5 milestone Oct 13, 2016
@timothysc timothysc added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Oct 13, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit f42337f into kubernetes:master Oct 14, 2016
@jayunit100 jayunit100 changed the title Minor cleanup to scheduler. Refactoring + Cleanup to scheduler +utils for modularizing checkServiceAffinity. Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. release-note-none Denotes a PR that doesn't merit a release note. sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants