Skip to content

Commit

Permalink
Set LastTransitionTime in ExecutionProgress return
Browse files Browse the repository at this point in the history
Signed-off-by: Prasad Ghangal <[email protected]>
  • Loading branch information
PrasadG193 committed Sep 26, 2023
1 parent 7bbcd2c commit 331b077
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pkg/function/backup_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func backupData(ctx context.Context, cli kubernetes.Interface, namespace, pod, c
func (b *backupDataFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(string(b.progressPercent)),
ProgressPercent: b.progressPercent,
LastTransitionTime: &metav1Time,
}, nil

Expand Down
2 changes: 1 addition & 1 deletion pkg/function/backup_data_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func backupDataAll(ctx context.Context, cli kubernetes.Interface, namespace stri
func (b *backupDataAllFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(b.progressPercent),
ProgressPercent: b.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/backup_data_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (*BackupDataStatsFunc) Arguments() []string {
func (b *BackupDataStatsFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(b.progressPercent),
ProgressPercent: b.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/backup_data_using_kopia_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (b *backupDataUsingKopiaServerFunc) Exec(ctx context.Context, tp param.Temp
func (b *backupDataUsingKopiaServerFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(b.progressPercent),
ProgressPercent: b.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/function/checkRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (*CheckRepositoryFunc) Arguments() []string {
func (c *CheckRepositoryFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/copy_volume_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (*copyVolumeDataFunc) Arguments() []string {
func (c *copyVolumeDataFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/create_csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func defaultSnapshotName(pvcName string, len int) string {
func (c *createCSISnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/create_csi_snapshot_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func createCSISnapshotStatic(
func (c *createCSISnapshotStaticFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/create_rds_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (crs *createRDSSnapshotFunc) Arguments() []string {
func (crs *createRDSSnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(crs.progressPercent),
ProgressPercent: crs.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/create_volume_from_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (*createVolumeFromSnapshotFunc) Arguments() []string {
func (crs *createVolumeFromSnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(crs.progressPercent),
ProgressPercent: crs.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/create_volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (*createVolumeSnapshotFunc) Arguments() []string {
func (c *createVolumeSnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/delete_csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (*deleteCSISnapshotFunc) Arguments() []string {
func (c *deleteCSISnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(c.progressPercent),
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/function/delete_csi_snapshot_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ package function

import (
"context"
"time"

kanister "github.com/kanisterio/kanister/pkg"
crv1alpha1 "github.com/kanisterio/kanister/pkg/apis/cr/v1alpha1"
"github.com/kanisterio/kanister/pkg/kube"
"github.com/kanisterio/kanister/pkg/kube/snapshot"
"github.com/kanisterio/kanister/pkg/param"
"github.com/kanisterio/kanister/pkg/progress"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func init() {
Expand Down Expand Up @@ -90,7 +92,11 @@ func (*deleteCSISnapshotContentFunc) Arguments() []string {
}

func (c *deleteCSISnapshotContentFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
return crv1alpha1.PhaseProgress{ProgressPercent: string(c.progressPercent)}, nil
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: c.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}

func deleteCSISnapshotContent(ctx context.Context, snapshotter snapshot.Snapshotter, name string) error {
Expand Down
8 changes: 7 additions & 1 deletion pkg/function/delete_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"

kanister "github.com/kanisterio/kanister/pkg"
Expand Down Expand Up @@ -262,5 +264,9 @@ func (*deleteDataFunc) Arguments() []string {
}

func (d *deleteDataFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
return crv1alpha1.PhaseProgress{ProgressPercent: string(d.progressPercent)}, nil
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/delete_data_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (*deleteDataAllFunc) Arguments() []string {
func (d *deleteDataAllFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/delete_data_using_kopia_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (d *deleteDataUsingKopiaServerFunc) Exec(ctx context.Context, tp param.Temp
func (d *deleteDataUsingKopiaServerFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/function/delete_rds_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (*deleteRDSSnapshotFunc) Arguments() []string {
func (d *deleteRDSSnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/delete_volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (*deleteVolumeSnapshotFunc) Arguments() []string {
func (d *deleteVolumeSnapshotFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/describe_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (*DescribeBackupsFunc) Arguments() []string {
func (d *DescribeBackupsFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/export_rds_snapshot_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (*exportRDSSnapshotToLocationFunc) Arguments() []string {
func (d *exportRDSSnapshotToLocationFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(d.progressPercent),
ProgressPercent: d.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/function/kube_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import (
"io"
"os"
"regexp"
"time"

kanister "github.com/kanisterio/kanister/pkg"
crv1alpha1 "github.com/kanisterio/kanister/pkg/apis/cr/v1alpha1"
"github.com/kanisterio/kanister/pkg/kube"
"github.com/kanisterio/kanister/pkg/output"
"github.com/kanisterio/kanister/pkg/param"
"github.com/kanisterio/kanister/pkg/progress"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func init() {
Expand Down Expand Up @@ -129,5 +131,9 @@ func (*kubeExecFunc) Arguments() []string {
}

func (kef *kubeExecFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
return crv1alpha1.PhaseProgress{ProgressPercent: string(kef.progressPercent)}, nil
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: kef.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
2 changes: 1 addition & 1 deletion pkg/function/kube_exec_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (*kubeExecAllFunc) Arguments() []string {
func (k *kubeExecAllFunc) ExecutionProgress() (crv1alpha1.PhaseProgress, error) {
metav1Time := metav1.NewTime(time.Now())
return crv1alpha1.PhaseProgress{
ProgressPercent: string(k.progressPercent),
ProgressPercent: k.progressPercent,
LastTransitionTime: &metav1Time,
}, nil
}
Expand Down

0 comments on commit 331b077

Please sign in to comment.