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

Added check for config changes #33

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion reactive/kubernetes_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def shutdown():
def build_kubeconfig(server):
'''Gather the relevant data for Kubernetes configuration objects and create
a config object with that information.'''
hookenv.status_set('maintenance', 'Writing kubeconfig file.')

ca_exists = ca_crt_path.exists()
client_pass = get_password('basic_auth.csv', 'admin')
# Do we have everything we need?
Expand All @@ -1458,6 +1458,13 @@ def build_kubeconfig(server):
kubeconfig_path = os.path.join(os.sep, 'home', 'ubuntu', 'config')
# Create the kubeconfig on this system so users can access the cluster.

with open(kubeclientconfig_path, 'r') as conf:
Copy link
Member

Choose a reason for hiding this comment

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

You meant kubeconfig_path vs kubeclientconfig_path here, right?

Also, I think on initial deployment, /home/ubuntu/config won't exist yet. That'll lead to a FileNotFoundError on this open. Consider a try/pass or check with something like isfile() to workaround that.

if not data_changed('kube-config-build', conf.read()):
hookenv.log('Skipping config write. No changes.', 'DEBUG')
return

hookenv.status_set('maintenance', 'Writing kubeconfig file.')

if ks:
create_kubeconfig(kubeconfig_path, server, ca_crt_path,
Copy link
Member

Choose a reason for hiding this comment

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

We call create_kubeconfig differently based on ks. If our ks changes after the kubeconfig file is written, we'll return in the not data_changed handler before we get a chance to write the new kubeconfig with keystone changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow good catch. OK will work on that.

user='admin', password=client_pass,
Expand Down