This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
environment variable for events namespace and bug fix #64
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import logging | ||
import re | ||
import sys | ||
import os | ||
import time | ||
import base64 | ||
from datetime import datetime | ||
|
@@ -169,6 +170,7 @@ def _describe_launch_configuration(): | |
|
||
def log_k8s_event(self, asg_name, price="", useSpot=False): | ||
msg_str = '{"apiVersion":"v1alpha1","spotPrice":"' + price + '", "useSpot": ' + str(useSpot).lower() + '}' | ||
mm_namespace = os.getenv('MINION_MANAGER_NAMESPACE', 'default') | ||
if not self.incluster: | ||
logger.info(msg_str) | ||
return | ||
|
@@ -184,6 +186,7 @@ def log_k8s_event(self, asg_name, price="", useSpot=False): | |
involved_object=client.V1ObjectReference( | ||
kind="SpotPriceInfo", | ||
name=asg_name, | ||
namespace=mm_namespace, | ||
), | ||
last_timestamp=event_timestamp, | ||
metadata=client.V1ObjectMeta( | ||
|
@@ -197,7 +200,7 @@ def log_k8s_event(self, asg_name, price="", useSpot=False): | |
type="Normal", | ||
) | ||
|
||
v1.create_namespaced_event(namespace="default", body=new_event) | ||
v1.create_namespaced_event(namespace=mm_namespace, body=new_event) | ||
logger.info("Spot price info event logged") | ||
except Exception as e: | ||
logger.info("Failed to log event: " + str(e)) | ||
|
@@ -212,12 +215,12 @@ def get_new_bid_info(self, asg_meta): | |
def update_needed(self, asg_meta): | ||
""" Checks if an ASG needs to be updated. """ | ||
try: | ||
current_price = "" | ||
asg_tag = asg_meta.get_mm_tag() | ||
bid_info = asg_meta.get_bid_info() | ||
if not bid_info.get("price"): | ||
if self.get_new_bid_info(asg_meta).get("price"): | ||
current_price = self.get_new_bid_info(asg_meta).get("price") | ||
current_price = self.get_new_bid_info(asg_meta).get("price") or "" | ||
else: | ||
current_price = bid_info.get("price") | ||
|
||
if asg_tag == "no-spot": | ||
if bid_info["type"] == "spot": | ||
|
@@ -371,6 +374,10 @@ def update_scaling_group(self, asg_meta, new_bid_info): | |
Updates the AWS AutoScalingGroup. Makes the next_bid_info as the new | ||
bid_info. | ||
""" | ||
if self._events_only: | ||
logger.info("Minion-manager configured for only generating events. No changes to launch config will be made.") | ||
return | ||
|
||
logger.info("Updating ASG: %s, Bid: %s", asg_meta.get_name(), | ||
new_bid_info) | ||
launch_config = asg_meta.get_lc_info() | ||
|
@@ -392,10 +399,6 @@ def update_scaling_group(self, asg_meta, new_bid_info): | |
logger.info("ASG(%s): New launch-config name: %s", | ||
asg_meta.get_name(), new_lc_name) | ||
|
||
if self._events_only: | ||
logger.info("Minion-manager configured for only generating events. No changes to launch config will be made.") | ||
return | ||
|
||
if spot_price is None: | ||
self.create_lc_on_demand(new_lc_name, launch_config) | ||
else: | ||
|
@@ -685,7 +688,7 @@ def minion_manager_work(self): | |
self.update_scaling_group(asg_meta, new_bid_info) | ||
continue | ||
|
||
# Update ASGs iff new bid is different from current bid. | ||
# Update ASGs if new bid is different from current bid. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, I reverted the change |
||
if self.are_bids_equal(asg_meta.bid_info, new_bid_info): | ||
logger.info("No change in bid info for %s", | ||
asg_meta.get_name()) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!