306 Commits

Author SHA1 Message Date
Auke Kok 58e5a63551 v45 v45 2019-12-20 12:43:12 -08:00
Auke Kok 533c9a0065 Attempt harder to obtain config-drive.
There are some cases where a config-drive is on the system, but
not initially detected early at boot. One such case is when the
cdrom subsystem isn't builtin to the kernel but enabled as a module.

We can try and catch this issue. It will slow down boot a bit, so
this only waits 1 second total for now. But modprobing `sr_mod` which
depends on `cdrom` is a good start here, and covers obtaining the
`meda_data.json` file in case a VM is booted with the -native or
other non-kvm kernels.
2019-12-18 12:20:06 -08:00
Auke Kok ca976ef947 v44 v44 2019-12-03 11:30:07 -08:00
Auke Kok 919dcdd6b7 Remove forced dependency ordering on systemd-networkd.
These lines forced systemd-networkd to wait until `ucd` had
completed.

In turn, `ucd` requires the network to be active in order
to install packages. It waits for the network to become
active, even.

Surely, this is untenable. Ucd will have to accept any
network state and may not prevent it from starting as
early as possible, which would be counter to any fast
boot initiative.
2019-11-13 12:18:32 -08:00
Auke Kok 463cb9f1a2 check dependency for CI. 2019-11-06 11:26:31 -08:00
Auke Kok fe6b56d58c Dix dependency names. 2019-11-06 11:14:59 -08:00
Auke Kok 44a2dc1885 Fix suffix. 2019-11-06 11:12:22 -08:00
Auke Kok 714a13e43b Use sudo in actions. 2019-11-06 11:11:11 -08:00
Auke Kok feff4b8798 Install deps (guess). 2019-11-06 11:08:10 -08:00
Auke Kok a229e6c247 Clean up yml file. 2019-11-06 10:57:25 -08:00
ahkok 79f4836877 Add github actions integration. 2019-11-06 10:56:18 -08:00
Auke Kok 13e2a7b290 v43 v43 2019-11-06 09:03:49 -08:00
Auke Kok 65b6eddb4a Fix wait_for_network, tested now too. 2019-11-06 09:03:24 -08:00
Auke Kok 0407325314 v42 v42 2019-10-31 14:39:37 -07:00
Auke Kok 5aa46b9b7d Allow packages etc. to also enter a valid wait for network. 2019-10-31 14:39:13 -07:00
Auke Kok e95430c21a Consolidate 2 vars, ensure we sleep a few times here. 2019-10-31 14:35:09 -07:00
Auke Kok 68e27c67ef Header - multiple inclusion guard. 2019-10-31 14:21:44 -07:00
Auke Kok 85747cb4c2 v41 v41 2019-10-29 11:33:34 -07:00
Auke Kok 9644cbdc5d Add wait_for_network: <boolean>.
This option allows users to suspend execution of the cloud-init provisioning
until a valid network is detected.

This detection is currently done through requesting a DNS lookup for one
of the Clear Linux NTP service IP addresses (this is a RR record, we
don't actually look at the result).

This lookup is not infinite. After 5 minutes, the wait exits no matter
what even if there is no network detected.

The option can be provided manually. `packages` and `package_upgrade`
options *imply* this option, but one can explicitly disable the wait
by providing it early in the cloud-config file with a value of `false`.

The wait routing is active - it will retry relatively quickly to detect
an active connection. Any failure will result in another retry. In
a fully private network without public DNS, this will not work.

The DNS hostname used for testing can be manipulated through the
`-with-dnstestaddr=<hostname>` configure flag. You shouldn't put an
IP address in here, since that fully disables any network testing.
2019-10-29 11:33:17 -07:00
Auke Kok 4364c943e1 v40 v40 2019-10-15 11:31:18 -07:00
jwang 4706d35c2c Add aliyun cloud support
Enable ucd to work in aliyun cloud by add a config templete
for aliyun

Signed-off-by: jwang <jing.j.wang@intel.com>
2019-10-15 11:27:02 -07:00
Auke Kok 2c8d9c0d62 Add security concern section to the README.md. 2019-10-14 14:30:18 -07:00
Auke Kok 112e0a4e39 v39 2019-09-30 10:58:24 -07:00
Auke Kok 542b611ae1 user-data: allow missing user data.
When I deduplicated this code I mistakenly used parse_headers() in
the same way twice. This was incorrect.

We definitely need to error out if a 404 or something else happens
for the SSH keys, since then we've lost entirely.

But a missing `user-data` is mostly harmless and optional, so, in
case a 404 happens for the second `GET` request, we shouldn't error
out, because this makes the instance unusable. Instead, we can
carry on as normal.
2019-09-30 10:58:24 -07:00
Auke Kok a240a29d21 Fix typo in yaml tag for ssh_authorized_keys. 2019-09-30 10:58:24 -07:00
jwang 7ed37b2b41 fix typo in tencent cloud-config template 2019-09-24 20:55:25 -07:00
Auke Kok 402d6a6255 v38 v38 2019-09-23 10:10:20 -07:00
Auke Kok 922b303f1b Don't create an abbreviated AWS user-data. 2019-09-23 10:09:46 -07:00
Auke Kok c351cb4ea5 v37 v37 2019-09-23 09:47:25 -07:00
jwang 2c7059fa5d fix wrong retcode check for write_lines function
write_lines return 0 means succeed, thus !write_lines go into error
handling path, which is not expected.

Signed-off-by: jwang <jing.j.wang@intel.com>
2019-09-12 10:47:53 -07:00
Auke Kok d2451d23ec Create write_lines() function to replace problematic duplicate code.
Create a new function for both sections of code needing to output
remainder stream bytes into output file. This makes error handling simpler
and easier to focus on the errors here in tencent.

I've adapted the code to use the OCI model of outputting the needed
data since OCI code written by William handles the output slightly
different based on previous experiences with OCI and I think this may
just help the Tencent case as well.

Also change some types to reduce casting. All in all this slightly
cleans up the code a bit.
2019-08-16 13:01:13 -07:00
Auke Kok 51e7f96ba3 Catch empty user_data file - nothing possible to do. 2019-08-15 16:11:17 -07:00
Auke Kok 57c3c60066 Check return value of write(). 2019-08-15 15:04:42 -07:00
Auke Kok d54043ce45 Handle write() exception. 2019-08-15 14:47:14 -07:00
Auke Kok 160ec7394e Don't run strlen() if buf is NULL.
Change the order here to make sure we're not running strlen
for no reason.
2019-08-15 14:05:31 -07:00
Auke Kok bdad5c2818 Update man pages to reflect the ucd-data-fetch program. 2019-08-07 14:59:30 -07:00
Auke Kok 01d4102d99 ucd-data-fetch: Support HTTP/1.1, allow HTTP/1.0 responses.
We do not want to break anything where HTTP/1.0 is only supported,
so we advertise 1.1 but allow responses from 1.0 capable server
as well as 1.1 capable servers.
2019-08-07 13:29:32 -07:00
Auke Kok 31e30b5b29 Start of unification of aws/oci/tencent data fetcher.
Instead of keep duplicating existing code, we can make this program
a little bit more versatile and cover all 3 use cases and add some
extensibility for further additions.

A static table describes what needs fetching and from where. The
rest is logically the same and so the delta isn't so bad.

We add tencent cloud support on top of this.
2019-08-06 15:29:12 -07:00
Auke Kok 908e95fd7c v36 v36 2019-04-11 14:20:26 -07:00
Julio Montes b1073ea8d4 disk: maximize rootfs partition
Other cloud-config implementations like cloud-init resizes automatically the
rootfs to the maximum allowed, ucd should do the same.

fixes #34

Signed-off-by: Julio Montes <julio.montes@intel.com>
2019-04-11 23:18:28 +02:00
Auke Kok 1f7c95ba1a Update man pages with proper formatting. v35 2018-11-16 10:58:38 -08:00
Auke Kok 496c1bb1b0 Also ignore ucd-oci 2018-11-16 10:58:26 -08:00
Auke Kok 451aa37d84 Fix man page generation. 2018-11-16 10:56:29 -08:00
Auke Kok 203c668269 v35 2018-11-16 10:49:28 -08:00
Auke Kok 365393bd31 Memset struct sockaddr_in to zero. 2018-11-16 10:48:57 -08:00
Auke Kok a98a0fe6c0 v34 v34 2018-11-16 09:45:05 -08:00
Auke Kok dc803bd6aa Fix dead code branch on error condition. 2018-11-16 09:44:46 -08:00
Mark D Horn bbed0e8a1b Markdown formatting fixes
Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
2018-09-13 08:59:56 -07:00
Auke Kok 45e7443579 v33 v33 2018-09-06 09:29:28 -07:00
Auke Kok bfc2d427be AWS: Do not assume the HTTP server supports keep-alive.
On some of the computational AWS instances, the HTTP service at
169.254* does not support HTTP/1.0 keep-alive. This causes the
second part of the user-data not to be transferred and results
in an error during the execution of ucd-aws. Subsequently, the
SSH key never gets provisioned by `ucd`. The result is an unusable
AWS instance that can't be remotely logged into.

Instead, we just terminate and reconnect for the second HTTP
request, reusing some memory where we can. This is a minute
bit slower, and doesn't really come at a size penalty either,
since it's just the same functions being used.
2018-09-06 09:26:29 -07:00