Commit Graph

91 Commits

Author SHA1 Message Date
Andrey Smirnov
360d887967 fix: prevent endless loop with DHCP requests in networkd
There were two problems:

* `configureInterfaces` was always failing if interface is already set
up, as the routes already exist

* `renew` was halving the renew interval each time `configureInterface`
fails, which starts at (LeaseTime/2) and goes effectively to zero

This was leading to high networkd CPU usage, storm of DHCP requests on
the network.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-12-01 08:12:12 -08:00
Andrew Rynhard
10db642b2f feat: add support for the Banana Pi M64
This adds the Banana Pi M64 to the list of supported boards.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
2020-11-30 18:17:37 -08:00
Artem Chernyshev
8aad711f18 feat: implement network interfaces list API
To be used in the interactive installer to configure networking.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
2020-11-27 10:48:45 -08:00
Andrey Smirnov
9a32e34cb1 feat: implement apply configuration without reboot
This allows config to be written to disk without being applied
immediately.

Small refactoring to extract common code paths.

At first, I tried to implement this via the sequencer, but looks like
it's too hard to get it right, as sequencer lacks context and config to
be written is not applied to the runtime.

Fixes #2828

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-11-23 12:42:44 -08:00
Andrey Smirnov
7767a41d4a feat: set interface MTU in DHCP mode even if DHCP is not successful
Fixes #2789

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-11-19 10:59:21 -08:00
Seán C McCord
5d4d179cd8 feat: support ipv6 routes
While IPv6 were mostly supported already, there was a single segment in
the interface setup which forced everything into an IPv4 route.
This limitation has been removed.

In so doing, route metrics have been cleaned up a small amount.
This change allows the specification of the route metric from the
config.

Fixes #2772

Signed-off-by: Seán C McCord <ulexus@gmail.com>
2020-11-17 13:11:26 -08:00
Andrey Smirnov
a2efa44663 chore: enable gci linter
Fixes were applied automatically.

Import ordering might be questionable, but it's strict:

* stdlib
* other packages
* same package imports

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-11-09 08:09:48 -08:00
Andrey Smirnov
8560fb9662 chore: enable nlreturn linter
Most of the fixes were automatically applied.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-11-09 06:48:07 -08:00
Andrew Rynhard
562ab1d572 chore: update golangci-lint
Brings in the latest version of golangci-lint and addresses errors.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
2020-11-02 20:34:05 -08:00
Spencer Smith
8b5406c889 chore: move to newer release of rtnetlink with fn args
This PR makes use of a new merge into the upstream rtnetlink library
that introduces functional args for adding routes.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-10-22 06:56:22 -07:00
Andrey Smirnov
16b6d344de chore: bump module dependencies in go.mod
This covers most of the packages except for those we have to keep on
hold (etcd and grpc because of etcd).

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-10-20 08:09:42 -07:00
Spencer Smith
4c47fa259c feat: support MTU and route changes for DHCP
This PR updates the behavior of our machine configs with respect to
DHCP-enabled interfaces. Now, if MTU is specified by the user, that
value will take precedence over any setting provided by the DHCP server.

Additionally, any routes specified will be appended to routes specified
by the DHCP server.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-10-16 17:22:47 -07:00
Spencer Smith
7bc3fcf77d feat: support metric values for DHCP
This PR adds a "DHCPOptions" field to the config. This field contains a
single subfield currently, "RouteMetric". Setting this well ensure that
any routes provided from the DHCP server are given this metric upon
injection into the routing table.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-10-16 08:29:04 -07:00
Artem Chernyshev
b53fc45e08 chore: add Context as param to some methods of Platform interface
Context is passed there for proper cancellation and timeouts.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
2020-10-07 14:40:10 -07:00
Spencer Smith
621bda47fe feat: allow for link local networking
This PR allows for the ability to specify neither CIDR nor DHCP in the
talos machine config. The result here should allow for things like SLAAC
addressing with ipv6.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-09-17 09:48:10 -07:00
Seán C McCord
896745a6dd fix: gracefully handle invalid interfaces in bond
An invalid interface set as a bond's subinterface should produce an
error, but it should not panic.

Signed-off-by: Seán C McCord <ulexus@gmail.com>
2020-09-17 01:44:51 -07:00
Andrey Smirnov
f6ecf000c9 refactor: extract packages loadbalancer and retry
This removes in-tree packages in favor of:

* github.com/talos-systems/go-retry
* github.com/talos-systems/go-loadbalancer

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-09-02 13:46:22 -07:00
Andrew Rynhard
d4f103ffcb fix: pass config via stdin
In order to perform upgrades the way we would like, it is important that
we avoid any bind mounts into containers. This change ensures that all
system services get their config via stdin.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
2020-08-20 15:26:13 -07:00
Andrey Smirnov
bddd4f1bf6 refactor: move external API packages into machinery/
This moves `pkg/config`, `pkg/client` and `pkg/constants`
under `pkg/machinery` umbrella.

And `pkg/machinery` is published as Go module inside Talos repository.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-08-17 09:56:14 -07:00
Andrey Smirnov
2697b99b7d refactor: extract pkg/net as github.com/talos-systems/net
This extracts common package as new module/repository.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-08-14 11:04:50 -07:00
Andrew Rynhard
92523bc422 refactor: remove structs from config provider
This make the config provider a pure interface definition by removing
all concrete internal types, and making them an interface.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
2020-08-06 13:21:41 -07:00
Andrey Smirnov
47608fb874 refactor: make pkg/config not rely on machined/../internal/runtime
This makes `pkg/config` directly importable from other projects.

There should be no functional changes.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-07-29 12:40:12 -07:00
Andrey Smirnov
41d5f7859a chore: update golangci-lint to 1.28.3
Fixes #2272

`gofumpt` is now included into `golangci-lint`, but not the
`gofumports`, so we keep it using it as separate binary, but we keep
versions in sync with `golangci-lint`.

This contains fixes from:

* `gofumpt` (automated, mostly around octal constants)
* `exhaustive` in `switch` statements
* `noctx` (adding context with default timeout to http requests)

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-07-16 08:05:42 -07:00
Andrew Rynhard
a5a2d959ed feat: upgrade runc to v1.0.0-rc90
This updates runc to the same version vendored by containerd.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
2020-07-02 13:19:33 -07:00
Andrey Smirnov
686dcc6743 chore: enable 'testpackage' linter
This linter makes sure tests are excercising only public package API.

I fixed all the tests which touch only public API of the packages. For
other test packages I added proper `//nolint` directive.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-06-30 16:42:28 -07:00
Andrey Smirnov
81d1c2bfe7 chore: enable godot linter
Issues were fixed automatically.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-06-30 10:39:56 -07:00
Spencer Smith
d57c97fdb6 feat: allow ability to create dummy nics
This PR will introduce a new field to v1alpha1 configs that allows users
to set `dummy: true` when specifying interfaces. If present, we will
create a dummy interface with the CIDR information given. This is useful
for users that don't want to use loopback for things like ECMP (or want
more than one dummy interface).

The created dummy interface looked like this with `ip a`:

```
3: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 66:4a:e3:5f:38:10 brd ff:ff:ff:ff:ff:ff
    inet 10.254.0.5/32 brd 10.254.0.5 scope global dummy0
       valid_lft forever preferred_lft forever
```

Will close #2186.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-06-17 17:15:07 -04:00
Frederik Schwan
f57d05e02a fix: ipv6 static default gateway not set if gateway is a LL unicast address
The source address is set by default, which leads to RNETLINK
errors, when the Global Unicast Address is passed as a Source
to a LL Unicast Gateway. Errors of RTNETLINK are now logged.

Signed-off-by: Frederik Schwan <frederik.schwan@linux.com>
2020-04-29 18:23:37 -07:00
Andrew Rynhard
49307d554d refactor: improve machined
This is a rewrite of machined. It addresses some of the limitations and
complexity in the implementation. This introduces the idea of a
controller. A controller is responsible for managing the runtime, the
sequencer, and a new state type introduced in this PR.

A few highlights are:

- no more event bus
- functional approach to tasks (no more types defined for each task)
  - the task function definition now offers a lot more context, like
    access to raw API requests, the current sequence, a logger, the new
    state interface, and the runtime interface.
- no more panics to handle reboots
- additional initialize and reboot sequences
- graceful gRPC server shutdown on critical errors
- config is now stored at install time to avoid having to download it at
  install time and at boot time
- upgrades now use the local config instead of downloading it
- the upgrade API's preserve option takes precedence over the config's
  install force option

Additionally, this pulls various packes in under machined to make the
code easier to navigate.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-04-28 08:20:55 -07:00
Andrew Rynhard
37a7906f09 chore: fix markdown linting issues
This fixes random markdown linting issues. The previous `sentences-per-line`
library seems to be broken now, and unmaintained. This moves to using
`textlint` instead.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-04-26 20:38:03 -07:00
Spencer Smith
ae0ed9ddc9 fix: ensure ordering of interfaces when deciding hostname
This PR will fix some unexpected behavior where we were using Interfaces
as an unordered map, which led to varying behavior with hostname
determination. We will now go through the list of interfaces
alphabetically by name.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-04-16 12:18:34 -07:00
Spencer Smith
38609bf581 feat: introduce ability to specify extra hosts in /etc/hosts
This PR will allow users to configure /etc/hosts through the network
config section, as opposed to having to use a file append operation.

Example usage might look something like:

```
...
...
machine:
  ...
  ...
  network:
    extraHostEntries:
      - ip: 192.168.1.100
        aliases:
          - test
          - test.wtf.bbq
...
...
```

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-04-03 12:17:55 -04:00
Andrew Rynhard
c144484a44 fix: don't use ARP table for networkd health check
We saw strange behavior in this health check, and think that it is due
to ARP table cache. In practice, the health check caused nodes to hang.
We decided to not use the ARP table to determine the health of networkd.
The fact that networkd can respond to the health API should be
sufficient enough since network will fail to start upon any error in the
initial setup of the network.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-03-26 12:21:35 -07:00
Niklas Wik
0824e500b2 feat: initial work for supporting vlans
Adding VLAN as option to machine config under devices.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

feat: Add addressing support for VLAN devices.

- Refactors static addressing to not be dependent on machine.Device

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

feat: Add addressing support for VLAN devices.

- Support of VLAN being the default network to use by removing need of addressing on master device.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: Fix the fmt of go files

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: refactor based on review comment.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: remove unused function

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

feat: initial work for supporting vlans

Adding VLAN as option to machine config under devices.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

feat: Add addressing support for VLAN devices.

- Refactors static addressing to not be dependent on machine.Device

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

feat: Add addressing support for VLAN devices.

- Support of VLAN being the default network to use by removing need of addressing on master device.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: Fix the fmt of go files

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: refactor based on review comment.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: fix test case function arguments

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: Add log for debugging address configuration failures

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: fix lint issues.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: fix the lint error.

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>

fix: Fix when addressing set with kernel options

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>
2020-03-23 17:08:39 -07:00
Andrey Smirnov
5342701f93 fix: update rtnetlink checks for bit masks
According to `rtnetlink(7)` field `state` is a bitmask of states, so
update the check to test accordingly.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-03-23 07:07:30 -07:00
Andrew Rynhard
b6698747bc fix: skip links without a carrier
This change ensures that we avoid setting up interfaces without a
carrier.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-03-13 15:07:15 -07:00
Andrew Rynhard
fa569bbd76 test: add test for empty hostname option
This adds a test for a case when a DHCP response contains a domain name,
but not a hostname.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-03-11 07:02:14 -07:00
Andrew Rynhard
9b47c049ef fix: ensure hostname is never empty
This fixes a case when the domain name DHCP option is set, but hostname
is missing, causing the node to be setup without a hostname.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-03-10 09:45:06 -07:00
Spencer Smith
12bfd8dd94 feat: allow for persistence of config data
This PR will allow users to set the `persist: true` value in their
config data to tell talos not to re-pull the config data at each reboot.
The default will still remain as a "pull every time" methodolgy in order
to encourage immutability by default.

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-03-06 11:42:00 -05:00
Andrew Rynhard
64b5b32732 refactor: use go-procfs
This makes use of the external procfs pacakge that is based on the
pacakge we are removing here.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-02-19 15:58:57 -08:00
Andrew Rynhard
fcaed8b0dd fix: don't proxy gRPC unix connections
The default gRPC dialer honors proxy environment variables, which causes
local unix socket connections to attempt to go through the proxy. This
fixes that by using a custom dialer.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
2020-02-10 05:37:50 -08:00
Seán C McCord
5f3485979a fix: do not add empty netconf
When `ip=dhcp` (as well as a few other conditions), the
buildKernelOptions function returns empty.  In these cases, this empty
network config should not be added to the common list for iteration.

fixes #1869

Signed-off-by: Seán C McCord <ulexus@gmail.com>
2020-02-10 05:26:38 -08:00
Andrey Smirnov
01d696ed10 chore: update golangci-lint-1.23.3
`gomnd` disabled, as it complains about every number used in the code,
and `wsl` became much more thorough.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-04 08:56:39 -08:00
Brad Beam
a39cd81b8f chore(networkd): Report on errors during interface configuration
This DRYs up the interface configuration and adds in an error channel to capture
any issues that come up from interface configuration. These errors are still
treated as non-fatal, but should provide some additional insight.

Signed-off-by: Brad Beam <brad.beam@b-rad.info>
2020-02-03 12:46:37 -08:00
Brad Beam
e9113537f9 feat(networkd): Make healthcheck perform a check
This implements an actual health check for networkd. We use the arp table ( ip neighbors )
to determine if the machine is actively sending traffic. We should see at least one entry
with a REACHABLE/STALE/DELAY state during normal operating conditions.

Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
2020-02-03 11:01:00 -08:00
Brad Beam
4593c4f727 fix(networkd): fix ticker leak
Call ticker.Stop() to prevent leak.

Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
2020-01-29 10:05:47 -08:00
Brad Beam
88df1b50b8 feat(networkd): Add health api
This introduces a health/ready api for networkd. This
will allow us to better determine the state of networkd
and allow for some level of monitoring.

Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
2020-01-29 09:09:27 -06:00
Andrey Smirnov
cebd88f77c fix: parse correctly kernel command line missing DNS config
If nameserver is missing, `net.ParseIP` parses it as `nil` `net.IP` and
later on this `<nil>` address is pushed to `resolv.conf`.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-01-27 21:14:05 +03:00
Brad Beam
93218687ec fix(networkd): Fix incorrect resolver settings
This modifies the way the hostname gets set. Previously, we would run
through the entire addressing and resolver configuration and then set the
hostname. This is problematic because the resolver depends on the functionality
of Hostname() ( resolver configuration relies on the domainname of the host ).

Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
2020-01-17 09:47:54 -05:00
Brad Beam
3dff2b234d fix(networkd): Set hostname properly for dhcp when no hostname option is returned
This fixes a condition where a dhcp response does not provide a hostname. Previously
this would cause the default hostname ( talos-127-0-1-1 ) to be used. This catches
the condition and changes it to compute the hostname via talos-ip.

Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
2020-01-16 09:03:47 -06:00