Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #807 from darkowlzz/storage-uninit
Browse files Browse the repository at this point in the history
Handle error when the backend storage is uninitialized
  • Loading branch information
stealthybox authored Mar 15, 2021
2 parents c8e3902 + 4cfe057 commit 2269681
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cmd/ignite/run/images.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package run

import (
"os"

api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/providers"
"github.com/weaveworks/ignite/pkg/util"
Expand All @@ -14,6 +16,11 @@ type ImagesOptions struct {
func NewImagesOptions() (io *ImagesOptions, err error) {
io = &ImagesOptions{}
io.allImages, err = providers.Client.Images().FindAll(filter.NewAllFilter())
// If the storage is uninitialized, avoid failure and continue with empty
// image list.
if err != nil && os.IsNotExist(err) {
err = nil
}
return
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/ignite/run/kernels.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package run

import (
"os"

api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/providers"
"github.com/weaveworks/ignite/pkg/util"
Expand All @@ -14,6 +16,11 @@ type KernelsOptions struct {
func NewKernelsOptions() (ko *KernelsOptions, err error) {
ko = &KernelsOptions{}
ko.allKernels, err = providers.Client.Kernels().FindAll(filter.NewAllFilter())
// If the storage is uninitialized, avoid failure and continue with empty
// kernel list.
if err != nil && os.IsNotExist(err) {
err = nil
}
return
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/ignite/run/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package run
import (
"bytes"
"fmt"
"strings"
"os"
"text/template"

"github.com/pkg/errors"
Expand Down Expand Up @@ -40,7 +40,7 @@ func (pf *PsFlags) NewPsOptions() (po *PsOptions, err error) {
po.allVMs, err = providers.Client.VMs().FindAll(filter.NewVMFilterAll("", po.All))
// If the storage is uninitialized, avoid failure and continue with empty
// VM list.
if err != nil && strings.Contains(err.Error(), "no such file or directory") {
if err != nil && os.IsNotExist(err) {
err = nil
}
return
Expand Down

0 comments on commit 2269681

Please sign in to comment.