Skip to content

Commit 538ba84

Browse files
committed
libct/error.go: rm ConfigError
ConfigError was added by commit e918d02, while removing runc own error system, to preserve a way for a libcontainer user to distinguish between a configuration error and something else. The way ConfigError is implemented requires a different type of check (compared to all other errors defined by error.go). An attempt was made to rectify this, but the resulting code became even more complicated. As no one is using this functionality (of differentiating a "bad config" type of error from other errors), let's just drop the ConfigError type. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 6145628 commit 538ba84

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

libcontainer/container_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (c *linuxContainer) Start(process *Process) error {
231231
c.m.Lock()
232232
defer c.m.Unlock()
233233
if c.config.Cgroups.Resources.SkipDevices {
234-
return &ConfigError{"can't start container with SkipDevices set"}
234+
return errors.New("can't start container with SkipDevices set")
235235
}
236236
if process.Init {
237237
if err := c.createExecFifo(); err != nil {

libcontainer/error.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,3 @@ var (
1111
ErrNotRunning = errors.New("container not running")
1212
ErrNotPaused = errors.New("container not paused")
1313
)
14-
15-
type ConfigError struct {
16-
details string
17-
}
18-
19-
func (e *ConfigError) Error() string {
20-
return "invalid configuration: " + e.details
21-
}

libcontainer/factory_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ type LinuxFactory struct {
251251

252252
func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, error) {
253253
if l.Root == "" {
254-
return nil, &ConfigError{"invalid root"}
254+
return nil, errors.New("root not set")
255255
}
256256
if err := l.validateID(id); err != nil {
257257
return nil, err
258258
}
259259
if err := l.Validator.Validate(config); err != nil {
260-
return nil, &ConfigError{err.Error()}
260+
return nil, err
261261
}
262262
containerRoot, err := securejoin.SecureJoin(l.Root, id)
263263
if err != nil {
@@ -294,7 +294,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
294294

295295
func (l *LinuxFactory) Load(id string) (Container, error) {
296296
if l.Root == "" {
297-
return nil, &ConfigError{"invalid root"}
297+
return nil, errors.New("root not set")
298298
}
299299
// when load, we need to check id is valid or not.
300300
if err := l.validateID(id); err != nil {

0 commit comments

Comments
 (0)