A few real-world fixes to create-cluster around initialization

This commit is contained in:
Justin Santa Barbara 2016-12-18 23:56:36 -05:00
parent 91b77ae11e
commit aeef9dc6eb
3 changed files with 18 additions and 15 deletions

View File

@ -82,6 +82,7 @@ func (o *CreateClusterOptions) InitDefaults() {
func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command { func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
options := &CreateClusterOptions{} options := &CreateClusterOptions{}
options.InitDefaults()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster",
@ -454,13 +455,7 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
cluster.Spec.Subnets[i].Type = api.SubnetTypePrivate cluster.Spec.Subnets[i].Type = api.SubnetTypePrivate
} }
if c.Bastion { var utilitySubnets []api.ClusterSubnetSpec
bastionGroup := &api.InstanceGroup{}
bastionGroup.Spec.Role = api.InstanceGroupRoleBastion
bastionGroup.ObjectMeta.Name = "bastions"
instanceGroups = append(instanceGroups, bastionGroup)
var bastionSubnets []api.ClusterSubnetSpec
for _, s := range cluster.Spec.Subnets { for _, s := range cluster.Spec.Subnets {
if s.Type == api.SubnetTypeUtility { if s.Type == api.SubnetTypeUtility {
continue continue
@ -470,9 +465,15 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
Zone: s.Zone, Zone: s.Zone,
Type: api.SubnetTypeUtility, Type: api.SubnetTypeUtility,
} }
bastionSubnets = append(bastionSubnets, subnet) utilitySubnets = append(utilitySubnets, subnet)
} }
cluster.Spec.Subnets = append(cluster.Spec.Subnets, bastionSubnets...) cluster.Spec.Subnets = append(cluster.Spec.Subnets, utilitySubnets...)
if c.Bastion {
bastionGroup := &api.InstanceGroup{}
bastionGroup.Spec.Role = api.InstanceGroupRoleBastion
bastionGroup.ObjectMeta.Name = "bastions"
instanceGroups = append(instanceGroups, bastionGroup)
} }
default: default:

View File

@ -62,6 +62,7 @@ func LoadChannel(location string) (*Channel, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid base channel location: %q", DefaultChannelBase) return nil, fmt.Errorf("invalid base channel location: %q", DefaultChannelBase)
} }
glog.V(4).Infof("resolving %q against default channel location %q", location, DefaultChannelBase)
u = base.ResolveReference(u) u = base.ResolveReference(u)
} }

View File

@ -330,10 +330,11 @@ func (c *Cluster) Validate(strict bool) error {
} }
if c.Spec.Topology.Bastion != nil { if c.Spec.Topology.Bastion != nil {
bastion := c.Spec.Topology.Bastion
if c.Spec.Topology.Masters == TopologyPublic || c.Spec.Topology.Nodes == TopologyPublic { if c.Spec.Topology.Masters == TopologyPublic || c.Spec.Topology.Nodes == TopologyPublic {
return fmt.Errorf("Bastion supports only Private Masters and Nodes") return fmt.Errorf("Bastion supports only Private Masters and Nodes")
} }
if fi.Int64Value(c.Spec.Topology.Bastion.IdleTimeout) <= int64(0) { if bastion.IdleTimeout != nil && *bastion.IdleTimeout <= 0 {
return fmt.Errorf("Bastion IdleTimeout should be greater than zero") return fmt.Errorf("Bastion IdleTimeout should be greater than zero")
} }
} }