dnf in Practice
Goal
With dnf you check the repository, install, trace a package back from a file before installing it, pick one transaction and undo it, and pin a version. In the final step, you work out per package why "it is supposedly pinned yet tries to upgrade" and fix it.
Why it matters
The decisive difference of dnf is that every install is recorded as a numbered transaction and can be undone by that number. apt has no corresponding feature. This difference changes the way you operate — "install it to see, and undo it if it isn't right" becomes possible. But if you pick the wrong number to undo, whatever was installed together with it disappears too, so you need the habit of looking at what a number did before picking it.
And a version lock is "writing one line in a list", so there is no warning when it is wrong. If the name is off by one character or it points to the new version, it shows up in the list but holds nothing, and that fact surfaces only after the regular upgrade runs. The incident in the final step is exactly that scene.
Steps
- Create the
/root/rhdirectory and save the detailed repository list to/root/rh/repolist.txt. A baseurl pointing to/opt/localrepomust be visible. - Query the information of the
treepackage and write only the version string on one line in/root/rh/tree-version.txt. - Install
treeandnanoseparately (two transactions), and write the NEVRA (name-version-release.architecture) of each of the two packages, one line each, in/root/rh/installed.txt. - Find the package containing
/usr/bin/iostatwithout installing it, and write only the package name in/root/rh/provides.txt. - Write the number of the transaction that installed only
nanoas a single numeric line in/root/rh/nano-txid.txt. - Undo that transaction (undo). After undoing it,
nanomust not be installed (tree must remain), and save that state to/root/rh/after-undo.txt. - Pin
treeto the version currently installed, and save the lock list to/root/rh/lock.txt. - Incident: raise
incident rh-lock-ignored, work out per package why three acme packages that are supposedly pinned appear as upgrade candidates, and fix them so they stay at 1.0. The report is/root/incident/rh-lock-ignored/report.txt.
Notes
- This lab is set up to finish within a 60-minute session (about 42 minutes), but if you spend a long time on the incident, extend it with
+시간(add time). The lab Pod has no volume, so your work disappears when the session ends. - The truth about what is installed lives in the rpmdb. Record the results of rpmdb queries rather than the package manager's output.
- When looking at upgrade candidates, use the command that reflects both locks and excludes. Some repository queries do not go through the version lock plugin, so the results differ.
- Incident tools:
incident listshows the incidents you can raise and a one-line symptom for each, andincident show <이름>(name) shows the ticket again. Raisingincident <이름>again returns it to its original broken state. - The incident report goes in
/root/incident/<이름>/report.txt(name is the incident name): one line<대상>: <원인 코드>(target: cause code) per target, plusevidence: <원인을 보여 준 출력 한 줄>(one line of output that showed the cause). Copy the evidence as is from output you actually saw. - Common mistake 1: if you install tree and nano with one command for steps 5 and 6, undoing that transaction removes tree as well.
- Common mistake 2: if you "add" again for a package that already has a wrong lock entry, the plugin only says it is "already locked" and changes nothing.
Checking the repository
Create the /root/rh directory and save the detailed repository list to /root/rh/repolist.txt. A baseurl pointing to /opt/localrepo must be visible.
Direction: you need not only the repository names but where each repository points. Tool: the verbose option that expands the repository list entry by entry. Concretely: each entry must show Repo-baseurl, Repo-expire, and Repo-filename lines, and the only one enabled is the local snapshot inside the image.
Querying package information
Query the information of the tree package and write only the version string on one line in /root/rh/tree-version.txt.
Direction: ask what the repository knows about that package, whether or not it is installed (the local database knows only what is installed). Tools: the subcommand that shows package information, or a repository query with an output format. Concretely: only the value of the version field; the grader compares it with the version the repository provides.
Installing packages
Install tree and nano separately (two transactions), and write the NEVRA (name-version-release.architecture) of each of the two packages, one line each, in /root/rh/installed.txt.
Direction: the unit of undoing is not a package but a transaction; if you install both in one command, both disappear together in step 6. Tools: the install subcommand, a local query asking about installed packages. Concretely: the record is based on the NEVRA line the local database outputs, not the package manager's output.
Finding the owner of a file that is not installed
The command /usr/bin/iostat is not on this server yet. Find the package containing this file without installing it, and write only the package name on one line in /root/rh/provides.txt (no version or architecture). Installing that package is a failure.
Direction: the local database knows the owners of installed files. For a file that does not exist yet, the answer comes only from the "file list" in the repository metadata. Tools: try both a local query (-qf) and a repository query (provides, whatprovides), and see why the results differ. Concretely: the first column of the repository query output is name-version-release.architecture. If you need only the name, specifying an output format is safer than cutting at hyphens by hand.
Choosing the transaction to undo
In the dnf transaction history, find the number of the transaction that installed only nano and write it as a single numeric line in /root/rh/nano-txid.txt. You undo this number in the next step (a transaction that also installed tree is a failure).
Direction: the unit of undoing is not a package but a transaction number. The habit of checking what a number did before picking it prevents accidents. Tools: the history list (which you can narrow by package name) and the detailed view of one number. Concretely: Packages Altered in the detailed view must contain only Install nano-….
Undoing a transaction
Undo the transaction that installed nano (undo). After undoing it, nano must not be installed, and save that state to /root/rh/after-undo.txt.
Direction: run the "opposite" of the one number you picked in step 5; this is different from undoing everything after that point. Tools: the undo action of the history subcommand, a local query asking whether something is installed. Concretely: the not-installed message comes out on standard error, so save that too. If tree disappears along with it, you picked the wrong number.
Pinning a version
Pin tree to the version currently installed (dnf's version lock plugin), and save the lock list to /root/rh/lock.txt. If you cannot use the plugin command, you may write directly in the plugin's list file.
Direction: a lock is one line saying "allow only this version of this name"; if even one of the name or version is wrong, it shows up in the list but holds nothing (the trap of the step 8 incident). Tools: the add and list subcommands of the version lock plugin. Concretely: a line of the form -0:-.* must appear in the list file, and the grader checks that it matches the currently installed version exactly.
Incident: three packages supposedly pinned still appear as upgrade candidates
Running incident rh-lock-ignored puts acme-* 1.1 into the in-house repository acme-updates, and acme-agent, acme-cli, and acme-db, which the operations team supposedly pinned at 1.0, still appear in dnf check-update (read the ticket first). Classify each of the three as one of exclude-wrong-repo (the exclude rule is in a repository that package does not come from), locked-new-version (the lock entry points to the new version), name-mismatch (the lock entry's name differs from the package), plugin-disabled (the lock plugin is turned off), or stale-cache (the metadata cache is stale), and fix them so that all three stay at 1.0. For agent and cli you must correct the lock entry itself; blocking them by covering with an exclude rule is not a fix. acme-web is to be upgraded in this window, so it must not be blocked, and turning off the repository or deleting 1.1 is not allowed either. In /root/incident/rh-lock-ignored/report.txt, write three lines <패키지>: <코드> (package: code) and evidence: <관찰한 출력 한 줄> (one line of output you observed).
Direction: "the lock does not work" means the lock entry is not holding anything. For each package separately, check whether each entry's name and version exactly match what is installed now, and which repository the exclude rule is attached to. Tools: the upgrade candidate check, the version lock plugin's list, config-manager's dump that expands the actual per-repository configuration, and a query showing which repository a package comes from. Concretely: compare the lines in the lock list character by character with the NEVRA in the rpmdb, and read what the plugin answers when you add an entry that already exists. excludepkgs applies only to packages in the repository section it is written in.