Merge pull request #39281 from dperny/vendor-swarmkit

Revert docker/swarmkit#2804
This commit is contained in:
Tibor Vass 2019-06-04 10:28:42 -07:00 committed by GitHub
commit 54043d2f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 39 deletions

View File

@ -33,7 +33,7 @@ func TestServiceUpdateLabel(t *testing.T) {
service.Spec.Labels["foo"] = "bar" service.Spec.Labels["foo"] = "bar"
_, err := cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{}) _, err := cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
poll.WaitOn(t, serviceIsUpdated(cli, serviceID), swarm.ServicePoll) poll.WaitOn(t, serviceSpecIsUpdated(cli, serviceID, service.Version.Index), swarm.ServicePoll)
service = getService(t, cli, serviceID) service = getService(t, cli, serviceID)
assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"})) assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"}))
@ -41,21 +41,21 @@ func TestServiceUpdateLabel(t *testing.T) {
service.Spec.Labels["foo2"] = "bar" service.Spec.Labels["foo2"] = "bar"
_, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{}) _, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
poll.WaitOn(t, serviceIsUpdated(cli, serviceID), swarm.ServicePoll) poll.WaitOn(t, serviceSpecIsUpdated(cli, serviceID, service.Version.Index), swarm.ServicePoll)
service = getService(t, cli, serviceID) service = getService(t, cli, serviceID)
assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar", "foo2": "bar"})) assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar", "foo2": "bar"}))
delete(service.Spec.Labels, "foo2") delete(service.Spec.Labels, "foo2")
_, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{}) _, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
poll.WaitOn(t, serviceIsUpdated(cli, serviceID), swarm.ServicePoll) poll.WaitOn(t, serviceSpecIsUpdated(cli, serviceID, service.Version.Index), swarm.ServicePoll)
service = getService(t, cli, serviceID) service = getService(t, cli, serviceID)
assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"})) assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"}))
delete(service.Spec.Labels, "foo") delete(service.Spec.Labels, "foo")
_, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{}) _, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
poll.WaitOn(t, serviceIsUpdated(cli, serviceID), swarm.ServicePoll) poll.WaitOn(t, serviceSpecIsUpdated(cli, serviceID, service.Version.Index), swarm.ServicePoll)
service = getService(t, cli, serviceID) service = getService(t, cli, serviceID)
assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{})) assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{}))
@ -63,7 +63,7 @@ func TestServiceUpdateLabel(t *testing.T) {
service.Spec.Labels["foo"] = "bar" service.Spec.Labels["foo"] = "bar"
_, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{}) _, err = cli.ServiceUpdate(ctx, serviceID, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(t, err) assert.NilError(t, err)
poll.WaitOn(t, serviceIsUpdated(cli, serviceID), swarm.ServicePoll) poll.WaitOn(t, serviceSpecIsUpdated(cli, serviceID, service.Version.Index), swarm.ServicePoll)
service = getService(t, cli, serviceID) service = getService(t, cli, serviceID)
assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"})) assert.Check(t, is.DeepEqual(service.Spec.Labels, map[string]string{"foo": "bar"}))
@ -271,3 +271,17 @@ func serviceIsUpdated(client client.ServiceAPIClient, serviceID string) func(log
} }
} }
} }
func serviceSpecIsUpdated(client client.ServiceAPIClient, serviceID string, serviceOldVersion uint64) func(log poll.LogT) poll.Result {
return func(log poll.LogT) poll.Result {
service, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
switch {
case err != nil:
return poll.Error(err)
case service.Version.Index > serviceOldVersion:
return poll.Success()
default:
return poll.Continue("waiting for service %s to be updated", serviceID)
}
}
}

View File

@ -130,7 +130,7 @@ github.com/containerd/ttrpc f02858b1457c5ca3aaec3a0803eb
github.com/gogo/googleapis d31c731455cb061f42baff3bda55bad0118b126b # v1.2.0 github.com/gogo/googleapis d31c731455cb061f42baff3bda55bad0118b126b # v1.2.0
# cluster # cluster
github.com/docker/swarmkit 1e20cbf4caaeaba79c75af00bce5f41085db4082 github.com/docker/swarmkit fb584e7b501ec4683b5c3e62476d76b8a7e7d9f6
github.com/gogo/protobuf ba06b47c162d49f2af050fb4c75bcbc86a159d5c # v1.2.1 github.com/gogo/protobuf ba06b47c162d49f2af050fb4c75bcbc86a159d5c # v1.2.1
github.com/cloudflare/cfssl 5d63dbd981b5c408effbb58c442d54761ff94fbd # 1.3.2 github.com/cloudflare/cfssl 5d63dbd981b5c408effbb58c442d54761ff94fbd # 1.3.2
github.com/fernet/fernet-go 9eac43b88a5efb8651d24de9b68e87567e029736 github.com/fernet/fernet-go 9eac43b88a5efb8651d24de9b68e87567e029736

View File

@ -141,17 +141,10 @@ func (u *Updater) Run(ctx context.Context, slots []orchestrator.Slot) {
} }
// Abort immediately if all tasks are clean. // Abort immediately if all tasks are clean.
if len(dirtySlots) == 0 { if len(dirtySlots) == 0 {
if service.UpdateStatus == nil { if service.UpdateStatus != nil &&
if u.annotationsUpdated(service) { (service.UpdateStatus.State == api.UpdateStatus_UPDATING ||
// Annotation-only update; mark the update as completed service.UpdateStatus.State == api.UpdateStatus_ROLLBACK_STARTED) {
u.completeUpdate(ctx, service.ID, true) u.completeUpdate(ctx, service.ID)
}
return
}
if service.UpdateStatus.State == api.UpdateStatus_UPDATING || service.UpdateStatus.State == api.UpdateStatus_ROLLBACK_STARTED {
// Update or rollback was started, and is now complete
u.completeUpdate(ctx, service.ID, true)
return
} }
return return
} }
@ -310,7 +303,7 @@ slotsLoop:
// have reached RUNNING by this point. // have reached RUNNING by this point.
if !stopped { if !stopped {
u.completeUpdate(ctx, service.ID, false) u.completeUpdate(ctx, service.ID)
} }
} }
@ -623,32 +616,25 @@ func (u *Updater) rollbackUpdate(ctx context.Context, serviceID, message string)
} }
} }
func (u *Updater) completeUpdate(ctx context.Context, serviceID string, force bool) { func (u *Updater) completeUpdate(ctx context.Context, serviceID string) {
log.G(ctx).Debugf("update of service %s complete", serviceID) log.G(ctx).Debugf("update of service %s complete", serviceID)
err := u.store.Update(func(tx store.Tx) error { err := u.store.Update(func(tx store.Tx) error {
service := store.GetService(tx, serviceID) service := store.GetService(tx, serviceID)
switch { if service == nil {
case service == nil:
return nil return nil
case service.UpdateStatus == nil && force:
// Force marking the status as updated; to account for annotation-only updates.
service.UpdateStatus = &api.UpdateStatus{
StartedAt: ptypes.MustTimestampProto(time.Now()),
State: api.UpdateStatus_COMPLETED,
Message: "update completed",
} }
case service.UpdateStatus == nil: if service.UpdateStatus == nil {
// The service was changed since we started this update // The service was changed since we started this update
return nil return nil
case service.UpdateStatus.State == api.UpdateStatus_ROLLBACK_STARTED: }
if service.UpdateStatus.State == api.UpdateStatus_ROLLBACK_STARTED {
service.UpdateStatus.State = api.UpdateStatus_ROLLBACK_COMPLETED service.UpdateStatus.State = api.UpdateStatus_ROLLBACK_COMPLETED
service.UpdateStatus.Message = "rollback completed" service.UpdateStatus.Message = "rollback completed"
default: } else {
service.UpdateStatus.State = api.UpdateStatus_COMPLETED service.UpdateStatus.State = api.UpdateStatus_COMPLETED
service.UpdateStatus.Message = "update completed" service.UpdateStatus.Message = "update completed"
} }
service.UpdateStatus.CompletedAt = ptypes.MustTimestampProto(time.Now()) service.UpdateStatus.CompletedAt = ptypes.MustTimestampProto(time.Now())
return store.UpdateService(tx, service) return store.UpdateService(tx, service)
@ -658,10 +644,3 @@ func (u *Updater) completeUpdate(ctx context.Context, serviceID string, force bo
log.G(ctx).WithError(err).Errorf("failed to mark update of service %s complete", serviceID) log.G(ctx).WithError(err).Errorf("failed to mark update of service %s complete", serviceID)
} }
} }
func (u *Updater) annotationsUpdated(service *api.Service) bool {
if service.PreviousSpec == nil {
return false
}
return !reflect.DeepEqual(service.Spec, service.PreviousSpec)
}