Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for gcp dataproc clusters #58

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action/termination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func (p *mockProvider) CleanupStorages(storageContainer *types.StorageContainer,
return nil
}

func (p *mockProvider) GetClusters() ([]*types.Cluster, error) {
return nil, nil
}

type terminationSuite struct {
suite.Suite
providers map[types.CloudType]func() types.CloudProvider
Expand Down
17 changes: 11 additions & 6 deletions aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -1913,17 +1913,18 @@ func newStack(stack *cloudformation.Stack, region string) *types.Stack {

// The low byte represents the state. The high byte is an opaque internal value
// and should be ignored.
// * 0 : pending
//
// * 16 : running
// - 0 : pending
//
// * 32 : shutting-down
// - 16 : running
//
// * 48 : terminated
// - 32 : shutting-down
//
// * 64 : stopping
// - 48 : terminated
//
// * 80 : stopped
// - 64 : stopping
//
// - 80 : stopped
func getInstanceState(instance *ec2.Instance) types.State {
if instance.State == nil {
return types.Unknown
Expand Down Expand Up @@ -2079,3 +2080,7 @@ func getRegionFromAvailabilityZone(az *string) string {
}
return (*az)[0 : len(*az)-1]
}

func (p awsProvider) GetClusters() ([]*types.Cluster, error) {
return nil, errors.New("NotImplemented")
}
20 changes: 13 additions & 7 deletions azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,15 @@ func getScaleSetInstanceState(view compute.VirtualMachineScaleSetVMInstanceView)
}

// Possible values:
// "PowerState/deallocated"
// "PowerState/deallocating"
// "PowerState/running"
// "PowerState/starting"
// "PowerState/stopped"
// "PowerState/stopping"
// "PowerState/unknown"
//
// "PowerState/deallocated"
// "PowerState/deallocating"
// "PowerState/running"
// "PowerState/starting"
// "PowerState/stopped"
// "PowerState/stopping"
// "PowerState/unknown"
//
// The assumption is that the status without time is the currently active status
func convertViewStatusToState(actualStatus compute.InstanceViewStatus) types.State {
switch *actualStatus.Code {
Expand Down Expand Up @@ -735,3 +737,7 @@ func newStack(rg resources.Group) *types.Stack {
Region: *rg.Location,
}
}

func (p azureProvider) GetClusters() ([]*types.Cluster, error) {
return nil, errors.New("NotImplemented")
}
6 changes: 5 additions & 1 deletion filter/longrunning.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func init() {
}

func (f longRunning) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[LONGRUNNING] Filtering instances (%d): [%s]", len(items), items)
log.Debugf("[LONGRUNNING] Filtering items (%d): [%s]", len(items), items)
now := time.Now()
return filter("LONGRUNNING", items, types.ExclusiveFilter, func(item types.CloudItem) bool {
switch item.GetItem().(type) {
Expand All @@ -61,6 +61,10 @@ func (f longRunning) Execute(items []types.CloudItem) []types.CloudItem {
case types.Alert:
if item.GetItem().(types.Alert).State != types.Unused {
log.Debugf("[LONGRUNNING] Filter alert, because it's in used state: %s", item.GetName())
}
case types.Cluster:
if item.GetItem().(types.Cluster).State != types.Running {
log.Debugf("[LONGRUNNING] Filter instance, because it's not in RUNNING state: %s", item.GetName())
return false
}
default:
Expand Down
2 changes: 1 addition & 1 deletion filter/oldaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {
}

func (f oldAccess) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[OLDACCESS] Filtering accesses (%d): [%s]", len(items), items)
log.Debugf("[OLDACCESS] Filtering items (%d): [%s]", len(items), items)
return filter("OLDACCESS", items, types.ExclusiveFilter, func(item types.CloudItem) bool {
switch item.GetItem().(type) {
case types.Access:
Expand Down
2 changes: 1 addition & 1 deletion filter/ownerless.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ownerless struct {
}

func (o ownerless) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[OWNERLESS] Filtering instances without tag %s (%d): [%s]", ctx.OwnerLabel, len(items), items)
log.Debugf("[OWNERLESS] Filtering items without tag %s (%d): [%s]", ctx.OwnerLabel, len(items), items)
return filter("OWNERLESS", items, types.ExclusiveFilter, func(item types.CloudItem) bool {
match := len(item.GetOwner()) == 0 || item.GetOwner() == "???"
log.Infof("[OWNERLESS] %T: %s match: %v", item, item.GetName(), match)
Expand Down
7 changes: 6 additions & 1 deletion filter/running.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type running struct {
}

func (f running) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[RUNNING] Filtering instances (%d): [%s]", len(items), items)
log.Debugf("[RUNNING] Filtering items (%d): [%s]", len(items), items)
return filter("RUNNING", items, types.ExclusiveFilter, func(item types.CloudItem) bool {
switch item.GetItem().(type) {
case types.Instance:
Expand All @@ -37,6 +37,11 @@ func (f running) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[RUNNING] Filter disk, because it's in used state: %s", item.GetName())
return false
}
case types.Cluster:
if item.GetItem().(types.Cluster).State != types.Running {
log.Debugf("[RUNNING] Filter cluster, because it's not in RUNNING state: %s", item.GetName())
return false
}
default:
log.Fatalf("[RUNNING] Filter does not apply for cloud item: %s", item.GetName())
}
Expand Down
5 changes: 5 additions & 0 deletions filter/stopped.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func (f stopped) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[STOPPED] Filter instance, because it's not in STOPPED state: %s", item.GetName())
return false
}
case types.Cluster:
if item.GetItem().(types.Cluster).State != types.Stopped {
log.Debugf("[RUNNING] Filter cluster, because it's not in STOPPED state: %s", item.GetName())
return false
}
default:
log.Fatalf("[STOPPED] Filter does not apply for cloud item: %s", item.GetName())
}
Expand Down
Loading