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

Various charm fixes. #195

Merged
merged 2 commits into from Oct 6, 2023
Merged

Conversation

alesstimec
Copy link
Contributor

Description

The what and why - include a summary of the change, describe what it does, and include relevant motivation and context.

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests
  • Independent change*

Test instructions

Notes for code reviewers

@mina1460
Copy link
Contributor

mina1460 commented Oct 4, 2023

the linter configuration is not set to check new changes only, it will fail because it is trying to lint the entire repo. I did the change required to lint new changes only in livepatch-client.

I can do it here if you would like

}
else:
logging.info("db_uri not stored")
logging.info("missing postgres relation")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should enter a blocked state here and return

Copy link
Contributor

Choose a reason for hiding this comment

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

Though granted lower down if the DB connection string is removed we call this function and if we were to return early here we wouldn't stop the Candid snap so it's a bit tricky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this check as it is not needed.. code calls self._check_config(event) which will return False if postgres connection string is missing and go into Waiting status

logging.info("setting config values {}".format(config_values))
relation = self.model.get_relation("candid")
if relation:
peers = []
Copy link
Contributor

Choose a reason for hiding this comment

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

The scoping of this variable is weird. It's only declared inside this if but we don't assign it to something outside this scope.

Copy link
Contributor

Choose a reason for hiding this comment

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

I.e. it doesn't look like it's actually being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i append to it on L161 and use it on L163?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah don't know how I missed that. Looks good.

logging.info("database uri {}".format(uri))
if not event.master or not event.master.uri:
logging.debug("removing database connection string")
del self._state.db_uri
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe in this case calling the stop hook and returning might be good?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this hook calls _update_config_and_restart which will now stop the service should any config value be missing

@mina1460
Copy link
Contributor

mina1460 commented Oct 4, 2023

rebased to run the actions again

import json


def requires_state_setter(func):
Copy link
Member

Choose a reason for hiding this comment

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

Nice replacement for repeated state.ready checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. but we have to be careful using it.. it is only useful when you're setting data in application's data bucket, which requires the unit to be leader.. if you're setting data in unit's data bucked, you don't need this check

@alesstimec alesstimec merged commit 9fda584 into canonical:master Oct 6, 2023
2 checks passed
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.

None yet

6 participants