-
Notifications
You must be signed in to change notification settings - Fork 39k
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
fix scheduler client construction from configuration files #65507
fix scheduler client construction from configuration files #65507
Conversation
@@ -197,37 +197,37 @@ func (o *Options) Validate() []error { | |||
|
|||
// Config return a scheduler config object | |||
func (o *Options) Config() (*schedulerappconfig.Config, error) { | |||
c := &schedulerappconfig.Config{} | |||
if err := o.ApplyTo(c); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we apply the options to the config struct first (which handles loading config from a file), then use the c.ComponentConfig....
for the rest of the function
c01906a
to
3499352
Compare
3499352
to
14d31af
Compare
|
||
func TestSchedulerOptions(t *testing.T) { | ||
// temp dir | ||
tmpDir, err := ioutil.TempDir("", "scheduler-options") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Is it safe to assume that tempdir always exists especially when running in containers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many unit tests already do this, so yes
} | ||
|
||
// Insulate this test from picking up in-cluster config when run inside a pod | ||
// We can't assume we have permissions to write to /var/run/secrets/... from a unit test to mock in-cluster config for testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty clever!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Thanks @liggitt.
/retest |
1 similar comment
/retest |
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, @liggitt! I only have minor comment about the test, but it is not important and given the urgency of this fix, I approve it.
/lgtm
} else if !strings.Contains(err.Error(), tc.expectedError) { | ||
t.Errorf("expected %q, got %q", tc.expectedError, err.Error()) | ||
} | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to continue
instead of return
here and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inside a t.Run function… returning continues to the next test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right! I missed that it is inside t.Run.
Thanks again!
"k8s.io/kubernetes/pkg/apis/componentconfig" | ||
) | ||
|
||
func TestSchedulerOptions(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive! Thanks for writing the test.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, k82cn, liggitt, ravisantoshgudimetla The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process @bsalamat @liggitt @ravisantoshgudimetla Pull Request Labels
|
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
This reverts commit c67b56f. Upstream fix: kubernetes/kubernetes#65507
fixes #65483
clients were being constructed from options prior to loading the specified configuration file. this is a regression from 1.10 behavior.
/sig scheduling
/kind bug
/priority critical-urgent
/milestone v1.11