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

Save kubeadm manifest backup directories #64337

Merged
merged 1 commit into from May 31, 2018

Conversation

liztio
Copy link
Contributor

@liztio liztio commented May 25, 2018

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 succeeded

Which 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:

kubeadm now preserves previous manifests after upgrades

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 25, 2018
@k8s-ci-robot k8s-ci-robot added area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels May 25, 2018
@liztio
Copy link
Contributor Author

liztio commented May 25, 2018

/wip

@liztio
Copy link
Contributor Author

liztio commented May 25, 2018

/label wip

@liztio liztio changed the title Save etcd dir [wip] Save etcd dir May 25, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 25, 2018
@liztio
Copy link
Contributor Author

liztio commented May 25, 2018

/test pull-kubernetes-node-e2e

@liztio
Copy link
Contributor Author

liztio commented May 29, 2018

/test pull-kubernetes-kubemark-e2e-gce pull-kubernetes-node-e2e pull-kubernetes-kubemark-e2e-gce-big

@liztio
Copy link
Contributor Author

liztio commented May 29, 2018

/test pull-kubernetes-node-e2e

@liztio liztio force-pushed the save-etcd-dir branch 3 times, most recently from e202724 to c0e1f40 Compare May 30, 2018 17:40
@timothysc timothysc added this to the v1.11 milestone May 30, 2018
@timothysc timothysc added kind/enhancement priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed milestone/incomplete-labels labels May 30, 2018
@timothysc
Copy link
Member

/assign @timothysc @luxas

@liztio
Copy link
Contributor Author

liztio commented May 30, 2018

$ sudo ls /etc/kubernetes/tmp/kubeadm-backup-manifests-2018-05-30-20-27-24/
etcd.yaml  kube-apiserver.yaml	kube-controller-manager.yaml  kube-scheduler.yaml

@liztio
Copy link
Contributor Author

liztio commented May 30, 2018

/remove-label wip

@liztio liztio changed the title [wip] Save etcd dir Save etcd dir May 30, 2018
Copy link
Member

@timothysc timothysc left a 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

// 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 {
Copy link
Member

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"},
Copy link
Member

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) {
Copy link
Member

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.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 30, 2018
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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

s/%v/%q

@neolit123
Copy link
Member

neolit123 commented May 30, 2018

well done @liztio .
added a couple of small nits. feel free to ignore 👍

@liztio
Copy link
Contributor Author

liztio commented May 31, 2018

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 31, 2018
@liztio
Copy link
Contributor Author

liztio commented May 31, 2018

/remove-hold

@liztio
Copy link
Contributor Author

liztio commented May 31, 2018

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 31, 2018
@liztio liztio changed the title Save etcd dir Save kubeadm manifest backup directories May 31, 2018
@neolit123
Copy link
Member

/test pull-kubernetes-e2e-gce
/test pull-kubernetes-kubemark-e2e-gce-big

return err
}
}

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

@timothysc timothysc left a 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.
Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2018
Copy link
Member

@luxas luxas left a 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 {
Copy link
Member

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"))
Copy link
Member

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?

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@timothysc timothysc added kind/bug Categorizes issue or PR as related to a bug. and removed kind/enhancement milestone/incomplete-labels labels May 31, 2018
@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process

@liztio @luxas @timothysc

Pull Request Labels
  • sig/cluster-lifecycle: Pull Request will be escalated to these SIGs if needed.
  • priority/important-soon: Escalate to the pull request owners and SIG owner; move out of milestone after several unsuccessful escalation attempts.
  • kind/bug: Fixes a bug discovered during the current release.
Help

@jberkus
Copy link

jberkus commented May 31, 2018

/retest

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit 9fee771 into kubernetes:master May 31, 2018
@k8s-ci-robot
Copy link
Contributor

@liztio: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-kubemark-e2e-gce-big 6ed91fc link /test pull-kubernetes-kubemark-e2e-gce-big

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. 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