Documentation
¶
Overview ¶
Package aws provides a cluster-destroyer for AWS clusters.
Index ¶
- func FindTaggedResourcesToDelete(ctx context.Context, logger logrus.FieldLogger, ...) (sets.Set[string], []*resourcegroupstaggingapi.ResourceGroupsTaggingAPI, error)
- func HandleErrorCode(err error) string
- func New(logger logrus.FieldLogger, metadata *types.ClusterMetadata) (providers.Destroyer, error)
- type ClusterUninstaller
- func (o *ClusterUninstaller) DeleteEC2Instances(ctx context.Context, awsSession *session.Session, toDelete sets.Set[string], ...) error
- func (o *ClusterUninstaller) DeleteResources(ctx context.Context, awsSession *session.Session, resources []string, ...) (sets.Set[string], error)
- func (o *ClusterUninstaller) Run() (*types.ClusterQuota, error)
- func (o *ClusterUninstaller) RunWithContext(ctx context.Context) ([]string, error)
- func (o *ClusterUninstaller) ValidateOwnedSubnets(ctx context.Context) error
- type ErrorTracker
- type Filter
- type IamRoleSearch
- type IamUserSearch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindTaggedResourcesToDelete ¶
func FindTaggedResourcesToDelete( ctx context.Context, logger logrus.FieldLogger, tagClients []*resourcegroupstaggingapi.ResourceGroupsTaggingAPI, filters []Filter, iamRoleSearch *IamRoleSearch, iamUserSearch *IamUserSearch, deleted sets.Set[string], ) (sets.Set[string], []*resourcegroupstaggingapi.ResourceGroupsTaggingAPI, error)
FindTaggedResourcesToDelete returns the tagged resources that should be deleted.
tagClients - clients of the tagging API to use to search for resources. deleted - the resources that have already been deleted. Any resources specified in this set will be ignored.
func HandleErrorCode ¶
HandleErrorCode takes the error and extracts the error code if it was successfully cast as an API Error.
func New ¶
func New(logger logrus.FieldLogger, metadata *types.ClusterMetadata) (providers.Destroyer, error)
New returns an AWS destroyer from ClusterMetadata.
Types ¶
type ClusterUninstaller ¶
type ClusterUninstaller struct {
// Filters is a slice of filters for matching resources. A
// resources matches the whole slice if it matches any of the
// entries. For example:
//
// filter := []map[string]string{
// {
// "a": "b",
// "c": "d:,
// },
// {
// "d": "e",
// },
// }
//
// will match resources with (a:b and c:d) or d:e.
Filters []Filter // filter(s) we will be searching for
Logger logrus.FieldLogger
Region string
ClusterID string
ClusterDomain string
HostedZoneRole string
// Session is the AWS session to be used for deletion. If nil, a
// new session will be created based on the usual credential
// configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, etc.).
Session *session.Session
EC2Client *ec2v2.Client
}
ClusterUninstaller holds the various options for the cluster we want to delete
func (*ClusterUninstaller) DeleteEC2Instances ¶
func (o *ClusterUninstaller) DeleteEC2Instances(ctx context.Context, awsSession *session.Session, toDelete sets.Set[string], deleted sets.Set[string], tracker *ErrorTracker) error
DeleteEC2Instances terminates all EC2 instances found.
func (*ClusterUninstaller) DeleteResources ¶
func (o *ClusterUninstaller) DeleteResources(ctx context.Context, awsSession *session.Session, resources []string, tracker *ErrorTracker) (sets.Set[string], error)
DeleteResources deletes the specified resources.
resources - the resources to be deleted.
The first return is the ARNs of the resources that were successfully deleted.
func (*ClusterUninstaller) Run ¶
func (o *ClusterUninstaller) Run() (*types.ClusterQuota, error)
Run is the entrypoint to start the uninstall process
func (*ClusterUninstaller) RunWithContext ¶
func (o *ClusterUninstaller) RunWithContext(ctx context.Context) ([]string, error)
RunWithContext runs the uninstall process with a context. The first return is the list of ARNs for resources that could not be destroyed.
func (*ClusterUninstaller) ValidateOwnedSubnets ¶
func (o *ClusterUninstaller) ValidateOwnedSubnets(ctx context.Context) error
ValidateOwnedSubnets validates whether the subnets owned by the cluster are safe to destroy. That is, the subnets are not currently in use (shared) by other clusters. This scenario is a misconfiguration and should not happen, but in practice it did: https://issues.redhat.com//browse/OCPBUGS-60071 Thus, we add a preflight check to abort the uninstall process in this case to avoid disruptions to other clusters.
type ErrorTracker ¶
type ErrorTracker struct {
// contains filtered or unexported fields
}
ErrorTracker holds a history of errors.
type Filter ¶
Filter holds the key/value pairs for the tags we will be matching against.
A resource matches the filter if all of the key/value pairs are in its tags.
type IamRoleSearch ¶
type IamRoleSearch struct {
Client *iam.IAM
Filters []Filter
Logger logrus.FieldLogger
Unmatched map[string]struct{}
}
IamRoleSearch holds data to search for IAM roles.
type IamUserSearch ¶
type IamUserSearch struct {
// contains filtered or unexported fields
}
IamUserSearch holds data to search for IAM users.