-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
kubeadm: Replace the yaml in the log/comments with a generic term. #130345
base: master
Are you sure you want to change the base?
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
8a02227
to
fb63528
Compare
/release-note-none |
LGTM label has been added. Git tree hash: 4de94b209ce33e899d62167ce8ea44456d8afa39
|
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 for the pr @HirazawaUi
for _, format := range formats { | ||
t.Run(fmt.Sprintf("%s_%s", tt.name, format.name), func(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.
since you are adding multi format testing for init and upgrade config, should you also add it to reset and join config?
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.
Added.
needs a simple release note explaining the user facing aspect of the change. |
fb63528
to
43ab8e3
Compare
43ab8e3
to
bf89648
Compare
} | ||
|
||
if obj == nil { | ||
t.Error("Unexpected nil return value") | ||
got, _ := LoadJoinConfigurationFromFile(tt.cfgPath, 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.
why not use bytestojoinconfiguration instead of writing a file and reading it
we should make this consistent across xconfiguration_tests.go.
} | ||
|
||
if obj == nil { | ||
t.Error("Unexpected nil return value") | ||
got, _ := LoadResetConfigurationFromFile(tt.cfgPath, 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.
again we should use bytestoresetconfiguration here instead of writing and loading
the load* functions can have another simple test, maybe
running some e2e |
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.
there are still some minor consistency problems, but the refactor is turning out nicely.
thanks
t.Errorf("LoadOrDefaultUpgradeConfiguration returned unexpected diff (-want,+got):\n%s", diff) | ||
} | ||
}) | ||
got, _ := LoadOrDefaultUpgradeConfiguration(tt.cfgPath, tt.cfg, 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.
we should remove the TestLoadUpgradeConfigurationFromFile function if other xconfiguration_test files no longer test the load functions and move the relevant test cases to the test function that tests the BytesTo* function
or just add a very simple TestLoadOrDefaultXConfiguration test everywhere that just makes sure that the function doesn't fail for a simple config.
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.
I added TestLoadXFromFile tests for reset and join, but could not add one for init since ComponentConfigs cannot be exported.
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.
not sure i understand, can you please provide an example?
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.
For example:
The kubeletConfig
struct in the componentconfigs directory is unexported (non-public).
ref:
kubernetes/cmd/kubeadm/app/componentconfigs/kubelet.go
Lines 84 to 87 in 8cca6d9
type kubeletConfig struct { | |
configBase | |
config kubeletconfig.KubeletConfiguration | |
} |
When executing the BytesToInitConfiguration
function, we will assign
default values to InitConfiguration.ComponentConfigs["kubelet.config.k8s.io"].kubeletConfig
.
However, since kubeletConfig
is unexported, we cannot reference it in the util/config
directory, making comparisons impossible.
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.
wouldn't this work?
cmp.Diff(got, tt.want, cmpopts.IgnoreFields{kubeadmapi.InitConfiguration{}, "ComponentConfigs"})
also i checked the latest contents of the latest pr, here is a more detailed explanation, what i meant earlier:
for each xconfiguration_test.go file, we should have:
- a detailed test for TestBytesToXConfiguration with various test cases
- a TestLoadXConfigurationFromFile with just a single case testing that a file loads, that's all
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.
cmp.Diff(got, tt.want, cmpopts.IgnoreFields{kubeadmapi.InitConfiguration{}, "ComponentConfigs"})
Yes, this will work perfectly.
- a TestLoadXConfigurationFromFile with just a single case testing that a file loads, that's all
I think I understand your point. However, replicating the tests for TestLoadXConfigurationFromFile
is quite convenient for me, so I provided them with the same test cases as TestLoadUpgradeConfigurationFromFile (my initial thought was that more test cases are always better than simple ones, especially when they are straightforward to copy/implement). Would this be considered redundant? If there are other considerations and we only need a simple test case, I can revert these unit tests.
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, its redundant. for the TestLoadXConfigurationFromFile, we just need a simple load test without content comparison.
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.
All right. I will add the unit tests for BytesToInitConfiguration tomorrow and revert some of the test cases from the latest commit.
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.
Changes have been made based on comments.
cb8b9ba
to
3bc4963
Compare
/retest |
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.
you could organize the commits better. remove all _test.go changes from commit 1 as it's supposed to only change output and move them to the last commits about test consistency. currently commit 1 makes changes to tests and later the last commit also changes the same tests.
also for all TestLoadXConfigurationFromFile functions make it use the two test cases:
- missing file
- valid config
0335aea
to
a2a6a5e
Compare
if (err != nil) != tc.expectedError { | ||
t.Fatalf("failed DocMapToUpgradeConfiguration:\n\texpected error: %t\n\t actual error: %v", tc.expectedError, err) | ||
} | ||
if err == nil { | ||
if diff := cmp.Diff(*cfg, tc.expectedCfg, cmpopts.IgnoreFields(kubeadmapi.UpgradeConfiguration{}, "Timeouts")); diff != "" { | ||
t.Fatalf("DocMapToUpgradeConfiguration returned unexpected diff (-want,+got):\n%s", diff) | ||
t.Fatalf("BytesToUpgradeConfiguration returned unexpected diff (-want,+got):\n%s", diff) |
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.
move this change from commit add BytesToXConfiguration function
to the last commit with tests.
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.
Checking and fixing problems caused by rebase, just a moment.
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.
I still put the changes to this unit test in the fourth commit because we removed the DocMapToUpgradeConfiguration
function in this commit. If we don’t modify this unit test, it will fail in the fourth commit.
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.
isn't it possible to move the delete of DocMapToUpgradeConfiguration also in the last commit?
the delete seems like a unit tests refactor too.
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.
Makes sense and has been changed as suggested.
a2a6a5e
to
cd0a29e
Compare
The content of the historical commits has been modified according to this suggestion. |
cd0a29e
to
9a84379
Compare
/lgtm /hold |
LGTM label has been added. Git tree hash: 636194a98151cf78f663a3457a37c15406e361f3
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: HirazawaUi, neolit123 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 |
Thank you for your patient review! |
this also fixes iiuc |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes kubernetes/kubeadm#3163 kubernetes/kubeadm#3162
Special notes for your reviewer:
To make the functions appear more consistent, I also renamed the SplitYAMLDocuments function to SplitYAMLOrJSONDocuments. If this is an unnecessary change, I can roll it back.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: