run go gmt
Signed-off-by: Kuromesi <blackfacepan@163.com>
This commit is contained in:
parent
852e3d78f9
commit
4631a0d2e2
|
|
@ -151,11 +151,11 @@ func TestIsBatchReady(t *testing.T) {
|
|||
func generatePods(updatedReplicas, noNeedRollbackReplicas int) []*corev1.Pod {
|
||||
podsNoNeed := generatePodsWith(map[string]string{
|
||||
util.NoNeedUpdatePodLabel: "0x1",
|
||||
v1beta1.RolloutIDLabel: "1",
|
||||
v1beta1.RolloutIDLabel: "1",
|
||||
apps.ControllerRevisionHashLabelKey: "version-1",
|
||||
}, noNeedRollbackReplicas, 0)
|
||||
return append(generatePodsWith(map[string]string{
|
||||
v1beta1.RolloutIDLabel: "1",
|
||||
v1beta1.RolloutIDLabel: "1",
|
||||
apps.ControllerRevisionHashLabelKey: "version-1",
|
||||
}, updatedReplicas-noNeedRollbackReplicas, noNeedRollbackReplicas), podsNoNeed...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ func TestLabelPatcher(t *testing.T) {
|
|||
|
||||
func generatePods(ordinalBegin, ordinalEnd, labeled int32, rolloutID, batchID, version string) []*corev1.Pod {
|
||||
podsWithLabel := generateLabeledPods(map[string]string{
|
||||
v1beta1.RolloutIDLabel: rolloutID,
|
||||
v1beta1.RolloutBatchIDLabel: batchID,
|
||||
v1beta1.RolloutIDLabel: rolloutID,
|
||||
v1beta1.RolloutBatchIDLabel: batchID,
|
||||
apps.ControllerRevisionHashLabelKey: version,
|
||||
}, int(labeled), int(ordinalBegin))
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ func TestReconcile(t *testing.T) {
|
|||
pod1.Labels = map[string]string{
|
||||
rolloutv1beta1.RolloutBatchIDLabel: "1",
|
||||
rolloutv1beta1.RolloutIDLabel: "2",
|
||||
"app": "echoserver",
|
||||
"app": "echoserver",
|
||||
}
|
||||
|
||||
pod2 := podDemo.DeepCopy()
|
||||
|
|
@ -428,7 +428,7 @@ func TestReconcile(t *testing.T) {
|
|||
pod2.Labels = map[string]string{
|
||||
rolloutv1beta1.RolloutBatchIDLabel: "2",
|
||||
rolloutv1beta1.RolloutIDLabel: "2",
|
||||
"app": "echoserver",
|
||||
"app": "echoserver",
|
||||
}
|
||||
|
||||
pod3 := podDemo.DeepCopy()
|
||||
|
|
@ -440,7 +440,7 @@ func TestReconcile(t *testing.T) {
|
|||
pod3.Labels = map[string]string{
|
||||
rolloutv1beta1.RolloutBatchIDLabel: "3",
|
||||
rolloutv1beta1.RolloutIDLabel: "2",
|
||||
"app": "echoserver",
|
||||
"app": "echoserver",
|
||||
}
|
||||
|
||||
pod4 := podDemo.DeepCopy()
|
||||
|
|
@ -452,7 +452,7 @@ func TestReconcile(t *testing.T) {
|
|||
pod4.Labels = map[string]string{
|
||||
rolloutv1beta1.RolloutBatchIDLabel: "3",
|
||||
rolloutv1beta1.RolloutIDLabel: "2",
|
||||
"app": "echoserver",
|
||||
"app": "echoserver",
|
||||
}
|
||||
|
||||
pod5 := podDemo.DeepCopy()
|
||||
|
|
@ -464,7 +464,7 @@ func TestReconcile(t *testing.T) {
|
|||
pod5.Labels = map[string]string{
|
||||
rolloutv1beta1.RolloutBatchIDLabel: "3",
|
||||
rolloutv1beta1.RolloutIDLabel: "2",
|
||||
"app": "echoserver",
|
||||
"app": "echoserver",
|
||||
}
|
||||
|
||||
return []*corev1.Pod{pod1, pod2, pod3, pod4, pod5}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ const (
|
|||
//
|
||||
// Note:
|
||||
//
|
||||
// 1. Writer reserves the set of pathnames starting with `..`.
|
||||
// 2. Writer offers no concurrency guarantees and must be synchronized
|
||||
// by the caller.
|
||||
// 1. Writer reserves the set of pathnames starting with `..`.
|
||||
// 2. Writer offers no concurrency guarantees and must be synchronized
|
||||
// by the caller.
|
||||
//
|
||||
// The visible files in this volume are symlinks to files in the writer's data
|
||||
// directory. Actual files are stored in a hidden timestamped directory which
|
||||
|
|
@ -86,33 +86,42 @@ const (
|
|||
//
|
||||
// The Write algorithm is:
|
||||
//
|
||||
// 1. The payload is validated; if the payload is invalid, the function returns
|
||||
// 2. The current timestamped directory is detected by reading the data directory
|
||||
// symlink
|
||||
// 3. The old version of the volume is walked to determine whether any
|
||||
// portion of the payload was deleted and is still present on disk.
|
||||
// 4. The data in the current timestamped directory is compared to the projected
|
||||
// data to determine if an update is required.
|
||||
// 5. A new timestamped dir is created
|
||||
// 6. The payload is written to the new timestamped directory
|
||||
// 7. Symlinks and directory for new user-visible files are created (if needed).
|
||||
// 1. The payload is validated; if the payload is invalid, the function returns
|
||||
//
|
||||
// For example, consider the files:
|
||||
// <target-dir>/podName
|
||||
// <target-dir>/user/labels
|
||||
// <target-dir>/k8s/annotations
|
||||
// 2. The current timestamped directory is detected by reading the data directory
|
||||
// symlink
|
||||
//
|
||||
// The user visible files are symbolic links into the internal data directory:
|
||||
// <target-dir>/podName -> ..data/podName
|
||||
// <target-dir>/usr -> ..data/usr
|
||||
// <target-dir>/k8s -> ..data/k8s
|
||||
// 3. The old version of the volume is walked to determine whether any
|
||||
// portion of the payload was deleted and is still present on disk.
|
||||
//
|
||||
// 4. The data in the current timestamped directory is compared to the projected
|
||||
// data to determine if an update is required.
|
||||
//
|
||||
// 5. A new timestamped dir is created
|
||||
//
|
||||
// 6. The payload is written to the new timestamped directory
|
||||
//
|
||||
// 7. Symlinks and directory for new user-visible files are created (if needed).
|
||||
//
|
||||
// For example, consider the files:
|
||||
// <target-dir>/podName
|
||||
// <target-dir>/user/labels
|
||||
// <target-dir>/k8s/annotations
|
||||
//
|
||||
// The user visible files are symbolic links into the internal data directory:
|
||||
// <target-dir>/podName -> ..data/podName
|
||||
// <target-dir>/usr -> ..data/usr
|
||||
// <target-dir>/k8s -> ..data/k8s
|
||||
//
|
||||
// The data directory itself is a link to a timestamped directory with
|
||||
// the real data:
|
||||
// <target-dir>/..data -> ..2016_02_01_15_04_05.12345678/
|
||||
//
|
||||
// 8. A symlink to the new timestamped directory ..data_tmp is created that will
|
||||
// become the new data directory
|
||||
//
|
||||
// 9. The new data directory symlink is renamed to the data directory; rename is atomic
|
||||
//
|
||||
// The data directory itself is a link to a timestamped directory with
|
||||
// the real data:
|
||||
// <target-dir>/..data -> ..2016_02_01_15_04_05.12345678/
|
||||
// 8. A symlink to the new timestamped directory ..data_tmp is created that will
|
||||
// become the new data directory
|
||||
// 9. The new data directory symlink is renamed to the data directory; rename is atomic
|
||||
// 10. Old paths are removed from the user-visible portion of the target directory
|
||||
// 11. The previous timestamped directory is removed, if it exists
|
||||
func (w *Writer) Write(payload map[string]FileProjection) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue