Skip to content

Commit

Permalink
Don't fail on unavailable features on OpenStack.
Browse files Browse the repository at this point in the history
Currently if we are looking for extensions for Neutron or try to list
services, it might happen, that underlying OpenStack cloud doesn't
support listing either extension or services. This patch is fixing it,
and assumption is, that trunk support is disabled in a case of
inability of listing Neutron extensions, and/or octavia support is
disabled in case of inability of listing services, instead of aborting
installation.
  • Loading branch information
gryf committed Feb 5, 2020
1 parent 552f107 commit ff6fc50
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions pkg/asset/installconfig/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
survey "gopkg.in/AlecAivazis/survey.v1"

"github.com/openshift/installer/pkg/types/openstack"
Expand Down Expand Up @@ -124,30 +125,29 @@ func Platform() (*openstack.Platform, error) {
return nil, err
}

trunkSupport := "0"
var i int
netExts, err := validValuesFetcher.GetNetworkExtensionsAliases(cloud)
if err != nil {
return nil, err
}
sort.Strings(netExts)
i := sort.SearchStrings(netExts, "trunk")
var trunkSupport string
if i == len(netExts) || netExts[i] != "trunk" {
trunkSupport = "0"
logrus.Warning("Could not retrieve networking extension aliases.")
} else {
trunkSupport = "1"
sort.Strings(netExts)
i = sort.SearchStrings(netExts, "trunk")
if i != len(netExts) && netExts[i] == "trunk" {
trunkSupport = "1"
}
}

octaviaSupport := "0"
serviceCatalog, err := validValuesFetcher.GetServiceCatalog(cloud)
if err != nil {
return nil, err
}
sort.Strings(serviceCatalog)
i = sort.SearchStrings(serviceCatalog, "octavia")
var octaviaSupport string
if i == len(serviceCatalog) || serviceCatalog[i] != "octavia" {
octaviaSupport = "0"
logrus.Warning("Could not retrieve service catalog.")
} else {
octaviaSupport = "1"
sort.Strings(serviceCatalog)
i = sort.SearchStrings(serviceCatalog, "octavia")
if i != len(serviceCatalog) && serviceCatalog[i] == "octavia" {
octaviaSupport = "1"
}
}

return &openstack.Platform{
Expand Down
12 changes: 6 additions & 6 deletions pkg/types/openstack/validation/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package validation
import (
"errors"

"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/openshift/installer/pkg/types"
Expand Down Expand Up @@ -31,24 +32,23 @@ func ValidatePlatform(p *openstack.Platform, n *types.Networking, fldPath *field
} else if !isValidValue(p.FlavorName, validFlavors) {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("computeFlavor"), p.FlavorName, validFlavors))
}
p.TrunkSupport = "0"
netExts, err := fetcher.GetNetworkExtensionsAliases(p.Cloud)
if err != nil {
allErrs = append(allErrs, field.InternalError(fldPath.Child("trunkSupport"), errors.New("could not retrieve networking extension aliases")))
logrus.Warning("Could not retrieve networking extension aliases.")
} else {
if isValidValue("trunk", netExts) {
p.TrunkSupport = "1"
} else {
p.TrunkSupport = "0"
}
}
p.OctaviaSupport = "0"
serviceCatalog, err := fetcher.GetServiceCatalog(p.Cloud)
if err != nil {
allErrs = append(allErrs, field.InternalError(fldPath.Child("octaviaSupport"), errors.New("could not retrieve service catalog")))
logrus.Warning("Could not retrieve service catalog.")
p.OctaviaSupport = "0"
} else {
if isValidValue("octavia", serviceCatalog) {
p.OctaviaSupport = "1"
} else {
p.OctaviaSupport = "0"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/openstack/validation/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func TestValidatePlatform(t *testing.T) {
name: "network extensions fetch failure",
platform: validPlatform(),
noNetExts: true,
valid: false,
valid: true,
},
{
name: "service catalog fetch failure",
platform: validPlatform(),
noServiceCatalog: true,
valid: false,
valid: true,
},
}
for _, tc := range cases {
Expand Down

0 comments on commit ff6fc50

Please sign in to comment.