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 filtration feature in the bulk API #1391

Merged
merged 8 commits into from
Dec 17, 2024
Merged

Conversation

khansaad
Copy link
Contributor

@khansaad khansaad commented Nov 25, 2024

Description

This PR adds the filtration feature in the bulk API using which user can hit bulk API with filtered resources like namespaces, containers and workloads instead of always fetching everything.

Fixes # (issue)

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Breaking change (What changes might users need to make in their application due to this PR?)
  • Requires DB changes

How has this been tested?

By manually hitting bulk API with multiple combinations of include and exclude filters

Please describe the tests that were run to verify your changes and steps to reproduce. Please specify any test configuration required.

  • New Test X
  • Functional testsuite

Test Configuration

  • Kubernetes clusters tested on: Openshift

Checklist 🎯

  • Followed coding guidelines
  • Comments added
  • Dependent changes merged
  • Documentation updated
  • Tests added or updated

Additional information

Include any additional information such as links, test results, screenshots here

@khansaad khansaad added the enhancement New feature or request label Nov 25, 2024
@khansaad khansaad added this to the Kruize 0.3 Release milestone Nov 25, 2024
@khansaad khansaad self-assigned this Nov 25, 2024
@dinogun
Copy link
Contributor

dinogun commented Dec 5, 2024

@khansaad This needs a Documentation update to mention the new filters being added. Also please add a few example filters in the kruize-demos repo (Eg Include only openshift-* namespaces or exclude them etc) and test them and post the results here, thanks

@khansaad
Copy link
Contributor Author

khansaad commented Dec 13, 2024

bulk-filter-demo-results.zip

Added the test results

@khansaad This needs a Documentation update to mention the new filters being added. Also please add a few example filters in the kruize-demos repo (Eg Include only openshift-* namespaces or exclude them etc) and test them and post the results here, thanks

@dinogun
Copy link
Contributor

dinogun commented Dec 13, 2024

@khansaad Please fix the conflicts

@khansaad
Copy link
Contributor Author

Done

Comment on lines 31 to 43
"namespace": ["cadvisor", "openshift-tuning", "openshift-monitoring", "thanos-bench"],
"workload": ["osd-rebalance-infra-nodes-28887030", "blackbox-exporter", "thanos-query"],
"containers": ["tfb-0", "alertmanager"],
"labels": {
"org_id": "ABCOrga",
"source_id": "ZZZ",
"cluster_id": "ABG"
}
},
"include": {
"namespace": [],
"workload": [],
"containers": [],
"namespace": ["cadvisor", "openshift-tuning", "openshift-monitoring", "thanos-bench"],
"workload": ["osd-rebalance-infra-nodes-28887030", "blackbox-exporter", "thanos-query"],
"containers": ["tfb-0", "alertmanager"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad example, the same things are present in both the include and exclude criteria. Also are not supporting wildcard chars here?

What we need to support is something like this

"exclude": {
   "namespace": ["openshift-*"]
},
"include": {
   "namespace": ["openshift-tuning"]
}

This should exclude all "openshift-" namespaces except "openshift-tuning"

@dinogun
Copy link
Contributor

dinogun commented Dec 13, 2024

With this bulk_input.json

{
  "filter": {
    "exclude": {
      "namespace": ["openshift-.*"]
    }
  },
  "datasource": "prometheus-1"
}

I see that bulk API thinks there are 0 experiments

$ ./bulk_service_demo.sh -c openshift -i quay.io/dinogun210/autotune_operator:0.2-pr1391

#######################################
# Kruize Demo Setup on openshift 
#######################################

🔄 Pulling required repositories... ✅ Done!
🔄 Installing kruize! Please wait..............✅ Installation of kruize complete!
🔄 Installing metric profile...✅ Installation of metric profile complete!
🔄 Invoking bulk service...✅ Invoked job_id 32b02bb5-cbed-447d-a767-704ff073da5a
🔔 Bulk job experiment details are currently being updated in ./kruize-bulk-demo.log.
🔄 Processing 0 experiments. Please wait....✅ Complete!
🔄 Fetching the experiments...✅ Complete!
🔄 List the recommendations for 1 experiments...✅ Complete!
📌 List of all experiments available in experiment_list.txt
📌 Recommendations for a single container in cluster can be found in recommendations_data.json.
📌 Job status is available in job_status.json

@khansaad
Copy link
Contributor Author

With this bulk_input.json

{
  "filter": {
    "exclude": {
      "namespace": ["openshift-.*"]
    }
  },
  "datasource": "prometheus-1"
}

I see that bulk API thinks there are 0 experiments

$ ./bulk_service_demo.sh -c openshift -i quay.io/dinogun210/autotune_operator:0.2-pr1391

#######################################
# Kruize Demo Setup on openshift 
#######################################

🔄 Pulling required repositories... ✅ Done!
🔄 Installing kruize! Please wait..............✅ Installation of kruize complete!
🔄 Installing metric profile...✅ Installation of metric profile complete!
🔄 Invoking bulk service...✅ Invoked job_id 32b02bb5-cbed-447d-a767-704ff073da5a
🔔 Bulk job experiment details are currently being updated in ./kruize-bulk-demo.log.
🔄 Processing 0 experiments. Please wait....✅ Complete!
🔄 Fetching the experiments...✅ Complete!
🔄 List the recommendations for 1 experiments...✅ Complete!
📌 List of all experiments available in experiment_list.txt
📌 Recommendations for a single container in cluster can be found in recommendations_data.json.
📌 Job status is available in job_status.json

Fixed the issue with experiments creation now but the demo is failing at listRecommendations step which is expected because of the recent DB changes. As @msvinaykumar mentioned, this should work after #1420 and #1421 merge

@khansaad
Copy link
Contributor Author

`saakhan:bulk_demo$ ./bulk_service_demo.sh -c openshift -i quay.io/khansaad/autotune_operator:bulk-filter

#######################################

Kruize Demo Setup on openshift

#######################################

🔄 Pulling required repositories... ✅ Done!
🔄 Installing kruize! Please wait....................✅ Installation of kruize complete!
Running bulk_demo.py...
bulk_demo.py -c openshift
Error from server (AlreadyExists): routes.route.openshift.io "kruize" already exists
Warning: apps.openshift.io/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+
IP = kruize-openshift-tuning.apps.kruize2.lab.psi.pnq2.redhat.com

KRUIZE URL = http://kruize-openshift-tuning.apps.kruize2.lab.psi.pnq2.redhat.com

#######################################
Creating metric profile
#######################################

URL = http://kruize-openshift-tuning.apps.kruize2.lab.psi.pnq2.redhat.com/createMetricProfile
Response status code = 201
{"message":"Metric Profile : resource-optimization-local-monitoring created successfully. View Metric Profiles at /listMetricProfiles","httpcode":201,"documentationLink":"","status":"SUCCESS"}

#######################################
Invoking bulk service
#######################################

URL = http://kruize-openshift-tuning.apps.kruize2.lab.psi.pnq2.redhat.com/bulk
Response - {'job_id': '730e3f0b-2ed6-4dfe-a962-1da96273fc31'}

#######################################
Querying job status in a loop
#######################################

Experiments: processed / Total - 0 / 0
Experiments: processed / Total - 0 / 8
Experiments: processed / Total - 3 / 8
Experiments: processed / Total - 6 / 8
Experiments: processed / Total - 8 / 8

#######################################
Bulk Job Completed! Fetching the processed experiments and listing recommendations
#######################################`

@khansaad khansaad requested a review from dinogun December 16, 2024 08:59
@chandrams
Copy link
Contributor

@msvinaykumar - Can you please review this PR

@chandrams
Copy link
Contributor

@khansaad - Tested with the below input json with quay.io/khansaad/autotune_operator:bulk-filter-with-cft, but it shows 0 processed experiments.

{
  "filter": {
    "exclude": {
      "namespace": ["openshift-.*"],
      "workload": [],
      "containers": [],
      "labels": {}
    },
    "include": {
      "namespace": ["openshift-tuning"],
      "workload": [],
      "containers": [],
      "labels": {}
    }
  },

  "time_range": {
        "start": null,
        "end": null
  }

Job status

{
    "status": "COMPLETED",
    "total_experiments": 0,
    "processed_experiments": 0,
    "notifications": {
        "200": {
            "type": "INFO",
            "message": "Nothing to do.",
            "code": 400
        }
    },
    "experiments": {},
    "webhook": null,
    "job_id": "599b70bb-a1a6-4814-96a0-7bfd5fb80e81",
    "job_start_time": "2024-12-17T11:48:52.071Z",
    "job_end_time": "2024-12-17T11:48:52.115Z"
}

Copy link
Contributor

@dinogun dinogun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dinogun dinogun merged commit 00e0ebd into kruize:mvp_demo Dec 17, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants