Skip to content

Commit

Permalink
remove comment and handle the error of Unmarshal
Browse files Browse the repository at this point in the history
Signed-off-by: Liu Zhenwei <zwliu@thoughtworks.com>
Signed-off-by: liuzhenwei <dui_zhang@163.com>
  • Loading branch information
diannaowa committed Mar 12, 2024
1 parent 121eb28 commit b4bd74c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apis/apps/pub/inplace_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ type InPlaceUpdateContainerRestartCount struct {
// RestartCount is the container restart count
RestartCount int `json:"restartCount,omitempty"`
// Timestamp is the time for this update
Timestamp metav1.Time `json:"timestamp"`
Timestamp metav1.Time `json:"timestamp,omitempty"`
}

func GetInPlaceUpdateState(obj metav1.Object) (string, bool) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/inplaceupdate/inplace_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ type UpdateSpec struct {
OldTemplate *v1.PodTemplateSpec `json:"oldTemplate,omitempty"`
NewTemplate *v1.PodTemplateSpec `json:"newTemplate,omitempty"`
}

type realControl struct {
podAdapter podadapter.Adapter
revisionAdapter revisionadapter.Interface
Expand Down Expand Up @@ -429,14 +428,15 @@ func recordPodAndContainersRestartCount(pod *v1.Pod, spec *UpdateSpec, revision
}
var currentPodRestartCount int64
containersRestartCount := make(map[string]appspub.InPlaceUpdateContainerRestartCount)
//revision := pod.GetLabels()["controller-revision-hash"]

if v, ok := pod.Annotations[appspub.InPlaceUpdatePodRestartKey]; ok {
currentPodRestartCount, _ = strconv.ParseInt(v, 10, 64)
}

if v, ok := pod.Annotations[appspub.InPlaceUpdateContainersRestartKey]; ok {
_ = json.Unmarshal([]byte(v), &containersRestartCount)
if err := json.Unmarshal([]byte(v), &containersRestartCount); err != nil {
return
}
}
calculateRestartCountFunc := func(cname string) {
containerRestartCount, ok := containersRestartCount[cname]
Expand Down

0 comments on commit b4bd74c

Please sign in to comment.