-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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: move duplicated code into enforceRequirements() #74511
kubeadm: move duplicated code into enforceRequirements() #74511
Conversation
Hi @rojkov. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
/ok-to-test |
f780c2b
to
b11b7f7
Compare
/test pull-kubernetes-integration |
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 @rojkov !
We need to remove the flaky tests though.
} | ||
|
||
// Ensure the user is root | ||
klog.V(1).Infof("running preflight checks") |
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.
s/Infof/Info
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.
fixed
name: "Valid config, but no version specified", | ||
isVersionMandatory: true, | ||
flags: &applyPlanFlags{ | ||
cfgPath: "testdata/cluster_config_with_version.yaml", |
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 am not a big a fan of using testdata files. In fact I was planning on nuking those at some point. Trouble is, that these occasionally get recycled by other tests, the actual test data is far apart from the test code and the test data itself does not mention what it's used to test.
I'd rather keep the content of the config in a const in this file (or even test case), write it out in a temp file and supply the temp file path to cfgPath
.
But that's just me, I am fine if you choose to keep the testdata files.
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.
Rewrote to create temp files with configs.
// XXX: This is possibly wrong. The current logic is that if version is omitted | ||
// from both the config and arguments then take the latest version | ||
// from the release server. Which is unknown at test time. | ||
expectedVersion: "v1.13.3", |
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 a flaky test, it requires internet connection and changing every time we release a new version. Please, don't add this 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.
I added this test case to illustrate a possible problem. I wasn't sure If it's expected that a user could use apply
without providing any version and still get away with it.
Removed now.
// XXX: This is possibly wrong. The current logic is that if version is omitted | ||
// from both the config and arguments then take the latest version | ||
// from the release server. Which is unknown at test time. | ||
expectedVersion: "v1.13.3", |
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 a flaky test case to be removed.
return "", err | ||
} | ||
|
||
if cfg.KubernetesVersion != "" { |
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.
The if statement does not make any difference if cfg.KubernetesVersion == ""
, because userVersion
should be empty at that moment. Just leave userVersion = cfg.KubernetesVersion
.
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! Fixed.
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 @rojkov
/priority important-longterm
and to a new function getK8sVersionFromUserInput(). Also drop applyPlanFlags.ignorePreflightErrorsSet field which is not a command line option.
b11b7f7
to
226843f
Compare
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.
/approve
thanks seems like a clean change.
leaving the LGTM to others.
we also need to start auditing 1.13 -> 1.14 upgrades...
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neolit123, rojkov 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 |
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Move duplicated code into
enforceRequirements()
and to a new functiongetK8sVersionFromUserInput()
.Also drop
applyPlanFlags.ignorePreflightErrorsSet
field which is not a command line option.Special notes for your reviewer:
This is a part of the PR series splitting #73135.
XXX: This PR increases code coverage, but the new tests reveal some unexpected behaviour. The current logic of handling user input is that if a user specifies a
ClusterConfiguration
file withoutKubernetesVersion
specified in it and no version is given as an argument then there's no failure. Because the functionLoadInitConfigurationFromFile()
returns a config with some default version already defined which is taken from the release server and is not known at test time.Thus when a new release of K8s is finalized the tests will start to fail.
Does this PR introduce a user-facing change?: