Skip to content

Commit d0bae66

Browse files
authored
Fix repository status update (#1208)
* Fix repository status update Signed-off-by: Emruz Hossain <emruz@appscode.com> * Fix restoresession metrics sending Signed-off-by: Emruz Hossain <emruz@appscode.com>
1 parent d7ee2d1 commit d0bae66

File tree

9 files changed

+96
-50
lines changed

9 files changed

+96
-50
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/aws/aws-sdk-go v1.31.9 // indirect
1010
github.com/cenkalti/backoff v2.2.1+incompatible
1111
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27
12-
github.com/go-openapi/spec v0.19.8 // indirect
1312
github.com/go-sql-driver/mysql v1.5.0
1413
github.com/gogo/protobuf v1.3.1
1514
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
@@ -49,7 +48,7 @@ require (
4948
kmodules.xyz/openshift v0.0.0-20200922211657-1ece16d36c18
5049
kmodules.xyz/prober v0.0.0-20200922212142-743a6514664e
5150
kmodules.xyz/webhook-runtime v0.0.0-20200922211931-8337935590de
52-
stash.appscode.dev/apimachinery v0.11.0
51+
stash.appscode.dev/apimachinery v0.11.1-0.20200928173325-6ed3a17b3541
5352
)
5453

5554
replace bitbucket.org/ww/goautoneg => gomodules.xyz/goautoneg v0.0.0-20120707110453-a547fc61f48d

go.sum

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI
175175
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
176176
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
177177
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
178-
github.com/gabriel-vasile/mimetype v1.1.0 h1:+ahX+MvQPFve4kO9Qjjxf3j49i0ACdV236kJlOCRAnU=
179-
github.com/gabriel-vasile/mimetype v1.1.0/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
180178
github.com/gabriel-vasile/mimetype v1.1.1 h1:qbN9MPuRf3bstHu9zkI9jDWNfH//9+9kHxr9oRBBBOA=
181179
github.com/gabriel-vasile/mimetype v1.1.1/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
182180
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -231,8 +229,6 @@ github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsd
231229
github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
232230
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
233231
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
234-
github.com/go-openapi/spec v0.19.7 h1:0xWSeMd35y5avQAThZR2PkEuqSosoS5t6gDH4L8n11M=
235-
github.com/go-openapi/spec v0.19.7/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
236232
github.com/go-openapi/spec v0.19.8 h1:qAdZLh1r6QF/hI/gTq+TJTvsQUodZsM7KLqkAJdiJNg=
237233
github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
238234
github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
@@ -985,36 +981,23 @@ k8s.io/sample-apiserver v0.18.9/go.mod h1:BqskggZvQv6thkecZe2iAoPeNTN7WRu6e5bfDz
985981
k8s.io/system-validators v1.0.4/go.mod h1:HgSgTg4NAGNoYYjKsUyk52gdNi2PVDswQ9Iyn66R7NI=
986982
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU=
987983
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
988-
kmodules.xyz/client-go v0.0.0-20200521005126-35ce6bd4ed46/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
989984
kmodules.xyz/client-go v0.0.0-20200521065424-173e32c78a20/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
990-
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
991985
kmodules.xyz/client-go v0.0.0-20200818143024-600fef263e03/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
992-
kmodules.xyz/client-go v0.0.0-20200915091229-7df16c29f4e8 h1:C6+M9aTLhPCmsJ8dmhPvkr7Qe2MN+iiY3kZvbonhS9E=
993-
kmodules.xyz/client-go v0.0.0-20200915091229-7df16c29f4e8/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
994986
kmodules.xyz/client-go v0.0.0-20200922200830-63d86b6e5b63 h1:luKlEul8LMhyyftoZN34+vboL9MWAeQpSAUZxaLZBGg=
995987
kmodules.xyz/client-go v0.0.0-20200922200830-63d86b6e5b63/go.mod h1:JZN34jqk6ZlR+QOnBPpnUVBab4rmfamqxfSvLaulBMY=
996988
kmodules.xyz/client-go v0.0.0-20200924114038-ef01fa7ccbed h1:xF+qTlIfCZ8R2ingWKcOg9ohrr8WNP+LO5IlBisPTvE=
997989
kmodules.xyz/client-go v0.0.0-20200924114038-ef01fa7ccbed/go.mod h1:JZN34jqk6ZlR+QOnBPpnUVBab4rmfamqxfSvLaulBMY=
998990
kmodules.xyz/constants v0.0.0-20200506032633-a21e58ceec72 h1:0sM6nE7aJon/PSdqZTj0bKJlPyzobXkG0wVYKpjcJJE=
999991
kmodules.xyz/constants v0.0.0-20200506032633-a21e58ceec72/go.mod h1:DbiFk1bJ1KEO94t1SlAn7tzc+Zz95rSXgyUKa2nzPmY=
1000-
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95/go.mod h1:jpu8xFsDKd6kAWUAKk8oTu/GQGBWqhrcaDeOJdaCJnk=
1001992
kmodules.xyz/crd-schema-fuzz v0.0.0-20200922204806-c1426cd7fcf4/go.mod h1:WrO3fryNyFCgqqyWnwI89lnzWA7kN072Ehya7ELGfzE=
1002-
kmodules.xyz/custom-resources v0.0.0-20200604135349-9e9f5c4fdba9 h1:W+k1qhU0W1rptia2PWPOb7IWUvWnf31EMnatXt7MW6w=
1003-
kmodules.xyz/custom-resources v0.0.0-20200604135349-9e9f5c4fdba9/go.mod h1:bu1V7HdnuHc1hgvbqAdcwTViQ0TfZwF3Nu/SjB4vai4=
1004993
kmodules.xyz/custom-resources v0.0.0-20200922210108-70f2815a43bb h1:SwMPMh6A196yoe8kAH+guTNS8rsTfB2dRbFNh6g0Znk=
1005994
kmodules.xyz/custom-resources v0.0.0-20200922210108-70f2815a43bb/go.mod h1:+YU32jSWaGGE4etTr/iCF88tLAeDNq1lhptVymjUbjg=
1006-
kmodules.xyz/objectstore-api v0.0.0-20200521103120-92080446e04d h1:ud3XDScnBdD5q6nLQI/tHLSbuuSwIFaav6IhcQAz2qA=
1007-
kmodules.xyz/objectstore-api v0.0.0-20200521103120-92080446e04d/go.mod h1:k6sbzLWYBLRGDNmCj/NwLgj1cniRXCl9ux/P6+7Xd+A=
1008995
kmodules.xyz/objectstore-api v0.0.0-20200922210707-59bab27e5d41 h1:BsCSSPoY0uRGylfPTUzzQ28h2axuXremPGPzwpmxvYI=
1009996
kmodules.xyz/objectstore-api v0.0.0-20200922210707-59bab27e5d41/go.mod h1:XAWxC/b1ICoufU6XDV0AOHNQY+y+4/B3Z5uyLnW1B6s=
1010-
kmodules.xyz/offshoot-api v0.0.0-20200521035628-e135bf07b226 h1:RZ7H0gl1z/9jLI74YOlGEtNeAknxTEKeAeYH0jakUcM=
1011-
kmodules.xyz/offshoot-api v0.0.0-20200521035628-e135bf07b226/go.mod h1:IbK+hCI23UfTDMzG7hos9sERCase2xsFK+XC0Ns3OCg=
1012997
kmodules.xyz/offshoot-api v0.0.0-20200922211229-36acc531abab h1:d/4AFAN0TfKgwhjbQYzwXXHT/5/vTP7SAAvS4uJX+wQ=
1013998
kmodules.xyz/offshoot-api v0.0.0-20200922211229-36acc531abab/go.mod h1:Wy3/mWK2lWQOviKVpBtiCEYtLaYIaSiym8leZNKBUd4=
1014999
kmodules.xyz/openshift v0.0.0-20200922211657-1ece16d36c18 h1:D1tzbwyrIPJBSmL3W/t2vT2aU3DVEYKf357a392REaY=
10151000
kmodules.xyz/openshift v0.0.0-20200922211657-1ece16d36c18/go.mod h1:kOnEGdrj+DxTYJWHftqEHeYywCgh9tEiBOD5kPhVbCc=
1016-
kmodules.xyz/prober v0.0.0-20200521101241-adf06150535c h1:aV6O9NbDpnFVra/D8c7b7TjI05w/CyI5CYJ8IBg6lg8=
1017-
kmodules.xyz/prober v0.0.0-20200521101241-adf06150535c/go.mod h1:XYWZkfQquD09Mn+O7piHS+SEPq9oFV1Wy2WZ9DA+oeA=
10181001
kmodules.xyz/prober v0.0.0-20200922212142-743a6514664e h1:NASVP0dOE5Zdlq+3Op7Fh2Yc8ei32uf9PxEbuwGLQm0=
10191002
kmodules.xyz/prober v0.0.0-20200922212142-743a6514664e/go.mod h1:AZ58K5hrxkkNPf8tM+UWeZjtNG3/mn192nKcUyC93F8=
10201003
kmodules.xyz/webhook-runtime v0.0.0-20200922211931-8337935590de h1:uWgv78OoOWx9eQdu6SEkPopvbpnL8WxZEMNd3/Oye2w=
@@ -1042,6 +1025,6 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
10421025
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
10431026
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
10441027
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
1045-
stash.appscode.dev/apimachinery v0.11.0 h1:ntvpZDGRsM0f99TBMYrvdtPiF7+d/0th13/EW9d978c=
1046-
stash.appscode.dev/apimachinery v0.11.0/go.mod h1:Cw+8L2u+1T7ZqfYvB2ktdXD/bsWslXNG/bIhk/sV+qs=
1028+
stash.appscode.dev/apimachinery v0.11.1-0.20200928173325-6ed3a17b3541 h1:nZEuGjrOMfoacYEM+buHyTb+F3iwpfH6lSbhB7I+Z18=
1029+
stash.appscode.dev/apimachinery v0.11.1-0.20200928173325-6ed3a17b3541/go.mod h1:txBRRww/eMQ1Z3BVvr7YzwvT9jC+txgN26L4Soj99kk=
10471030
vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI=

pkg/controller/restore_session.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,12 @@ func (c *StashController) setRestorePhaseRunning(invoker apis.RestoreInvoker) er
835835
}
836836

837837
func (c *StashController) setRestorePhaseSucceeded(invoker apis.RestoreInvoker) error {
838+
var err error
838839
// total restore session duration is the difference between the time when restore invoker was created and when it completed
839840
sessionDuration := time.Since(invoker.ObjectMeta.CreationTimestamp.Time).String()
840841

841842
// update restore invoker status
842-
_, err := invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
843+
invoker.Status, err = invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
843844
Phase: api_v1beta1.RestoreSucceeded,
844845
SessionDuration: sessionDuration,
845846
})
@@ -882,11 +883,12 @@ func (c *StashController) setRestorePhaseSucceeded(invoker apis.RestoreInvoker)
882883
}
883884

884885
func (c *StashController) setRestorePhaseFailed(invoker apis.RestoreInvoker, restoreErr error) error {
886+
var err error
885887
// total restore session duration is the difference between the time when restore invoker was created and when it completed
886888
sessionDuration := time.Since(invoker.ObjectMeta.CreationTimestamp.Time).String()
887889

888890
// update restore invoker status
889-
_, err := invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
891+
invoker.Status, err = invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
890892
Phase: api_v1beta1.RestoreFailed,
891893
SessionDuration: sessionDuration,
892894
})
@@ -930,11 +932,12 @@ func (c *StashController) setRestorePhaseFailed(invoker apis.RestoreInvoker, res
930932
}
931933

932934
func (c *StashController) setRestorePhaseUnknown(invoker apis.RestoreInvoker, restoreErr error) error {
935+
var err error
933936
// total restore session duration is the difference between the time when restore invoker was created and when it completed
934937
sessionDuration := time.Since(invoker.ObjectMeta.CreationTimestamp.Time).String()
935938

936939
// update restore invoker status
937-
_, err := invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
940+
invoker.Status, err = invoker.UpdateRestoreInvokerStatus(apis.RestoreInvokerStatus{
938941
Phase: api_v1beta1.RestorePhaseUnknown,
939942
SessionDuration: sessionDuration,
940943
})

pkg/status/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func (o UpdateStatusOptions) executePostBackupActions(invoker apis.Invoker, back
335335
in.SnapshotCount = repoStats.SnapshotCount
336336
in.SnapshotsRemovedOnLastCleanup = repoStats.SnapshotsRemovedOnLastCleanup
337337
in.TotalSize = repoStats.Size
338+
in.LastBackupTime = &backupSession.CreationTimestamp
338339
return in
339340
}, metav1.UpdateOptions{})
340341
return err

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ sigs.k8s.io/structured-merge-diff/v3/typed
12191219
sigs.k8s.io/structured-merge-diff/v3/value
12201220
# sigs.k8s.io/yaml v1.2.0
12211221
sigs.k8s.io/yaml
1222-
# stash.appscode.dev/apimachinery v0.11.0
1222+
# stash.appscode.dev/apimachinery v0.11.1-0.20200928173325-6ed3a17b3541
12231223
stash.appscode.dev/apimachinery/apis
12241224
stash.appscode.dev/apimachinery/apis/repositories
12251225
stash.appscode.dev/apimachinery/apis/repositories/install

vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go

Lines changed: 28 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go

Lines changed: 28 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)