Turn 409 into 500 Try Again Later when using generateName

If a client says they want the name to be generated, a 409 is
not appropriate (since they didn't specify a name). Instead, we
should return the next most appropriate error, which is a 5xx
error indicating the request failed but the client *should* try
again.  Since there is no 5xx error that exactly fits this purpose,
use 500 with StatusReasonTryAgainLater set.

This commit does not implement client retry on TryAgainLater, but
clients should retry up to a certain number of times.
This commit is contained in:
Clayton Coleman
2015-01-28 23:11:29 -05:00
parent e485dc93ca
commit 1588970ec4
21 changed files with 237 additions and 18 deletions

View File

@@ -17,6 +17,8 @@ limitations under the License.
package registrytest
import (
"sync"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
@@ -26,6 +28,13 @@ import (
type ControllerRegistry struct {
Err error
Controllers *api.ReplicationControllerList
sync.Mutex
}
func (r *ControllerRegistry) SetError(err error) {
r.Lock()
defer r.Unlock()
r.Err = err
}
func (r *ControllerRegistry) ListControllers(ctx api.Context) (*api.ReplicationControllerList, error) {
@@ -37,6 +46,8 @@ func (r *ControllerRegistry) GetController(ctx api.Context, ID string) (*api.Rep
}
func (r *ControllerRegistry) CreateController(ctx api.Context, controller *api.ReplicationController) error {
r.Lock()
defer r.Unlock()
return r.Err
}

View File

@@ -52,6 +52,12 @@ func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *Minio
}
}
func (r *MinionRegistry) SetError(err error) {
r.Lock()
defer r.Unlock()
r.Err = err
}
func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.NodeList, error) {
r.Lock()
defer r.Unlock()

View File

@@ -40,6 +40,12 @@ func NewPodRegistry(pods *api.PodList) *PodRegistry {
}
}
func (r *PodRegistry) SetError(err error) {
r.Lock()
defer r.Unlock()
r.Err = err
}
func (r *PodRegistry) ListPodsPredicate(ctx api.Context, filter func(*api.Pod) bool) (*api.PodList, error) {
r.Lock()
defer r.Unlock()

View File

@@ -41,6 +41,12 @@ type ServiceRegistry struct {
UpdatedID string
}
func (r *ServiceRegistry) SetError(err error) {
r.mu.Lock()
defer r.mu.Unlock()
r.Err = err
}
func (r *ServiceRegistry) ListServices(ctx api.Context) (*api.ServiceList, error) {
r.mu.Lock()
defer r.mu.Unlock()