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

Changes to enable run Single check #885

Merged
merged 12 commits into from
Oct 3, 2023
Merged

Conversation

jayasimha-raghavan-unskript
Copy link
Member

@jayasimha-raghavan-unskript jayasimha-raghavan-unskript commented Sep 28, 2023

Description

EN-5093
Please include a summary of the change, motivation and context.

  • Added support to run unskript-ctl.sh -rc -f <check_name>
  • Added save_check_names as a helper routine to enable bash completion of all available checks.

Testing

Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.

Screen.Recording.2023-09-28.at.4.31.53.PM.mov
(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -rc -f k8s_get_offline_nodes
Executing Runbook -> /unskript/data/execution/workspace/1cbe3535-1469-4abe-a676-9aab01881578.ipynb
INFO:traitlets:Executing notebook with kernel: python3


╒═══════════════════════╤══════════╤════════════════╤═════════╕
│ Checks Name           │ Result   │   Failed Count │ Error   │
╞═══════════════════════╪══════════╪════════════════╪═════════╡
│ Get K8s offline nodes │  PASS    │              0 │ N/A     │
╘═══════════════════════╧══════════╧════════════════╧═════════╛

(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -rc -f k8s_get_unbound_pvcs
Executing Runbook -> /unskript/data/execution/workspace/ecf0742a-f410-43af-8cd0-56d3a21b26f5.ipynb
INFO:traitlets:Executing notebook with kernel: python3


╒═════════════════════════════╤══════════╤════════════════╤═════════╕
│ Checks Name                 │ Result   │   Failed Count │ Error   │
╞═════════════════════════════╪══════════╪════════════════╪═════════╡
│ Get Kubernetes Unbound PVCs │  FAIL    │              5 │ N/A     │
╘═════════════════════════════╧══════════╧════════════════╧═════════╛


FAILED RESULTS

Get Kubernetes Unbound PVCs
Failed Objects:
[{'name': 'redis-data-redis-replicas-0', 'namespace': 'redis'},
 {'name': 'storage-my-prometheus-alertmanager-0', 'namespace': 'default'},
 {'name': 'rts-openvpn-pvc', 'namespace': 'sbox-yura'},
 {'name': 'redis-data-redis-replicas-2', 'namespace': 'redis'},
 {'name': 'redis-data-redis-replicas-1', 'namespace': 'redis'}]
 
(base) root@1e9dadced23e:/unskript/data/actions# 

(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -
-cc                      --credential-list        --display-failed-logs    --list-checks            -rc                      --run-runbook            --start-debug            
-cl                      -df                      -dl                      --list-runbooks          -rr                      -sa                      --stop-debug             
--create-credentials     --display-failed-checks  -lc                      -lr                      --run-checks             --show-audit-trail       
(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -
-cc                      --credential-list        --display-failed-logs    --list-checks            -rc                      --run-runbook            --start-debug            
-cl                      -df                      -dl                      --list-runbooks          -rr                      -sa                      --stop-debug             
--create-credentials     --display-failed-checks  -lc                      -lr                      --run-checks             --show-audit-trail       
(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -
-cc                      --credential-list        --display-failed-logs    --list-checks            -rc                      --run-runbook            --start-debug            
-cl                      -df                      -dl                      --list-runbooks          -rr                      -sa                      --stop-debug             
--create-credentials     --display-failed-checks  -lc                      -lr                      --run-checks             --show-audit-trail       
(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -rc 
all         connectors  -f          failed      
(base) root@1e9dadced23e:/unskript/data/actions# unskript-ctl.sh -rc -f
Display all 101 possibilities? (y or n)
aws_check_rds_non_m5_t3_instances                                  aws_get_long_running_redshift_clusters_without_reserved_nodes      k8s_get_all_evicted_pods_from_namespace
aws_filter_ebs_unattached_volumes                                  aws_get_nlbs_without_targets                                       k8s_get_cluster_health
aws_filter_ebs_volumes_with_low_iops                               aws_get_older_generation_rds_instances                             k8s_get_deployment_status
aws_filter_instances_without_termination_and_lifetime_tag          aws_get_publicly_accessible_db_instances                           k8s_get_error_pods_from_all_jobs
aws_filter_old_ebs_snapshots                                       aws_get_publicly_accessible_db_snapshots                           k8s_get_expiring_certificates
aws_filter_public_s3_buckets_by_acl                                aws_get_rds_automated_snapshots_above_retention_period             k8s_get_failed_deployments
aws_filter_unencrypted_s3_buckets                                  aws_get_reserved_instances_about_to_retired                        k8s_get_frequently_restarting_pods
aws_filter_unhealthy_instances_from_asg                            aws_get_schedule_to_retire_instances                               k8s_get_memory_utilization_of_services
aws_filter_untagged_ec2_instances                                  aws_get_stopped_instance_volumes                                   k8s_get_nodes_with_insufficient_resources
aws_filter_unused_keypairs                                         aws_get_timed_out_lambdas                                          k8s_get_offline_nodes
aws_filter_unused_log_streams                                      aws_get_ttl_under_given_hours                                      k8s_get_oomkilled_pods
aws_filter_unused_nat_gateway                                      aws_get_unhealthy_instances_from_elb                               k8s_get_pending_pods
aws_find_elbs_with_no_targets_or_instances                         aws_get_unused_route53_health_checks                               k8s_get_pods_in_crashloopbackoff_state
aws_find_idle_instances                                            aws_list_clusters_with_low_utilization                             k8s_get_pods_in_imagepullbackoff_state
aws_finding_redundant_trails                                       aws_list_expiring_access_keys                                      k8s_get_pods_in_not_running_state
aws_find_long_running_lambdas                                      aws_list_expiring_acm_certificates                                 k8s_get_pods_in_terminating_state
aws_find_low_connection_rds_instances                              aws_list_unattached_elastic_ips                                    k8s_get_pods_with_high_restart
aws_find_old_gen_emr_clusters                                      aws_list_unhealthy_instances_in_target_group                       k8s_get_service_with_no_associated_endpoints
aws_find_rds_instances_with_low_cpu_utilization                    aws_list_unused_secrets                                            k8s_get_unbound_pvcs
aws_find_redshift_clusters_with_low_cpu_utilization                aws_list_users_with_old_passwords                                  kafka_check_offline_partitions
aws_find_redshift_cluster_without_pause_resume_enabled             custom_aws_execute_sts_get_caller_id_command                       kafka_get_topics_with_lag
aws_find_s3_buckets_without_lifecycle_policies                     custom_aws_get_unhealthy_instances_from_elb                        mongodb_check_large_index_size
aws_get_alb_listeners_without_http_redirect                        custom_k8s_get_ns_command                                          mongodb_compare_disk_size_to_threshold
aws_get_ebs_volume_for_low_usage                                   elasticsearch_check_health_status                                  mongodb_get_server_status
aws_get_ebs_volumes_without_gp3_type                               elasticsearch_check_large_index_size                               postgres_check_locks
aws_get_ec2_instances_with_smaller_cpu_size                        elasticsearch_compare_cluster_disk_size_to_threshold               postgresql_check_active_connections
aws_get_ecs_instances_without_autoscaling                          elasticsearch_get_index_health                                     postgresql_check_unused_indexes
aws_get_ecs_services_without_autoscaling                           gcp_get_buckets_without_lifecycle_policies                         postgresql_get_cache_hit_ratio
aws_get_iam_users_without_password_policies                        gcp_get_unused_backend_services                                    postgresql_get_server_status
aws_get_idle_emr_clusters                                          github_get_open_pull_requests                                      postgresql_long_running_queries
aws_get_lambdas_not_using_arm_graviton2_processor                  github_list_stale_issues                                           redis_get_cluster_health
aws_get_lambdas_with_high_error_rate                               github_list_stale_pull_requests                                    ssh_get_ec2_instances_with_low_available_disk_size
aws_get_long_running_elasticcache_clusters_without_reserved_nodes  k8s_check_service_status                                           ssh_get_ec2_instances_with_low_memory_size
aws_get_long_running_rds_instances_without_reserved_instances      k8s_check_worker_cpu_utilization    

More Single Check test

(base) root@0807cc10510e:~# unskript-ctl.sh -rc --check
Display all 101 possibilities? (y or n)
aws_check_rds_non_m5_t3_instances                                  aws_get_long_running_redshift_clusters_without_reserved_nodes      k8s_get_all_evicted_pods_from_namespace
aws_filter_ebs_unattached_volumes                                  aws_get_nlbs_without_targets                                       k8s_get_cluster_health
aws_filter_ebs_volumes_with_low_iops                               aws_get_older_generation_rds_instances                             k8s_get_deployment_status
aws_filter_instances_without_termination_and_lifetime_tag          aws_get_publicly_accessible_db_instances                           k8s_get_error_pods_from_all_jobs
aws_filter_old_ebs_snapshots                                       aws_get_publicly_accessible_db_snapshots                           k8s_get_expiring_certificates
aws_filter_public_s3_buckets_by_acl                                aws_get_rds_automated_snapshots_above_retention_period             k8s_get_failed_deployments
aws_filter_unencrypted_s3_buckets                                  aws_get_reserved_instances_about_to_retired                        k8s_get_frequently_restarting_pods
aws_filter_unhealthy_instances_from_asg                            aws_get_schedule_to_retire_instances                               k8s_get_memory_utilization_of_services
aws_filter_untagged_ec2_instances                                  aws_get_stopped_instance_volumes                                   k8s_get_nodes_with_insufficient_resources
aws_filter_unused_keypairs                                         aws_get_timed_out_lambdas                                          k8s_get_offline_nodes
aws_filter_unused_log_streams                                      aws_get_ttl_under_given_hours                                      k8s_get_oomkilled_pods
aws_filter_unused_nat_gateway                                      aws_get_unhealthy_instances_from_elb                               k8s_get_pending_pods
aws_find_elbs_with_no_targets_or_instances                         aws_get_unused_route53_health_checks                               k8s_get_pods_in_crashloopbackoff_state
aws_find_idle_instances                                            aws_list_clusters_with_low_utilization                             k8s_get_pods_in_imagepullbackoff_state
aws_finding_redundant_trails                                       aws_list_expiring_access_keys                                      k8s_get_pods_in_not_running_state
aws_find_long_running_lambdas                                      aws_list_expiring_acm_certificates                                 k8s_get_pods_in_terminating_state
aws_find_low_connection_rds_instances                              aws_list_unattached_elastic_ips                                    k8s_get_pods_with_high_restart
aws_find_old_gen_emr_clusters                                      aws_list_unhealthy_instances_in_target_group                       k8s_get_service_with_no_associated_endpoints
aws_find_rds_instances_with_low_cpu_utilization                    aws_list_unused_secrets                                            k8s_get_unbound_pvcs
aws_find_redshift_clusters_with_low_cpu_utilization                aws_list_users_with_old_passwords                                  kafka_check_offline_partitions
aws_find_redshift_cluster_without_pause_resume_enabled             custom_aws_execute_sts_get_caller_id_command                       kafka_get_topics_with_lag
aws_find_s3_buckets_without_lifecycle_policies                     custom_aws_get_unhealthy_instances_from_elb                        mongodb_check_large_index_size
aws_get_alb_listeners_without_http_redirect                        custom_k8s_get_ns_command                                          mongodb_compare_disk_size_to_threshold
aws_get_ebs_volume_for_low_usage                                   elasticsearch_check_health_status                                  mongodb_get_server_status
aws_get_ebs_volumes_without_gp3_type                               elasticsearch_check_large_index_size                               postgres_check_locks
aws_get_ec2_instances_with_smaller_cpu_size                        elasticsearch_compare_cluster_disk_size_to_threshold               postgresql_check_active_connections
aws_get_ecs_instances_without_autoscaling                          elasticsearch_get_index_health                                     postgresql_check_unused_indexes
aws_get_ecs_services_without_autoscaling                           gcp_get_buckets_without_lifecycle_policies                         postgresql_get_cache_hit_ratio
aws_get_iam_users_without_attached_policies                        gcp_get_unused_backend_services                                    postgresql_get_server_status
aws_get_idle_emr_clusters                                          github_get_open_pull_requests                                      postgresql_long_running_queries
aws_get_lambdas_not_using_arm_graviton2_processor                  github_list_stale_issues                                           redis_get_cluster_health
aws_get_lambdas_with_high_error_rate                               github_list_stale_pull_requests                                    ssh_get_ec2_instances_with_low_available_disk_size
aws_get_long_running_elasticcache_clusters_without_reserved_nodes  k8s_check_service_status                                           ssh_get_ec2_instances_with_low_memory_size
aws_get_long_running_rds_instances_without_reserved_instances      k8s_check_worker_cpu_utilization                                   
(base) root@0807cc10510e:~# unskript-ctl.sh -rc --check k8s_get_unbound_pvcs
Executing Runbook -> /unskript/data/execution/workspace/310ece5f-27e8-4ff0-bd1a-0c404c3bee56.ipynb
INFO:traitlets:Executing notebook with kernel: python3


╒═════════════════════════════╤══════════╤════════════════╤═════════╕
│ Checks Name                 │ Result   │   Failed Count │ Error   │
╞═════════════════════════════╪══════════╪════════════════╪═════════╡
│ Get Kubernetes Unbound PVCs │  FAIL    │              5 │ N/A     │
╘═════════════════════════════╧══════════╧════════════════╧═════════╛


FAILED RESULTS

Get Kubernetes Unbound PVCs
Failed Objects:
[{'name': 'redis-data-redis-replicas-0', 'namespace': 'redis'},
 {'name': 'storage-my-prometheus-alertmanager-0', 'namespace': 'default'},
 {'name': 'rts-openvpn-pvc', 'namespace': 'sbox-yura'},
 {'name': 'redis-data-redis-replicas-2', 'namespace': 'redis'},
 {'name': 'redis-data-redis-replicas-1', 'namespace': 'redis'}]
 
(base) root@0807cc10510e:~# 

Checklist:

  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • Any dependent changes have been merged and published.

Documentation

Make sure that you have documented corresponding changes in this repository.

@jayasimha-raghavan-unskript jayasimha-raghavan-unskript marked this pull request as ready for review September 29, 2023 15:24
@amit-chandak-unskript amit-chandak-unskript merged commit 6b58bd1 into master Oct 3, 2023
7 checks passed
@amit-chandak-unskript amit-chandak-unskript deleted the en-5093-jayasimha branch October 3, 2023 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants