Skip to content

Commit

Permalink
Use Restic spec hash instead of resource version to restart pods (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Mar 27, 2018
1 parent 4486724 commit afb1746
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/stash/v1alpha1/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const (
LastAppliedConfiguration = ResticKey + "/last-applied-configuration"
VersionTag = ResticKey + "/tag"
// ResourceVersion will be used to trigger restarts for ReplicaSet and RC pods
ResourceVersion = ResticKey + "/resource-version"
ResourceHash = ResticKey + "/resource-hash"
)
10 changes: 10 additions & 0 deletions apis/stash/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package v1alpha1

import (
"hash/fnv"
"strconv"

core "k8s.io/api/core/v1"
hashutil "k8s.io/kubernetes/pkg/util/hash"
)

func (l LocalSpec) ToVolumeAndMount(volName string) (core.Volume, core.VolumeMount) {
Expand All @@ -16,3 +20,9 @@ func (l LocalSpec) ToVolumeAndMount(volName string) (core.Volume, core.VolumeMou
}
return vol, mnt
}

func (r Restic) GetSpecHash() string {
hash := fnv.New64a()
hashutil.DeepHashObject(hash, r.Spec)
return strconv.FormatUint(hash.Sum64(), 10)
}
1 change: 1 addition & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/k8s.io/kubernetes/pkg/util/hash/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afb1746

Please sign in to comment.