Commit Graph

124 Commits

Author SHA1 Message Date
Colin Walters
b82f7338ea src: Quiet a few gcc -Wmaybe-uninitialized warnings
GCC (at least 5.2.1) isn't smart enough to figure out these are always
initialized.
2015-11-23 12:08:37 -05:00
Matthew Barnes
6c197455e1 daemon: Don't fail during rebase cleanup
Ignore errors during cleanup after a successful rebase.  The source
origin ref may not actually exist.  The issue linked below describes
one such case.

Fixes https://github.com/projectatomic/rpm-ostree/issues/179
2015-11-16 15:35:39 -05:00
Matthew Barnes
63d7ff8d5f daemon: Add rpmostreed_parse_revision()
Determines a revision argument to either be a SHA256 checksum or a version
metadata value.

The revision string may have a "revision=" prefix to denote a SHA256
checksum, or a "version=" prefix to denote a version metadata value.  If
the revision string lacks either prefix, the function attempts to infer
the type of revision.  The prefixes are case-insensitive.
2015-11-06 09:10:48 -05:00
Matthew Barnes
6f184d6072 daemon: Remove equivalence check for details variant
rpmostreed_commit_generate_cached_details_variant() returns NULL if the
origin checksum of an OstreeDeployment matches the checksum of a refspec,
which may also be the OstreeDeployment's origin.

I don't understand the reasoning for that, especially since none of the
callers are prepared to deal with a NULL return.  Nor is there a comment,
so remove the check.

This was making the daemon crash on

  rpm-ostree deploy --preview <current-deployment-checksum>

which should just indicate no package differences.
2015-11-06 09:10:48 -05:00
Matthew Barnes
0a7706c241 daemon: Strip override-commit when upgrading
Deploy method locks the deployment at a particular commit by adding an
"override-commit" line to the origin file.

Upgrade method must undo the override so we always upgrade to the latest
available commit.
2015-11-06 09:10:48 -05:00
Matthew Barnes
9eabc1ba3c daemon: Add "RpmDiff" methods to supplement Deploy
DownloadDeployRpmDiff and GetCachedDeployRpmDiff, which take the same
revision argument as Deploy.
2015-11-06 09:10:48 -05:00
Matthew Barnes
9a13d39a25 daemon: Add Deploy() method
Deploy(revision) pulls and deploys a particular revision on the
branch of the currently booted deployment.  The revision can be
expressed as a SHA256 checksum or as a version metadata value.
2015-11-06 09:10:48 -05:00
Matthew Barnes
316f927aef daemon: Add rpmostreed_repo_lookup_cached_version()
Similar to rpmostreed_repo_lookup_version(), except without pulling from
a remote repository.  It traverses whatever commits are available in the
local repository.
2015-11-06 09:10:48 -05:00
Matthew Barnes
b3ecdd10b6 daemon: Add primitives for version lookup
rpmostreed_repo_pull_ancestry() downloads an ancestry of commit objects
starting from a given refspec.  An optional visitor function is called
for each commit object.  The visitor function can stop the recursion,
such as when looking for a particular commit.

rpmostreed_repo_lookup_version() builds on this by supplying a visitor
function that examines commit metadata for a particular version value.
When the version value is found, the commit's checksum is returned to
the caller.
2015-11-06 09:10:48 -05:00
Matthew Barnes
a5dd7d1a1a daemon: Miscellaneous diff operation cleanups 2015-11-06 09:10:48 -05:00
Giuseppe Scrivano
f140f33d4d rpm-ostree: support 'reboot' immediately after a rebase
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:33:06 +02:00
Giuseppe Scrivano
b5cd3f2d1e rpmostreed: refactor common code in the new function rpmostreed_reboot
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:22:36 +02:00
Giuseppe Scrivano
f8cc2e05a8 fixup! rpm-ostree: support 'reboot' immediately after a rollback 2015-10-06 08:35:10 +02:00
Giuseppe Scrivano
fad97b901c fixup! rpm-ostree: support 'reboot' immediately after an upgrade 2015-10-06 08:32:15 +02:00
Giuseppe Scrivano
1bc2029173 rpm-ostree: support 'reboot' immediately after a rollback
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-05 09:18:50 +02:00
Giuseppe Scrivano
391522ecdb rpm-ostree: support 'reboot' immediately after an upgrade
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-05 09:14:51 +02:00
petervo
85c82816b6 daemon: Add detail variant to rpm diff methods
Allows clients to see version, timestamp
and other detailed information along with
the rpm diffs for cached updates and rebases.

This will be used by the Cockpit interface.
2015-09-29 17:39:15 -07:00
petervo
cb6ed53fec daemon: Expose details for cached updates
Adds a CachedUpdate property that allows clients
to see version, timestamp and other detailed
information for pending updates. Additionally
changes to this property signal clients that a
new rpm-diff can be fetched with GetCachedUpdateRpmDiff.

This will be used by the Cockpit interface.
2015-09-29 17:38:51 -07:00
petervo
8ed604ef2d daemon: Expose the path that started a transaction 2015-09-28 17:25:25 -07:00
Matthew Barnes
73f2a7f058 daemon: Make "diff" methods safer
Various OS "diff" methods can run concurrently with whatever else is
going on since they don't have to obtain the system root lock.

Just to make sure there's no conflicts when writing deployments or
downloading RPM package details, use an internal reader/writer lock
to protect the critical sections of upgrade, rebase, rollback, etc.
2015-09-09 22:00:06 -04:00
Matthew Barnes
a22c592a78 daemon: Use GVariantDict ("a{sv}") for deployments
Allows for future extensibility.  Also some of the optional attributes
can actually be optional.  See the XML interface spec for the key names.
2015-09-09 22:00:06 -04:00
Matthew Barnes
7b7f13697f daemon: Remove fallback PATH setting
To the best of my knowledge, the daemon does not rely on PATH anywhere.
This chunk of code is uncommented and seems unnecessary so remove it.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d32a4b9f6a daemon: Update deployments on "updated" signal
Also, renamed the signal from "sysroot-updated" since it originates
from RpmostreedSysroot.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a388f986bb daemon: Don't keep persistent OstreeSysroot instance
Create and load a new OstreeSysroot and OstreeRepo instance as needed.
This ensures its internal state is up-to-date, since several ostree
commands can alter stored state without the daemon's knowledge.

I would prefer keeping persistent instances if these issues can be
addressed, as it would eliminate some inconvenient error handling.
But this way is safer for now.
2015-09-09 22:00:05 -04:00
Matthew Barnes
22c5d5a654 daemon: Add rpmostreed_sysroot_load_state()
Replaces rpmostreed_load_sysroot_and_repo() with a slightly more
convenient API.
2015-09-09 22:00:05 -04:00
Matthew Barnes
82702c295b daemon: Fix OS.Rebase() method
Having the OS.Upgrade() and OS.Rebase() logic flows conflated in the
daemon had me nervous.  A day's worth of debugging a failing test case
proved that nervousness well-founded.  Split them into distinct backend
operations.
2015-09-09 22:00:05 -04:00
Matthew Barnes
8d2713e0f2 daemon: Add a Sysroot.Path property
So the client side can read it back.

This replaces the GObject "sysroot-path" property in the wrapper class,
which created some additional daemon refactoring.
2015-09-09 22:00:05 -04:00
Matthew Barnes
0326568a4a tests: Adapt to rpm-ostree daemon
No doubt better ways are possible but this is the least messy thing
I could come up on a deadline.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a1b7ed5f9c daemon: Remove "on-message-bus" property
Wasn't used for anything.
2015-09-09 22:00:05 -04:00
Colin Walters
41d74abaf8 daemon: Bind DBus service <-> systemd service configs
Using this flag tells DBus to activate using systemd, which gives
tighter integration.
2015-09-09 22:00:05 -04:00
Colin Walters
da81156d81 daemon: Export objects on bus (not name) acquision
This closes a race condition where the objects might not be exported
by the time clients call methods.

Also delete the code in the "on name lost" handler - it's not going to
happen in practice (we don't allow replacement), and causes issues as
it may be run first before we get the notification that the name is
owned.  github.com/cockpit-project/storaged has some better code here
which we could copy later.

This then in turn allows us to delete the "hold"/"release"
infrastructure.  Basically the daemon will live forever in the
process.
2015-09-09 22:00:05 -04:00
Matthew Barnes
9c0e87bc75 daemon: Share Transaction address for identical requests
If a client makes a request that is identical (that is, same method name
and same parameters) to an ongoing transaction, return the bus address of
that transaction.  The client can then "tune in" to the progress messages.
(Remember the Transaction.Start() method returns a boolean to distinguish
a newly-started transaction from an ongoing transaction.)

The driving use case for this is a dropped ssh connection during a long
running transaction -- like "upgrade" -- and being able to reattach to
the transaction's progress messages mid-stream.
2015-09-09 22:00:05 -04:00
Matthew Barnes
b3189b6ae4 daemon: Support multiple Transaction connections
Few things to note:

 - Cancelling a transaction no longer immediately destroys it.

 - Transaction is destroyed when finished (or cancelled) and has
   no client connections.

 - If a client attaches to a finished transaction and calls Start(),
   the transaction will re-emit the Finished signal to that client.

 - The transaction bus address is not yet shared across multiple
   clients, so multiple connections doesn't actually work from the
   outside yet.  It's just supported internally.
2015-09-09 22:00:05 -04:00
Matthew Barnes
24f01556a0 daemon: Make the Transaction.Start() method idempotent
Add a boolean return so callers can distinguish between actually starting
the transaction or reattaching to an in-progress transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
6e28454e6d daemon: Change bus name watching semantics
Only watch the caller's bus name until the transaction is started.
Thereafter the transaction proceeds independently of the calling
process.
2015-09-09 22:00:05 -04:00
Matthew Barnes
aaadcba77b daemon: Rename all the things!
Use 'rpmostreed' as the symbol prefix.
2015-09-09 22:00:05 -04:00
Matthew Barnes
188be0cd58 daemon: Change ActiveTransaction value
Change the ActiveTransaction property from the bus address of the active
transaction to a string tuple: (method name, sender name)

The bus address was only a placeholder, and not very useful since each
transaction only accepts one connection (presumably the method caller).
2015-09-09 22:00:05 -04:00
Matthew Barnes
495bf4c3f3 daemon: Simplify authorization policy
The current policy is to only allow the root user access to the Sysroot
and OS interfaces, but this can be expressed in the static bus config.

The long-term intention is to integrate with PolicyKit.  Leave comments
in the code stating so but remove the unnecessary authorization handler
for the time being, just so there's less code to review.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d051794a88 daemon: Add debug messages for transactions 2015-09-09 22:00:05 -04:00
Matthew Barnes
7917c89890 daemon: More transaction API churn
Since the daemon can detect when the client closes its peer-to-peer
connection, simplify the API by converting the Finish() method to a
Finished signal that is only emitted once.

Internally, add a "closed" signal to transactions (triggered by a
closed GDBusConnection), and have the transaction monitor use that
instead of "finished" to know when to dispose of the transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
ebc48d0158 daemon: Remove owner checks on Transaction methods
Because peer-to-peer endpoints don't get assigned unique names, the
sender == owner check is rendered useless.  But I'm not sure we even
need a check since the transaction *is* peer-to-peer now.

One way to secure the returned bus address from prying eyes would be
to employ GcrSecretExchange, but this would only complicate the hand-
shake further and (imo) necessitate a public client-side function to
implement the handshake correctly.
2015-09-09 22:00:05 -04:00
Matthew Barnes
19e626c087 daemon: Use a peer-to-peer connection for transactions
Transaction progress and message signals are really only intended for
one recipient: the client that invoked the method.  Use a peer-to-peer
connection for transactions so we're not spamming the system bus.

This entails returning a bus address rather than an object path in
methods that use transactions.  The client opens a connection to the
bus address, connects handlers to the Transaction interface (on path
"/"), and then invokes the Start() method.

To finish a transaction, the client need only close the connection,
either explicitly or by terminating.  The server will detect this
and clean up resources for that transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d69cb7d7c1 daemon: Convert transactions to subclasses
Implementing a template pattern for transactions.

The TransactionClass is now abstract, and transaction_new() is replaced
with various method-specific functions like transaction_new_upgrade().
These custom subclasses live in a new file transaction-types.[ch].

Further, transaction_monitor_new_transaction() is replaced with
transaction_monitor_add().  So the handlers for "OS" interface methods
need only create an appropriate transaction instance and hand it off to
the transaction monitor.
2015-09-09 22:00:05 -04:00
Matthew Barnes
434a967ab1 daemon: Add "invocation" property to TransactionClass
Move as much as possible out of transaction_new() for the benefit of
subclasses.  The GDBusMethodInvocation property for setting up D-Bus
properties and name watching in the constructed() method.
2015-09-09 22:00:05 -04:00
Matthew Barnes
36c87fb483 daemon: Add a Start() method to transactions
Turns out we do still need a Start() method after all.  Not for lack
of trying, but I can't get away from the client and server doing some
sort of handshake at the beginning to avoid either raciness on the
client side or artificial delays on the server side.

I don't particularly like the "start" signal I've added -- I'd much
prefer subclassing -- but I'm trying to keep the changes incremental.
2015-09-09 22:00:05 -04:00
Matthew Barnes
029a3e5924 daemon: Prepare TransactionClass for subclassing
Expose the instance and class structures, move instance members to a
private structure.  This is also towards having the TransactionClass
follow a template pattern.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a0db1c705f daemon: Have Transaction objects handle sysroot locking
Also, the Transaction holds an OstreeSysroot reference for its duration,
which is convenient for callbacks.
2015-09-09 22:00:05 -04:00
Matthew Barnes
1934d631c0 daemon: Implement GInitableIface in transactions
Towards having the Transaction wrapper class follow a template pattern.
2015-09-09 22:00:05 -04:00
Matthew Barnes
cfc52adfea daemon: Catch systemd journal messages by redirecting stdout
libostree logs messages to systemd's journal and also to stdout.
Redirect our own stdout back to ourselves so we can capture those
messages and pass them on to clients.  Admittedly hokey but avoids
hacking libostree directly (for now).
2015-09-09 22:00:05 -04:00
Matthew Barnes
f1973d7557 daemon: Add ProgressEnd signal to Transaction interface
The ProgressEnd signal indicates to clients there will be no more
DownloadProgress or SignatureProgress signals in the transaction,
and any further Message signals should be output as separate lines
instead of replacing the previous progress message.

In other words, it's just a way of driving GSConsole remotely.
2015-09-09 22:00:05 -04:00
Matthew Barnes
b6691cbdca daemon: Rework transactions
A few changes:

- Modify the D-Bus API to include a Finish() method instead of a Start()
  method, the idea being the client calls Finish() to obtain the final
  status and optional message once the transaction indicates it's done.
  Calling Finish() also removes the transaction object from the bus.

- Introduce Transaction class as a thin wrapper for RPMOSTreeTransaction.
  Stores the status info for Finish(), detects when the caller's bus name
  vanishes, and emits various status signals to TransactionMonitor.

- Introduce TransactionMonitor as a factory class for Transactions that
  also handles book keeping chores like tracking the active Transaction.
  The Sysroot and OS interfaces share a TransactionMonitor instance.
2015-09-09 22:00:05 -04:00
Matthew Barnes
463d3676ea daemon: Miscellaneous cleanups 2015-09-09 22:00:05 -04:00
Matthew Barnes
915b78e2aa daemon: Startup modifications 2015-09-09 22:00:04 -04:00
petervo
23cfdf29b6 daemon: Track active transaction 2015-09-09 22:00:04 -04:00
petervo
0114507865 daemon: Start implementing transaction methods 2015-09-09 22:00:04 -04:00
petervo
075d6bdad0 daemon: Implement package diff methods 2015-09-09 22:00:04 -04:00
petervo
a140c26200 daemon: OS properties and property updates 2015-09-09 22:00:04 -04:00
Matthew Barnes
c6548ace61 daemon: Half-implement the Upgrade() command
This isn't finished yet but it shows the direction I'm going and some
issues I'm encountering.

The CLI layer has 3 different versions of upgrade now:

  1) If --check-diff is given, execute it locally regardless of sysroot.
     I'm not convinced this variation needs to be executed in the daemon,
     but if it does we need a separate D-Bus method since it produces
     different results.

  2) Else if --sysroot is not "/", execute it locally.  I don't think
     the daemon currently indicates what sysroot it's operating on, and
     even if it did I'm not sure the CLI should be talking to anything
     but the "/" daemon.

  3) Else if --sysroot is "/", defer to the daemon.

Obviously there's a lot of unwanted code duplication going on here.
I'd like to factor out the common parts and put them in libpriv for
reuse, but I'm also trying to preserve the CLI behavior and all the
various g_print() calls are causing a problem.

I was toying with the idea of adding a "message" signal to
OstreeAsyncProgress for miscellanous status messages.  Those signals
could then be handled by either printing the message to stdout or
transmitting it over D-Bus via the Transaction object.

Some of those g_print() messages could then be moved directly into
the common libpriv functions and handed off to OstreeAsyncProgress.
2015-09-09 22:00:04 -04:00
Matthew Barnes
0b89d54bb0 daemon: Add GetOS() method to Sysroot interface
Returns the object path for the given OS name.

This can be done entirely client side, but it requires connecting to
the object manager interface, requesting all the objects and sifting
through them to find the one with a matching Name property.

For some use cases this method is just more convenient.
2015-09-09 22:00:04 -04:00
Matthew Barnes
b4db4a1621 daemon: Some D-Bus API tweaks
Trying to get the Update() method working end-to-end, and figuring out
all the status reporting around it.
2015-09-09 22:00:04 -04:00
Matthew Barnes
89e41eb8db daemon: Integrate download progress into new_transaction() 2015-09-09 22:00:04 -04:00
Matthew Barnes
84dbd934b5 daemon: Add callback stubs for OS methods 2015-09-09 22:00:04 -04:00
petervo
d332175bb3 daemon: Ensure os names are relative to deploy dir 2015-09-09 22:00:04 -04:00
petervo
19fde3a50a daemon: Start of sysroot interface implementation 2015-09-09 22:00:04 -04:00
petervo
8b283656b6 daemon: Dbus setup
Brings in auth, errors and path building functions
2015-09-09 22:00:04 -04:00
petervo
94efc7bb77 daemon: Publishing and unpublishing interfaces 2015-09-09 22:00:04 -04:00
petervo
950fcf7a99 daemon: deployment utils
Adds a gvariant representation of a deployment
2015-09-09 22:00:04 -04:00
Matthew Barnes
c2e19fb39e daemon: Add deployment_generate_id() to utils 2015-09-09 22:00:04 -04:00
Matthew Barnes
8f5993e220 daemon: Add factory function for Transaction objects
Creates, configures and exports an RPMOSTreeTransaction object from a
GDBusMethodInvocation.  The interface is exported relative to the object
path on which the D-Bus method was called.
2015-09-09 22:00:04 -04:00
Matthew Barnes
0774249b81 daemon: Add "Method" property to Transaction object 2015-09-09 22:00:04 -04:00
Matthew Barnes
d6a48feb7a daemon: Handle bus name acquisition in main.c 2015-09-09 22:00:04 -04:00
Matthew Barnes
2f5057a022 daemon: Make the Daemon instance global in main.c
Just easier than passing it around to callbacks.
2015-09-09 22:00:04 -04:00
Colin Walters
a435dea27a daemon: Flesh out new API
Peter, Matthew and I talked for a while and came up with this.
2015-09-09 22:00:04 -04:00
petervo
c0d15a66ad daemon: Start of work on daemon 2015-09-09 22:00:04 -04:00