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
Save kubeadm manifest backup directories #64337
Conversation
/wip |
/label wip |
/test pull-kubernetes-node-e2e |
/test pull-kubernetes-kubemark-e2e-gce pull-kubernetes-node-e2e pull-kubernetes-kubemark-e2e-gce-big |
/test pull-kubernetes-node-e2e |
e202724
to
c0e1f40
Compare
/assign @timothysc @luxas |
|
/remove-label wip |
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.
Minor nits, otherwise lgtm
/approve
cmd/kubeadm/app/cmd/upgrade/apply.go
Outdated
// GetPathManagerForUpgrade returns a path manager properly configured for the given MasterConfiguration. | ||
func GetPathManagerForUpgrade(internalcfg *kubeadmapi.MasterConfiguration, etcdUpgrade bool) (upgrade.StaticPodPathManager, error) { | ||
isHAEtcd := false | ||
if internalcfg.Etcd.External != nil && len(internalcfg.Etcd.External.Endpoints) > 1 { |
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 logic can probably be a part of the existing etcd utils. There are a bunch.
haEtcd := &kubeadmapi.MasterConfiguration{ | ||
Etcd: kubeadmapi.Etcd{ | ||
External: &kubeadmapi.ExternalEtcd{ | ||
Endpoints: []string{"10.100.0.1:2379", "10.100.0.2:2379"}, |
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.
Should probably be 3 for consistency.
if err != nil { | ||
return "", fmt.Errorf("couldn't create a temporary directory: %v", err) | ||
} | ||
return tempDir, nil | ||
} | ||
|
||
// CreateTimestampDirForKubeadm is a function that creates a temporary directory under /etc/kubernetes/tmp formatted with the current date | ||
func CreateTimestampDirForKubeadm(dirName string) (string, error) { |
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'm genuinely surprised that I couldn't find a utility f(n) in k8s land that didn't do this.
timestampDirName := fmt.Sprintf("%s-%s", dirName, time.Now().Format("2006-01-02-15-04-05")) | ||
timestampDir := path.Join(tempDir, timestampDirName) | ||
if err := os.Mkdir(timestampDir, 0700); err != nil { | ||
return "", err |
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.
possibly wrap this error in fmt.Errorf("could not create timestamp directory %q: %v", timestampDir, err)
?
} | ||
|
||
if _, err := os.Stat(tempManifestDir); !os.IsNotExist(err) { | ||
t.Errorf("%v should not have existed", tempManifestDir) |
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/%v/%q
well done @liztio . |
/hold |
/remove-hold |
/hold cancel |
/test pull-kubernetes-e2e-gce |
return err | ||
} | ||
} | ||
|
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.
minor format consistency things are usually nice to stick in editors to auto-save. totally non-blocking just an FYI.
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 do have a lot of autocommit things, just not removing trailing space I guess
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.
please squash commits then lgtm.
When kubeadm upgrades a static pod cluster, the old manifests were previously deleted. This patch alters this behaviour so they are now stored in a timestamped temporary directory.
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
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
Minor nits, but you don't have to address them now
@@ -216,3 +217,8 @@ func (c Client) WaitForClusterAvailable(delay time.Duration, retries int, retryI | |||
} | |||
return false, fmt.Errorf("timeout waiting for etcd cluster to be available") | |||
} | |||
|
|||
// CheckConfigurationIsHA returns true if the given MasterConfiguration etcd block appears to be an HA configuration. | |||
func CheckConfigurationIsHA(cfg *kubeadmapi.Etcd) bool { |
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.
nit: we call MasterConfiguration
generally cfg
. etcd
or etcdCfg
or etcdObj
or e
would probably be better here.
return "", fmt.Errorf("failed to create directory %q: %v", tempDir, err) | ||
} | ||
|
||
timestampDirName := fmt.Sprintf("%s-%s", dirName, time.Now().Format("2006-01-02-15-04-05")) |
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.
Can you make a constant for this or use one of the formats defined in time
?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liztio, luxas, timothysc 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 Pull Request Labels
|
/retest |
Automatic merge from submit-queue (batch tested with PRs 62460, 64480, 63774, 64540, 64337). If you want to cherry-pick this change to another branch, please follow the instructions here. |
@liztio: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
What this PR does / why we need it:
Kubeadm will now preserves previous manifests after
kubeadm upgrade apply
. Previously these files would be deleted after the upgrade succeededWhich issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes # kubeadm/489
Special notes for your reviewer:
Release note: