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

[FC-20956] batou_ext.fcio: Add components that set an RG in maintenance for the time of the deployment #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Jan 17, 2025

Given a provision section in the secret config like

[provision]
project = test
api_key = <redacted>

an environment config like this

[host:test42]
components =
  demo
  directoryxmlrpc
  maintenancestart
  maintenanceend

and a component like this

class Demo(Component):
  def configure(self):
    self.provide("needs-maintenance", self)
    self += File("foobar")

then all subcomponents configured by `Demo will be deployed while the RG is in maintenance.

@Ma27 Ma27 requested review from zagy, frlan and PhilTaken January 17, 2025 10:19
Copy link
Member Author

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

I guess a bit more docs would be nice. But first we should discuss the things below.

)


class MaintenanceEnd(batou.component.Component):
Copy link
Member Author

Choose a reason for hiding this comment

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

This has the downside that setting it up is a little verbose: you have to add three additional components.
We may be able to cut it down to two by removing the DirectoryXMLRPC and setting up the client in each component.

Another idea I had was to use a decorator which injects Start end End into a component (and calls the component's configure in between), but this has the downside that the maintenance is left when the component itself is updated. I.e.

@needs_maintenance
class Foobar(Component):
  def configure(self):
    # The RG is in maintenance when X & Y are deployed
    self += X()
    self += Y()
  def update(self):
    # when this is reached, we're not in maintenance anymore.

Thoughts?

def change_maintenance_state(
xmlrpc, host_name, desired_state, predict_only=False
):
rg_name = host_name[:-2]
Copy link
Member Author

Choose a reason for hiding this comment

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

I effectively assume here that each host in a deployment is in the same RG.
Do we even have cases where this is not True?

self.xmlrpc = self.require_one("directory-xmlrpc")

def verify(self):
raise batou.UpdateNeeded()
Copy link
Member Author

Choose a reason for hiding this comment

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

I still have bad feelings about this: every deployment with no other change will set the RG to maintenance for a short time with this.

Unfortunately I don't have a better idea after reading through batou's sources: when MaintenanceStart is deployed, we don't know yet if anything else will change later that needs maintenance. We could of course run all of the verify() methods of these components in here, but this doesn't take their sub-components into account.

Ideas? Or is this good enough?

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.

1 participant