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

fix(reconciler): Use new subcommand of ic-admin for revising the GuestOS versions #1264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 77 additions & 9 deletions release-controller/dre_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,23 @@ def __init__(self, auth: typing.Optional[Auth] = None):
]
else:
self.auth = []
self.cli = resolve_binary("dre")
self.cli = resolve_binary("old-dre")

def _run(self, *args: str) -> str:
def _run(self, *args: str, **subprocess_kwargs: typing.Any) -> str:
"""Run the dre CLI."""
return subprocess.check_output(
[self.cli, *(["--yes"] if "propose" in args else []), *self.auth, *args],
env=self.env,
text=True,
return typing.cast(
str,
subprocess.check_output(
[
self.cli,
*(["--yes"] if "propose" in args else []),
*self.auth,
*args,
],
env=self.env,
text=True,
**subprocess_kwargs,
),
)

def get_blessed_versions(self) -> list[str]:
Expand Down Expand Up @@ -115,7 +124,7 @@ def get_election_proposals_by_version(self) -> dict[str, ElectionProposal]:
d[replica_version] = proposal
return d

def place_proposal(
def propose_to_revise_elected_guestos_versions(
self,
changelog: str,
version: str,
Expand All @@ -124,16 +133,74 @@ def place_proposal(
package_checksum: str,
package_urls: list[str],
dry_run: bool = False,
) -> int:
try:
self._run(
"propose",
"revise-elected-guestos-versions",
"--help",
stderr=subprocess.STDOUT,
)
subcommand_name: (
typing.Literal["update-elected-replica-versions"]
| typing.Literal["revise-elected-guestos-versions"]
) = "revise-elected-guestos-versions"
# New style of proposal naming is now active in ic-admin.
except subprocess.CalledProcessError:
# Old style of proposal naming is still active in ic-admin.
try:
self._run(
"propose",
"revise-elected-guestos-versions",
"--help",
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError:
raise RuntimeError(
"No variant of the dre propose command "
"can be used to revise elected GuestOS versions"
)
subcommand_name = "update-elected-replica-versions"

return self._propose_to_update_elected_replica_versions(
subcommand_name,
changelog,
version,
forum_post_url,
unelect_versions,
package_checksum,
package_urls,
dry_run,
)

def _propose_to_update_elected_replica_versions(
self,
subcommand_name: typing.Literal["update-elected-replica-versions"]
| typing.Literal["revise-elected-guestos-versions"],
changelog: str,
version: str,
forum_post_url: str,
unelect_versions: list[str],
package_checksum: str,
package_urls: list[str],
dry_run: bool = False,
) -> int:
unelect_versions_args = []
if subcommand_name == "revise-elected-guestos-versions":
proposal_url_args: list[str] = ["--proposal-url", forum_post_url]
summary = changelog
else:
proposal_url_args = []
summary = changelog + f"\n\nLink to the forum post: {forum_post_url}"

if len(unelect_versions) > 0:
unelect_versions_args.append("--replica-versions-to-unelect")
unelect_versions_args.extend(unelect_versions)
summary = changelog + f"\n\nLink to the forum post: {forum_post_url}"

self._logger.info("Submitting proposal for version %s", version)
text = self._run(
"propose",
"update-elected-replica-versions",
subcommand_name,
"--proposal-title",
f"Elect new IC/Replica revision (commit {version[:7]})",
"--summary",
Expand All @@ -146,6 +213,7 @@ def place_proposal(
"--replica-version-to-elect",
version,
*unelect_versions_args,
*proposal_url_args,
)
if not dry_run:
try:
Expand Down
22 changes: 20 additions & 2 deletions release-controller/dryrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __init__(self) -> None:
super().__init__()
self._logger = LOGGER.getChild(self.__class__.__name__)

def place_proposal(
def propose_to_revise_elected_guestos_versions(
self,
changelog: str,
version: str,
Expand All @@ -239,7 +239,7 @@ def place_proposal(
package_urls: list[str],
dry_run: bool = False,
) -> int:
super().place_proposal(
super().propose_to_revise_elected_guestos_versions(
changelog,
version,
forum_post_url,
Expand All @@ -260,3 +260,21 @@ def announce_release(
self, webhook: str, version_name: str, google_doc_url: str, tag_all_teams: bool
) -> None:
self._logger.warning("Simulating announcement of %s in slack", version_name)


def oneoff_dre_place_proposal() -> None:
changelog = "Fake changelog"
dre = DRECli()
dre.propose_to_revise_elected_guestos_versions(
changelog=changelog,
version="0" * 40,
forum_post_url="https://forum.dfinity.org/t/proposal-to-elect-new-release-rc-2024-03-27-23-01/29042/7",
unelect_versions=[],
package_checksum="0" * 40,
package_urls=["https://doesntmatter.com/"],
)


if __name__ == "__main__":
# FIXME make formatter not output ANSI when stderr is not console
oneoff_dre_place_proposal()
18 changes: 10 additions & 8 deletions release-controller/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,15 @@ def reconcile(self) -> None:
urls = version_package_urls(release_commit)

try:
proposal_id = self.dre.place_proposal(
changelog=changelog,
version=release_commit,
forum_post_url=rc_forum_topic.post_url(release_commit),
unelect_versions=unelect_versions,
package_checksum=checksum,
package_urls=urls,
proposal_id = (
self.dre.propose_to_revise_elected_guestos_versions(
changelog=changelog,
version=release_commit,
forum_post_url=rc_forum_topic.post_url(release_commit),
unelect_versions=unelect_versions,
package_checksum=checksum,
package_urls=urls,
)
)
success = prop.record_submission(proposal_id)
revlogger.info("%s", success)
Expand Down Expand Up @@ -601,7 +603,7 @@ def oneoff() -> None:
assert changelog

dre = dre_cli.DRECli()
dre.place_proposal(
dre.propose_to_revise_elected_guestos_versions(
changelog=changelog,
version=version,
forum_post_url="https://forum.dfinity.org/t/proposal-to-elect-new-release-rc-2024-03-27-23-01/29042/7",
Expand Down