-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Add kubectl rollout history #19893
Conversation
Labelling this PR as size/XL |
889c3d9
to
065ff4e
Compare
GCE e2e test build/test passed for commit 889c3d9220f7ee040506330e7bec80a486e19c8c. |
GCE e2e test build/test passed for commit 065ff4e242eebd4076876540f1ec88ed1b7aba84. |
} | ||
sort.Ints(versions) | ||
|
||
fmt.Fprintf(out, "VERSION\n") |
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 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).
cc @ghodss |
Needs to be updated to Revision, but otherwise looks like a reasonable first cut. |
PR needs rebase |
065ff4e
to
3929a78
Compare
Labelling this PR as size/XXL |
GCE e2e test build/test passed for commit 3929a787714a16a38ae4c4b0f9cb3f724da2ef42. |
3929a78
to
ee29c56
Compare
@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. |
GCE e2e test build/test passed for commit 86e8d37551b2026af599d753485938c77cedc56b. |
Latest(). | ||
Flatten(). | ||
Do() | ||
err = r.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.
This check is redundant, r.Infos() will run it for you
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.
Done
GCE e2e build/test failed for commit d777c2256c98fb3f5b016fd6f2f96f8e2ea9015b. |
d777c22
to
0f28ffc
Compare
@Kargakis all comments addressed; PTAL |
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" |
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 see this annotation twice; here and in pkg/kubectl/history.go
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.
Removed it here
@Kargakis PTAL |
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) |
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.
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]
// ...
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.
revision is int64
and sort
doesn't supports int64
.
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.
Note that I cast between int and int64 which is better than casting between strings and int64
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.
What if revision is something like int64(3546343826724305832)
? It's incorrect after int(revision)
.
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.
Well, I guess string->int64 is safer. But will we ever get to such numbers? Anyway, I am fine with this too
two last comments, lgtm after they are addressed and you squash |
feee156
to
8fb86a3
Compare
Squashed. PTAL on the comment that's not addressed. |
GCE e2e test build/test passed for commit 8fb86a3. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit 8fb86a3. |
Automatic merge from submit-queue |
Auto commit by PR queue bot
Addresses #17168; depends on #19581 and #19882.
See proposal.
Sample output:
cc @bgrant0607 @nikhiljindal @ironcladlou @Kargakis @kubernetes/sig-config @kubernetes/kubectl @madhusudancs