|
@@ -892,7 +892,7 @@ func (c *Cluster) GetService(input string) (types.Service, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateService updates existing service to match new properties.
|
|
// UpdateService updates existing service to match new properties.
|
|
-func (c *Cluster) UpdateService(serviceID string, version uint64, spec types.ServiceSpec, encodedAuth string) error {
|
|
|
|
|
|
+func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec types.ServiceSpec, encodedAuth string) error {
|
|
c.RLock()
|
|
c.RLock()
|
|
defer c.RUnlock()
|
|
defer c.RUnlock()
|
|
|
|
|
|
@@ -913,6 +913,11 @@ func (c *Cluster) UpdateService(serviceID string, version uint64, spec types.Ser
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ currentService, err := getService(ctx, c.client, serviceIDOrName)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+
|
|
if encodedAuth != "" {
|
|
if encodedAuth != "" {
|
|
ctnr := serviceSpec.Task.GetContainer()
|
|
ctnr := serviceSpec.Task.GetContainer()
|
|
if ctnr == nil {
|
|
if ctnr == nil {
|
|
@@ -922,10 +927,6 @@ func (c *Cluster) UpdateService(serviceID string, version uint64, spec types.Ser
|
|
} else {
|
|
} else {
|
|
// this is needed because if the encodedAuth isn't being updated then we
|
|
// this is needed because if the encodedAuth isn't being updated then we
|
|
// shouldn't lose it, and continue to use the one that was already present
|
|
// shouldn't lose it, and continue to use the one that was already present
|
|
- currentService, err := getService(ctx, c.client, serviceID)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
ctnr := currentService.Spec.Task.GetContainer()
|
|
ctnr := currentService.Spec.Task.GetContainer()
|
|
if ctnr == nil {
|
|
if ctnr == nil {
|
|
return fmt.Errorf("service does not use container tasks")
|
|
return fmt.Errorf("service does not use container tasks")
|
|
@@ -936,7 +937,7 @@ func (c *Cluster) UpdateService(serviceID string, version uint64, spec types.Ser
|
|
_, err = c.client.UpdateService(
|
|
_, err = c.client.UpdateService(
|
|
ctx,
|
|
ctx,
|
|
&swarmapi.UpdateServiceRequest{
|
|
&swarmapi.UpdateServiceRequest{
|
|
- ServiceID: serviceID,
|
|
|
|
|
|
+ ServiceID: currentService.ID,
|
|
Spec: &serviceSpec,
|
|
Spec: &serviceSpec,
|
|
ServiceVersion: &swarmapi.Version{
|
|
ServiceVersion: &swarmapi.Version{
|
|
Index: version,
|
|
Index: version,
|