Merge pull request #543 from coreos/remove-pixiecore

Remove pixiecore handler and support
This commit is contained in:
Dalton Hubble
2017-05-22 17:51:21 -07:00
committed by GitHub
6 changed files with 4 additions and 149 deletions

View File

@@ -4,6 +4,8 @@ Notable changes between releases.
## Latest
* Remove pixiecore support (deprecated in v0.5.0)
### Examples
* Upgrade self-hosted Kubernetes cluster examples to v1.6.4

View File

@@ -4,7 +4,7 @@
Physical machines [network boot](network-booting.md) in an network boot environment with DHCP/TFTP/DNS services or with [coreos/dnsmasq](../contrib/dnsmasq).
`matchbox` serves iPXE, GRUB, or Pixiecore boot configs via HTTP to machines based on Group selectors (e.g. UUID, MAC, region, etc.) and machine Profiles. Kernel and initrd images are fetched and booted with Ignition to install CoreOS. The "first boot" Ignition config if fetched and CoreOS is installed.
`matchbox` serves iPXE or GRUB configs via HTTP to machines based on Group selectors (e.g. UUID, MAC, region, etc.) and machine Profiles. Kernel and initrd images are fetched and booted with Ignition to install CoreOS. The "first boot" Ignition config if fetched and CoreOS is installed.
CoreOS boots ("first boot" from disk) and runs Ignition to provision its disk with systemd units, files, keys, and more to become a cluster node. Systemd units may fetch metadata from a remote source if needed.

View File

@@ -75,7 +75,7 @@ Profiles reference an Ignition config, Cloud-Config, and/or generic config by na
}
```
The `"boot"` settings will be used to render configs to network boot programs such as iPXE, GRUB, or Pixiecore. You may reference remote kernel and initrd assets or [local assets](#assets).
The `"boot"` settings will be used to render configs to network boot programs such as iPXE or GRUB. You may reference remote kernel and initrd assets or [local assets](#assets).
To use Ignition, set the `coreos.config.url` kernel option to reference the `matchbox` [Ignition endpoint](api.md#ignition-config), which will render the `ignition_id` file. Be sure to add the `coreos.first_boot` option as well.

View File

@@ -1,57 +0,0 @@
package http
import (
"net/http"
"path/filepath"
"context"
"github.com/Sirupsen/logrus"
"github.com/coreos/matchbox/matchbox/server"
pb "github.com/coreos/matchbox/matchbox/server/serverpb"
)
// pixiecoreHandler returns a handler that renders the boot config JSON for
// the requester, to implement the Pixiecore API specification.
// DEPRECATED
func (s *Server) pixiecoreHandler(core server.Server) ContextHandler {
fn := func(ctx context.Context, w http.ResponseWriter, req *http.Request) {
// pixiecore only provides a MAC address label
macAddr, err := parseMAC(filepath.Base(req.URL.Path))
if err != nil {
s.logger.Errorf("unparseable MAC address: %v", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
attrs := map[string]string{"mac": macAddr.String()}
group, err := core.SelectGroup(ctx, &pb.SelectGroupRequest{Labels: attrs})
if err != nil {
s.logger.WithFields(logrus.Fields{
"label": macAddr,
}).Infof("No matching group")
http.NotFound(w, req)
return
}
profile, err := core.ProfileGet(ctx, &pb.ProfileGetRequest{Id: group.Profile})
if err != nil {
s.logger.WithFields(logrus.Fields{
"label": macAddr,
"group": group.Id,
}).Infof("No profile named: %s", group.Profile)
http.NotFound(w, req)
return
}
// match was successful
s.logger.WithFields(logrus.Fields{
"label": macAddr,
"group": group.Id,
"profile": profile.Id,
}).Debug("Matched a Pixiecore config")
s.renderJSON(w, profile.Boot)
}
return ContextHandlerFunc(fn)
}

View File

@@ -1,86 +0,0 @@
package http
import (
"net/http"
"net/http/httptest"
"testing"
"context"
logtest "github.com/Sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/coreos/matchbox/matchbox/server"
"github.com/coreos/matchbox/matchbox/storage/storagepb"
fake "github.com/coreos/matchbox/matchbox/storage/testfakes"
)
func TestPixiecoreHandler(t *testing.T) {
fakeProfile := &storagepb.Profile{
Id: "g1h2i3j4",
Boot: &storagepb.NetBoot{
Kernel: "/image/kernel",
Initrd: []string{"/image/initrd_a", "/image/initrd_b"},
Cmdline: map[string]string{
"a": "b",
"c": "",
},
},
CloudId: "cloud-config.tmpl",
IgnitionId: "ignition.tmpl",
GenericId: "generic.tmpl",
}
store := &fake.FixedStore{
Groups: map[string]*storagepb.Group{testGroupWithMAC.Id: testGroupWithMAC},
Profiles: map[string]*storagepb.Profile{testGroupWithMAC.Profile: fakeProfile},
}
logger, _ := logtest.NewNullLogger()
srv := NewServer(&Config{Logger: logger})
c := server.NewServer(&server.Config{Store: store})
h := srv.pixiecoreHandler(c)
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/"+validMACStr, nil)
h.ServeHTTP(context.Background(), w, req)
// assert that:
// - MAC address parameter is used for Group matching
// - the Profile's NetBoot config is rendered as Pixiecore JSON
expectedJSON := `{"kernel":"/image/kernel","initrd":["/image/initrd_a","/image/initrd_b"],"cmdline":{"a":"b","c":""}}`
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, jsonContentType, w.HeaderMap.Get(contentType))
assert.Equal(t, expectedJSON, w.Body.String())
}
func TestPixiecoreHandler_InvalidMACAddress(t *testing.T) {
logger, _ := logtest.NewNullLogger()
srv := NewServer(&Config{Logger: logger})
c := server.NewServer(&server.Config{Store: &fake.EmptyStore{}})
h := srv.pixiecoreHandler(c)
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/", nil)
h.ServeHTTP(context.Background(), w, req)
assert.Equal(t, http.StatusBadRequest, w.Code)
}
func TestPixiecoreHandler_NoMatchingGroup(t *testing.T) {
logger, _ := logtest.NewNullLogger()
srv := NewServer(&Config{Logger: logger})
c := server.NewServer(&server.Config{Store: &fake.EmptyStore{}})
h := srv.pixiecoreHandler(c)
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/"+validMACStr, nil)
h.ServeHTTP(context.Background(), w, req)
assert.Equal(t, http.StatusNotFound, w.Code)
}
func TestPixiecoreHandler_NoMatchingProfile(t *testing.T) {
store := &fake.FixedStore{
Groups: map[string]*storagepb.Group{fake.Group.Id: fake.Group},
}
logger, _ := logtest.NewNullLogger()
srv := NewServer(&Config{Logger: logger})
c := server.NewServer(&server.Config{Store: store})
h := srv.pixiecoreHandler(c)
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/"+validMACStr, nil)
h.ServeHTTP(context.Background(), w, req)
assert.Equal(t, http.StatusNotFound, w.Code)
}

View File

@@ -55,8 +55,6 @@ func (s *Server) HTTPHandler() http.Handler {
mux.Handle("/boot.ipxe", chain(ipxeInspect()))
mux.Handle("/boot.ipxe.0", chain(ipxeInspect()))
mux.Handle("/ipxe", chain(s.selectProfile(s.core, s.ipxeHandler())))
// Boot via Pixiecore
mux.Handle("/pixiecore/v1/boot/", chain(s.pixiecoreHandler(s.core)))
// Ignition Config
mux.Handle("/ignition", chain(s.selectGroup(s.core, s.ignitionHandler(s.core))))
// Cloud-Config
@@ -75,7 +73,6 @@ func (s *Server) HTTPHandler() http.Handler {
mux.Handle("/boot.ipxe.sig", signerChain(ipxeInspect()))
mux.Handle("/boot.ipxe.0.sig", signerChain(ipxeInspect()))
mux.Handle("/ipxe.sig", signerChain(s.selectProfile(s.core, s.ipxeHandler())))
mux.Handle("/pixiecore/v1/boot.sig/", signerChain(s.pixiecoreHandler(s.core)))
mux.Handle("/ignition.sig", signerChain(s.selectGroup(s.core, s.ignitionHandler(s.core))))
mux.Handle("/cloud.sig", signerChain(s.selectGroup(s.core, s.cloudHandler(s.core))))
mux.Handle("/generic.sig", signerChain(s.selectGroup(s.core, s.genericHandler(s.core))))
@@ -89,7 +86,6 @@ func (s *Server) HTTPHandler() http.Handler {
mux.Handle("/boot.ipxe.asc", signerChain(ipxeInspect()))
mux.Handle("/boot.ipxe.0.asc", signerChain(ipxeInspect()))
mux.Handle("/ipxe.asc", signerChain(s.selectProfile(s.core, s.ipxeHandler())))
mux.Handle("/pixiecore/v1/boot.asc/", signerChain(s.pixiecoreHandler(s.core)))
mux.Handle("/ignition.asc", signerChain(s.selectGroup(s.core, s.ignitionHandler(s.core))))
mux.Handle("/cloud.asc", signerChain(s.selectGroup(s.core, s.cloudHandler(s.core))))
mux.Handle("/generic.asc", signerChain(s.selectGroup(s.core, s.genericHandler(s.core))))