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

Add kubectl rollout history #19893

Merged

Conversation

janetkuo
Copy link
Member

Addresses #17168; depends on #19581 and #19882.
See proposal.

Sample output:

$ kubectl rollout history deployment
Deployment "nginx-deployment":
REVISION    CHANGE-CAUSE
1           kubectl create -f deployment.yaml

Deployment "redis-deployment":
REVISION    CHANGE-CAUSE
1           kubectl create -f deployment.yaml
2           kubectl apply -f deployment.yaml

$ kubectl rollout history deployment --revision=1
Deployment "nginx-deployment" revision 1
Labels:     deployment.kubernetes.io/podTemplateHash=811039852,name=nginx
Annotations:    <none>
Image(s):   nginx
No volumes.

Deployment "redis-deployment" revision 1
Labels:     deployment.kubernetes.io/podTemplateHash=1905753157,name=redis
Annotations:    <none>
Image(s):   redis
No volumes.

cc @bgrant0607 @nikhiljindal @ironcladlou @Kargakis @kubernetes/sig-config @kubernetes/kubectl @madhusudancs

@k8s-github-robot
Copy link

Labelling this PR as size/XL

@k8s-github-robot k8s-github-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 20, 2016
@janetkuo janetkuo force-pushed the kubectl-rollout-history branch from 889c3d9 to 065ff4e Compare January 21, 2016 00:59
@k8s-bot
Copy link

k8s-bot commented Jan 21, 2016

GCE e2e test build/test passed for commit 889c3d9220f7ee040506330e7bec80a486e19c8c.

@k8s-bot
Copy link

k8s-bot commented Jan 21, 2016

GCE e2e test build/test passed for commit 065ff4e242eebd4076876540f1ec88ed1b7aba84.

@bgrant0607 bgrant0607 assigned bgrant0607 and unassigned lavalamp Jan 22, 2016
}
sort.Ints(versions)

fmt.Fprintf(out, "VERSION\n")
Copy link
Member

Choose a reason for hiding this comment

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

The initial version doesn't need to be too fancy, but how about displaying change-source?

It might also make sense to add a column for the image, since that will often be what changed.

In the future, we might also want to think about how to summarize what changed, perhaps by doing a strategic diff and categorizing different parts of the pod template: image (I), env (E), volumes (V), resources (R), scheduling constraints (S), other (O).

@bgrant0607
Copy link
Member

cc @ghodss

@bgrant0607
Copy link
Member

Needs to be updated to Revision, but otherwise looks like a reasonable first cut.

@k8s-github-robot
Copy link

PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2016
@janetkuo janetkuo force-pushed the kubectl-rollout-history branch from 065ff4e to 3929a78 Compare January 30, 2016 00:43
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2016
@k8s-github-robot
Copy link

Labelling this PR as size/XXL

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/new-api size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 30, 2016
@k8s-bot
Copy link

k8s-bot commented Jan 30, 2016

GCE e2e test build/test passed for commit 3929a787714a16a38ae4c4b0f9cb3f724da2ef42.

@janetkuo janetkuo force-pushed the kubectl-rollout-history branch from 3929a78 to ee29c56 Compare January 30, 2016 01:37
@janetkuo
Copy link
Member Author

@bgrant0607 Code updated; PTAL (Note that the support for recording kubectl commands is in #20035 but not here)

Sample output:

$ kubectl rollout history deployment
Deployment "nginx-deployment":
REVISION    CHANGE-CAUSE
1           kubectl create -f deployment.yaml

Deployment "redis-deployment":
REVISION    CHANGE-CAUSE
1           kubectl create -f deployment.yaml
2           kubectl apply -f deployment.yaml

$ kubectl rollout history deployment --revision=1
Deployment "nginx-deployment" revision 1
Labels:     deployment.kubernetes.io/podTemplateHash=811039852,name=nginx
Annotations:    <none>
Image(s):   nginx
No volumes.

Deployment "redis-deployment" revision 1
Labels:     deployment.kubernetes.io/podTemplateHash=1905753157,name=redis
Annotations:    <none>
Image(s):   redis
No volumes.

@janetkuo janetkuo changed the title RFC: Add kubectl rollout history [LGTM] Add kubectl rollout history [LGTM] Jan 31, 2016
@k8s-bot
Copy link

k8s-bot commented Jan 31, 2016

GCE e2e test build/test passed for commit 86e8d37551b2026af599d753485938c77cedc56b.

Latest().
Flatten().
Do()
err = r.Err()
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is redundant, r.Infos() will run it for you

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@k8s-bot
Copy link

k8s-bot commented Feb 1, 2016

GCE e2e build/test failed for commit d777c2256c98fb3f5b016fd6f2f96f8e2ea9015b.

@janetkuo janetkuo force-pushed the kubectl-rollout-history branch from d777c22 to 0f28ffc Compare February 1, 2016 19:08
@janetkuo
Copy link
Member Author

janetkuo commented Feb 1, 2016

@Kargakis all comments addressed; PTAL

@k8s-bot
Copy link

k8s-bot commented Feb 1, 2016

GCE e2e test build/test passed for commit 0f28ffcfba1aa72ef418fd4e4d85724139533630.

@@ -42,7 +42,8 @@ import (
)

const (
ApplyAnnotationsFlag = "save-config"
ApplyAnnotationsFlag = "save-config"
ChangeCauseAnnotation = "kubernetes.io/change-cause"
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this annotation twice; here and in pkg/kubectl/history.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed it here

@janetkuo
Copy link
Member Author

janetkuo commented Feb 1, 2016

@Kargakis PTAL

@k8s-bot
Copy link

k8s-bot commented Feb 1, 2016

GCE e2e test build/test passed for commit feee1565598e31299312e9ecee6209bb8494ed5b.

errs := []error{}
for _, r := range revisions {
// Find the change-cause of revision r
r64, err := strconv.ParseInt(r, 10, 64)
Copy link
Contributor

Choose a reason for hiding this comment

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

ugh, this is tiring. How about:

var revisions []int
for k := range historyInfo.RevisionToTemplate {
    revisions = append(revisions, int(k))
}
sort.Ints(revisions)
// ...
for _, r := range revisions {
   changeCause := historyInfo.RevisionToTemplate[int64(r)].Annotations[ChangeCauseAnnotation]
  // ...

Copy link
Member Author

Choose a reason for hiding this comment

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

revision is int64 and sort doesn't supports int64.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that I cast between int and int64 which is better than casting between strings and int64

Also https://golang.org/pkg/sort/#Ints

Copy link
Member Author

Choose a reason for hiding this comment

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

What if revision is something like int64(3546343826724305832)? It's incorrect after int(revision).

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I guess string->int64 is safer. But will we ever get to such numbers? Anyway, I am fine with this too

@0xmichalis
Copy link
Contributor

two last comments, lgtm after they are addressed and you squash

@janetkuo janetkuo force-pushed the kubectl-rollout-history branch from feee156 to 8fb86a3 Compare February 1, 2016 23:35
@janetkuo
Copy link
Member Author

janetkuo commented Feb 1, 2016

Squashed. PTAL on the comment that's not addressed.

@k8s-bot
Copy link

k8s-bot commented Feb 2, 2016

GCE e2e test build/test passed for commit 8fb86a3.

@janetkuo janetkuo added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 2, 2016
@janetkuo janetkuo changed the title Add kubectl rollout history [LGTM] Add kubectl rollout history Feb 2, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Feb 2, 2016

GCE e2e test build/test passed for commit 8fb86a3.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Feb 2, 2016
@k8s-github-robot k8s-github-robot merged commit 17a5058 into kubernetes:master Feb 2, 2016
@janetkuo janetkuo added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/app-lifecycle area/kubectl lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants