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

Noninteractive frontend for apt-get #24

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

cderici
Copy link

@cderici cderici commented Jun 5, 2024

DEBIAN_FRONTEND=noninteractive is used for disabling all interactions
on apt-get install.

https://bugs.launchpad.net/juju/+bug/2011637 reports that their
upgrade was stuck in a grub prompt during an apt-get install. This
change precedes apt-get install command with the
DEBIAN_FRONTEND=noninteractive env variable to ensure no prompts or
interactions happen during apt-get.

According to the man 7 debconf, this env variable "makes the default
answers be used for all questions".

This also fixes some linter issues.

QA steps

For this package per se, run things like:

 $ make test
 $ make static-check

For testing the actual change:

 $ juju switch 3.4

Pull this change and point Juju's packaging package to your local path where you keep this change:

replace github.com/juju/packaging/v2 => <path-to->/packaging

Alternatively you can directly point to this change: (add the following to the go.mod in Juju):

replace github.com/juju/packaging/v2 => github.com/cderici/packaging/v2 noninteractive-frontend-JUJU-6135

After this, just build, bootstrap, deploy and play around to make sure nothing is broken (which means something's changed in the apt-get install and apt-get remove stuff).

 $ make build && make install
 $ juju bootstrap localhost
 $ juju deploy ubuntu
 $ juju remove-application ubuntu

@cderici cderici requested a review from hpidcock June 5, 2024 21:14
@cderici cderici changed the base branch from master to v2 June 5, 2024 21:36
cderici added 3 commits June 5, 2024 21:51
…able

DEBIAN_FRONTEND=noninteractive is used for disabling all interactions
on frontends of commands like apt-get, dpkg, etc.

https://bugs.launchpad.net/juju/+bug/2011637 reports that their
upgrade was stuck in a grub prompt during an apt-get install. This
change preceeds all apt-get commands with the
DEBIAN_FRONTEND=noninteractive env variable to ensure no prompts or
interactions happen during apt-get.

According to the `man 7 debconf`, this env variable "makes the default
answers be used for all questions".
@cderici cderici force-pushed the noninteractive-frontend-JUJU-6135 branch from 0c78f8b to 577e952 Compare June 5, 2024 21:56
@hpidcock
Copy link
Member

hpidcock commented Jun 5, 2024

To test this I needed to:

Downgrade distro-info

ubuntu@juju-1b3bf6-0:~$ apt list distro-info -a
Listing... Done
distro-info/jammy-updates,now 1.1ubuntu0.2 amd64 [installed,automatic]
distro-info/jammy 1.1build1 amd64
ubuntu@juju-1b3bf6-0:~$ sudo apt install distro-info=1.1build1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  shunit2
The following packages will be DOWNGRADED:
  distro-info
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 5 not upgraded.
Need to get 19.1 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] ...

Upgrade the controller

juju upgrade-controller --build-agent

But it said machine-0: 08:36:17 INFO juju.worker.upgradesteps upgrade steps for 3.4.4.3 have already been run. so that means I need to bump the juju version a bit more. So I changed version/version.go to 3.4.5.

So I upgraded the controller again (this time to 3.4.5...)

juju upgrade-controller --build-agent

Then I can see in debug-log it has upgraded the distro-info package

machine-0: 08:41:52 INFO juju.upgrade updating distro-info
machine-0: 08:41:52 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet update
machine-0: 08:41:52 INFO juju.state.pool.txnwatcher txn watcher started
machine-0: 08:41:53 INFO juju.apiserver.connection agent login: machine-0 for 73120324-ad3d-48c3-82a0-f3ca2cee2931
machine-0: 08:41:53 INFO juju.apiserver.connection agent disconnected: machine-0 for 73120324-ad3d-48c3-82a0-f3ca2cee2931
machine-0: 08:41:54 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet install distro-info
machine-0: 08:41:57 INFO juju.worker.upgradesteps signalling that this controller is ready for upgrade
machine-0: 08:41:57 INFO juju.worker.upgradesteps waiting for other controllers to be ready for upgrade
machine-0: 08:41:58 INFO juju.worker.upgradesteps finished waiting - all controllers are ready to run upgrade steps
machine-0: 08:41:58 INFO juju.worker.upgradesteps starting upgrade from 3.4.4.1 to 3.4.5.4 for "machine-0"
machine-0: 08:41:58 INFO juju.upgrade All upgrade steps completed successfully
machine-0: 08:41:58 INFO juju.worker.upgradesteps upgrade to 3.4.5.4 completed successfully.

Copy link
Member

@hpidcock hpidcock left a comment

Choose a reason for hiding this comment

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

Please ensure to add more tests to the juju/juju PR.

@cderici cderici merged commit cb8b0e9 into juju:v2 Jun 6, 2024
3 checks passed
jujubot added a commit to juju/juju that referenced this pull request Jun 7, 2024
#17483

This brings the `DEBIAN_FRONTEND=noninteractive` env variable to apt-get install (from juju/packaging#24), which is needed for
https://bugs.launchpad.net/juju/+bug/2011637 for auto upgrades/restarts.

<!-- Why this change is needed and what it does. -->

## QA steps

This is a change in the dependency (and it's QAed when it landed [over there](juju/packaging#24) on 3.4), however, it should be QAed on 3.5 as well.

This is for the lp bug https://bugs.launchpad.net/juju/+bug/2011637, and to QA this, we need to trigger an upgrade.

`juju bootstrap localhost testme`

After the controller is up, get in there and downgrade the `distro-info` (to be upgraded later by `juju upgrade-controller`:

```
$ juju ssh -m controller 0
 

ubuntu@juju-07b4a2-0:~$ apt list distro-info -a
Listing... Done
distro-info/jammy-updates,now 1.1ubuntu0.2 amd64 [installed,automatic] <------- 1.1ubuntu0.2 is installed
distro-info/jammy 1.1build1 amd64

# manually downgrade to 1.1build1
ubuntu@juju-07b4a2-0:~$ sudo apt install distro-info=1.1build1

ubuntu@juju-07b4a2-0:~$ apt list distro-info -a
Listing... Done
distro-info/jammy-updates 1.1ubuntu0.2 amd64 [upgradable from: 1.1build1]
distro-info/jammy,now 1.1build1 amd64 [installed,upgradable to: 1.1ubuntu0.2]
```

Now we need to trigger an upgrade on the Juju side, for this, edit the `version/version.go` with `3.5.3` (don't bump the minor, just the patch):
```
// The presence and format of this constant is very important.
// The debian/rules build recipe uses this value for the version
// number of the release package.
const version = "3.5.3"
```

Build and run an upgrade:
```
$ make build && make install
$ juju upgrade-controller --build-agent
no prepackaged agent binaries available, using local agent binary 3.5.3.2 (built from source)
best version:
 3.5.3.2
started upgrade to 3.5.3.2
```

Now take a look at the `juju debug-log -m controller` to see if you can spot that the `updating distro-info` succeeded:
```
...
machine-0: 22:05:01 INFO juju.worker.upgradesteps checking that upgrade can proceed
machine-0: 22:05:01 INFO juju.upgrade updating distro-info
machine-0: 22:05:01 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet update
machine-0: 22:05:04 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet install distro-info
machine-0: 22:05:08 INFO juju.worker.upgradesteps signalling that this controller is ready for upgrade
machine-0: 22:05:08 INFO juju.worker.upgradesteps waiting for other controllers to be ready for upgrade
machine-0: 22:05:08 INFO juju.worker.upgradesteps finished waiting - all controllers are ready to run upgrade steps
machine-0: 22:05:08 INFO juju.worker.upgradesteps starting upgrade from 3.5.2.1 to 3.5.3.2 for "machine-0"
machine-0: 22:05:08 INFO juju.upgrade All upgrade steps completed successfully
machine-0: 22:05:08 INFO juju.worker.upgradesteps upgrade to 3.5.3.2 completed successfully.
...
```

## Links

<!-- Link to all relevant specification, documentation, bug, issue or JIRA card. -->

**Launchpad bug:** https://bugs.launchpad.net/juju/+bug/2011637

**Jira card:** JUJU-6135
jujubot added a commit to juju/juju that referenced this pull request Jun 7, 2024
#17482

This brings the `DEBIAN_FRONTEND=noninteractive` env variable to apt-get install (from juju/packaging#24), which is needed for
https://bugs.launchpad.net/juju/+bug/2011637 for auto upgrades/restarts.

<!-- Why this change is needed and what it does. -->

## QA steps

This is a change in the dependency (and it's QAed when it landed [over there](juju/packaging#24) on 3.4), however, 3.4 might have changed by then, so it should be QAed here as well.

This is for the lp bug https://bugs.launchpad.net/juju/+bug/2011637, and to QA this, we need to trigger an upgrade.

`juju bootstrap localhost testme`

After the controller is up, get in there and downgrade the `distro-info` (to be upgraded later by `juju upgrade-controller`:

```
$ juju ssh -m controller 0
 
ubuntu@juju-085cfb-0:~$ apt list distro-info -a
Listing... Done
distro-info/jammy-updates,now 1.1ubuntu0.2 amd64 [installed,automatic] <------- 1.1ubuntu0.2 is installed
distro-info/jammy 1.1build1 amd64

# manually downgrade to 1.1build1
ubuntu@juju-085cfb-0:~$ sudo apt install distro-info=1.1build1

ubuntu@juju-085cfb-0:~$ apt list distro-info -a
Listing... Done
distro-info/jammy-updates 1.1ubuntu0.2 amd64 [upgradable from: 1.1build1]
distro-info/jammy,now 1.1build1 amd64 [installed,upgradable to: 1.1ubuntu0.2]
```

Now we need to trigger an upgrade on the Juju side, for this, edit the `version/version.go`:
```
// The presence and format of this constant is very important.
// The debian/rules build recipe uses this value for the version
// number of the release package.
const version = "3.4.5"
```

Build and run an upgrade:
```
$ make build && make install
$ juju upgrade-controller --build-agent
no prepackaged agent binaries available, using local agent binary 3.4.5.3 (built from source)
best version:
 3.4.5.3
started upgrade to 3.4.5.3
```

Now take a look at the `juju debug-log -m controller` to see if you can spot that the `updating distro-info` succeeded:
```
...
machine-0: 21:27:38 INFO juju.worker.upgradesteps checking that upgrade can proceed
machine-0: 21:27:38 INFO juju.upgrade updating distro-info
machine-0: 21:27:38 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet update
machine-0: 21:27:38 INFO juju.state.pool.txnwatcher txn watcher started
machine-0: 21:27:40 INFO juju.state LogTailer starting oplog tailing: recent id count=10, lastTime=2024-06-06 21:27:35.982729989 +0000 UTC, minOplogTs=2024-06-06 21:26:35.982729989 +0000 UTC
machine-0: 21:27:40 INFO juju.packaging.manager Running: apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::Options::=--force-unsafe-io --assume-yes --quiet install distro-info
machine-0: 21:27:44 INFO juju.worker.upgradesteps signalling that this controller is ready for upgrade
machine-0: 21:27:44 INFO juju.worker.upgradesteps waiting for other controllers to be ready for upgrade
machine-0: 21:27:44 INFO juju.worker.upgradesteps finished waiting - all controllers are ready to run upgrade steps
machine-0: 21:27:44 INFO juju.worker.upgradesteps starting upgrade from 3.4.4.1 to 3.4.5.3 for "machine-0"
machine-0: 21:27:44 INFO juju.upgrade All upgrade steps completed successfully
machine-0: 21:27:44 INFO juju.worker.upgradesteps upgrade to 3.4.5.3 completed successfully.
...
```

## Links

<!-- Link to all relevant specification, documentation, bug, issue or JIRA card. -->

**Launchpad bug:** https://bugs.launchpad.net/juju/+bug/2011637

**Jira card:** JUJU-6135
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.

2 participants