Skip to content

Commit

Permalink
fix(alibaba): readd missing nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Jason-ZW <zhenyang@rancher.com>
  • Loading branch information
rancher-sy-bot committed Sep 8, 2020
1 parent 8481c35 commit 4c16456
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

const (
MasterInstancePrefix = "autok3s.%s.m" // autok3s.<cluster.region>.m
WorkerInstancePrefix = "autok3s.%s.w" // autok3s.<cluster.region>.w
WildcardInstanceName = "autok3s.%s.*" // autok3s.<cluster.region>.*
MasterInstancePrefix = "autok3s.%s.m." // autok3s.<cluster.region>.m
WorkerInstancePrefix = "autok3s.%s.w." // autok3s.<cluster.region>.w
WildcardInstanceName = "autok3s.%s.*" // autok3s.<cluster.region>.*
BindPrefix = "autok3s.providers.%s.%s"
ConfigFile = "config.yaml"
StateFile = ".state"
Expand Down
28 changes: 25 additions & 3 deletions pkg/providers/alibaba/alibaba.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ func (p *Alibaba) Rollback() error {
ids := make([]string, 0)

p.m.Range(func(key, value interface{}) bool {
ids = append(ids, key.(string))
v := value.(types.Node)
if v.RollBack {
ids = append(ids, key.(string))
}
return true
})

Expand Down Expand Up @@ -276,9 +279,9 @@ func (p *Alibaba) runInstances(num int, master bool) error {
}
for _, id := range response.InstanceIdSets.InstanceIdSet {
if master {
p.m.Store(id, types.Node{Master: true, InstanceID: id, InstanceStatus: alibaba.StatusPending})
p.m.Store(id, types.Node{Master: true, RollBack: true, InstanceID: id, InstanceStatus: alibaba.StatusPending})
} else {
p.m.Store(id, types.Node{Master: false, InstanceID: id, InstanceStatus: alibaba.StatusPending})
p.m.Store(id, types.Node{Master: false, RollBack: true, InstanceID: id, InstanceStatus: alibaba.StatusPending})
}
}

Expand Down Expand Up @@ -371,6 +374,25 @@ func (p *Alibaba) assembleInstanceStatus(ssh *types.SSH) (*types.Cluster, error)
v.InternalIPAddress = status.VpcAttributes.PrivateIpAddress.IpAddress
v.PublicIPAddress = status.PublicIpAddress.IpAddress
p.m.Store(status.InstanceId, v)
continue
}

if strings.Contains(status.InstanceName, ".m.") {
p.m.Store(status.InstanceId, types.Node{
Master: true,
RollBack: false,
InstanceID: status.InstanceId,
InstanceStatus: alibaba.StatusRunning,
InternalIPAddress: status.VpcAttributes.PrivateIpAddress.IpAddress,
PublicIPAddress: status.PublicIpAddress.IpAddress})
} else {
p.m.Store(status.InstanceId, types.Node{
Master: false,
RollBack: false,
InstanceID: status.InstanceId,
InstanceStatus: alibaba.StatusRunning,
InternalIPAddress: status.VpcAttributes.PrivateIpAddress.IpAddress,
PublicIPAddress: status.PublicIpAddress.IpAddress})
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/types/autok3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Node struct {
InstanceStatus string `json:"instance-status,omitempty" yaml:"instance-status,omitempty"`
PublicIPAddress []string `json:"public-ip-address,omitempty" yaml:"public-ip-address,omitempty"`
InternalIPAddress []string `json:"internal-ip-address,omitempty" yaml:"internal-ip-address,omitempty"`
RollBack bool `json:"-" yaml:"-"`
}

type SSH struct {
Expand Down

0 comments on commit 4c16456

Please # to comment.