Skip to content

Commit

Permalink
[ci skip] 2019.02.04-1679
Browse files Browse the repository at this point in the history
  • Loading branch information
cybozu-neco committed Feb 4, 2019
2 parents fde69c0 + 7d1dd63 commit 6227a8d
Show file tree
Hide file tree
Showing 76 changed files with 1,273 additions and 698 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ VERSION = 0.0.1-master
DEST = .
DEB = neco_$(VERSION)_amd64.deb
BIN_PKGS = ./pkg/neco
SBIN_PKGS = ./pkg/neco-updater ./pkg/neco-worker ./pkg/sabakan-serf-handler ./pkg/setup-hw
SBIN_PKGS = ./pkg/neco-updater ./pkg/neco-worker ./pkg/sabakan-serf-handler

all:
@echo "Specify one of these targets:"
Expand Down Expand Up @@ -65,8 +65,7 @@ $(DEB):
GOBIN=$(SBINDIR) go install -tags='$(GOTAGS)' $(SBIN_PKGS)
mkdir -p $(SHAREDIR)
cp etc/* $(SHAREDIR)
go install -tags='$(GOTAGS)' ./pkg/fill-asset-name
fill-asset-name ignitions $(SHAREDIR)/ignitions
cp -a ignitions $(SHAREDIR)
mkdir -p $(DOCDIR)
cp README.md LICENSE $(DOCDIR)
chmod -R g-w $(WORKDIR)
Expand Down
18 changes: 9 additions & 9 deletions artifacts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions artifacts_new.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions artifacts_release.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 5 additions & 11 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import "path/filepath"

const systemdDir = "/etc/systemd/system"

// SabakanPublicImages is the list of container image names to be uploaded to sabakan.
var SabakanPublicImages = []string{"serf", "coil", "squid"}

// SabakanPrivateImages is the list of private container image names to be uploaded to sabakan.
// TODO: Update this slice when the setup-hw container is created
//var SabakanPrivateImages = []string{"omsa"}
var SabakanPrivateImages []string
// SabakanImages is the list of container image names to be uploaded to sabakan.
var SabakanImages = []string{"setup-hw", "serf", "coil", "squid"}

// RktImages is the list of container image names to be run as rkt containers.
//var RktImages = []string{"cke", "etcd", "omsa", "sabakan", "serf", "vault", "hyperkube"}
var RktImages = []string{"cke", "etcd", "sabakan", "serf", "vault", "hyperkube"}
var RktImages = []string{"cke", "etcd", "setup-hw", "sabakan", "serf", "vault", "hyperkube"}

// Neco params
const (
Expand Down Expand Up @@ -59,9 +53,9 @@ const (
VaultPrefix = "/vault/"
)

// OMSA params
// setup-hw params
const (
OMSAService = "omsa"
SetupHWService = "setup-hw"
)

// Etcdpasswd params
Expand Down
18 changes: 11 additions & 7 deletions dctest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ DHCP_JSON = $(SABAKAN_DIR)/dhcp.json
OLDVER = 0.0.1
NEWVER = 0.0.2
AUTOCONFIG = $(SABAKAN_DIR)/auto-config
BMC_USER = $(SABAKAN_DIR)/bmc-user.json
OLD_DEB = $(SABAKAN_DIR)/neco_$(OLDVER)_amd64.deb
NEW_DEB = $(SABAKAN_DIR)/neco_$(NEWVER)_amd64.deb
SABAKAN_CONTENTS = $(AUTOCONFIG) $(OLD_DEB) $(NEW_DEB)
TEST_DEPS = $(OUTPUT)/$(CUSTOM_UBUNTU) $(AUTOCONFIG) $(BMC_USER) $(OPERATION_SSH_DIR)
SSH_PRIVKEY = $(realpath ./dctest_key)
BOB_PRIVKEY = $(realpath ./bob_key)
BOB_PUBKEY = $(realpath ./bob_key.pub)
Expand All @@ -55,13 +56,16 @@ $(OUTPUT)/$(CUSTOM_UBUNTU): $(CUSTOM_UBUNTU)
$(DHCP_JSON):
$(GOPATH)/bin/placemat-menu -f $(MENU) -o $(OUTPUT)

$(SABAKAN_DIR)/auto-config: auto-config $(DHCP_JSON)
$(AUTOCONFIG): auto-config $(DHCP_JSON)
cp $< $@

$(SABAKAN_DIR)/neco_$(OLDVER)_amd64.deb: $(OPERATION_SSH_DIR)
$(BMC_USER): bmc-user.json $(DHCP_JSON)
cp $< $@

$(OLD_DEB): $(OPERATION_SSH_DIR)
cd ..; make deb VERSION=$(OLDVER) DEST=$(realpath $(SABAKAN_DIR))

$(SABAKAN_DIR)/neco_$(NEWVER)_amd64.deb: $(OPERATION_SSH_DIR)
$(NEW_DEB): $(OPERATION_SSH_DIR)
cd ..; make deb VERSION=$(NEWVER) DEST=$(realpath $(SABAKAN_DIR)) TAGS=new

# workaround for placemat-menu
Expand All @@ -70,12 +74,12 @@ $(OPERATION_SSH_DIR):
cp dctest_key $(OPERATION_SSH_DIR)/boot_key

# Targets
test: $(OUTPUT)/$(CUSTOM_UBUNTU) $(SABAKAN_CONTENTS)
test: $(TEST_DEPS) $(OLD_DEB) $(NEW_DEB)
sudo rm -rf $(PLACEMAT_DATADIR)
sudo rm -rf $(VM_SHARED_DIR)
./test.sh

placemat: $(OUTPUT)/$(CUSTOM_UBUNTU) $(SABAKAN_CONTENTS)
placemat: $(TEST_DEPS) $(OLD_DEB) $(NEW_DEB)
sudo rm -rf $(PLACEMAT_DATADIR)
sudo rm -rf $(VM_SHARED_DIR)
sudo systemd-run --unit=placemat.service $(PLACEMAT) -enable-virtfs $(realpath output/cluster.yml)
Expand All @@ -91,7 +95,7 @@ stop:
test-light:
./test-light.sh "$(TARGET)"

test-release: $(OUTPUT)/$(CUSTOM_UBUNTU) $(AUTOCONFIG) $(OPERATION_SSH_DIR)
test-release: $(TEST_DEPS)
cd ..; make deb VERSION=$(OLDVER) DEST=$(realpath $(SABAKAN_DIR)) TAGS=release
sudo rm -rf $(PLACEMAT_DATADIR)
sudo rm -rf $(VM_SHARED_DIR)
Expand Down
13 changes: 13 additions & 0 deletions dctest/bmc-user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": {
"password": {
"raw": "raw password"
}
},
"power": {
"password": {
"hash": "hashed_secret",
"salt": "salt for hash"
}
}
}
1 change: 1 addition & 0 deletions dctest/bootstrap/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var _ = Describe("Test Neco bootstrap", func() {
Context("sabakan", dctest.TestSabakan)
// uploading contents to sabakan must be done after sabakan configuration.
Context("contents", dctest.UploadContents)
Context("machines", dctest.TestMachines)
Context("cke", func() {
dctest.TestCKE("0.0.1")
})
Expand Down
13 changes: 0 additions & 13 deletions dctest/cke.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ type serfMemberContainer struct {
// TestCKE tests CKE
func TestCKE(version string) {
It("should generates cluster.yml automatically", func() {
vaultToken := getVaultToken()

By("initialize Vault for CKE")
execSafeAt(boot0, "env", "VAULT_TOKEN="+vaultToken, "ckecli", "vault", "init")

By("generating SSH key for worker nodes")
execSafeAt(boot0, "neco", "ssh", "generate")

By("regenerating ignitions and registering machines")
execSafeAt(boot0, "sabactl", "ignitions", "delete", "worker", version)
execSafeAt(boot0, "neco", "sabakan-upload", "--ignitions-only")
execSafeAt(boot0, "sabactl", "machines", "create", "-f", "/mnt/machines.json")

By("setting configurations")
execSafeAt(boot0, "ckecli", "constraints", "set", "control-plane-count", "3")
execSafeAt(boot0, "ckecli", "constraints", "set", "minimum-workers", "2")
Expand Down
9 changes: 1 addition & 8 deletions dctest/contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@ func TestContents() {
for _, image := range neco.SystemContainers {
Expect(assets).To(ContainElement(neco.ACIAssetName(image)))
}
images := neco.SabakanPublicImages
_, err = os.Stat("../secrets")
secretExists := err == nil

if secretExists {
images = append(images, neco.SabakanPrivateImages...)
}
for _, name := range images {
for _, name := range neco.SabakanImages {
image, err := neco.CurrentArtifacts.FindContainerImage(name)
Expect(err).NotTo(HaveOccurred())
Expect(assets).To(ContainElement(neco.ImageAssetName(image)))
Expand Down
1 change: 1 addition & 0 deletions dctest/functions/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var _ = Describe("Test Neco functions", func() {
})
Context("upgrade", dctest.TestUpgrade)
Context("join/remove", dctest.TestJoinRemove)
Context("machines", dctest.TestMachines)
Context("cke", func() {
dctest.TestCKE("0.0.2")
})
Expand Down
18 changes: 6 additions & 12 deletions dctest/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestInit() {
It("should success initialize cke", func() {
token := getVaultToken()

By("initializing etcd for CKE")
execSafeAt(boot0, "neco", "init", "cke")

for _, host := range []string{boot0, boot1, boot2} {
Expand All @@ -106,24 +107,17 @@ func TestInit() {

execSafeAt(host, "systemctl", "-q", "is-active", "cke.service")
}

By("initializing Vault for CKE")
execSafeAt(boot0, "env", "VAULT_TOKEN="+token, "ckecli", "vault", "init")
})

It("should success retrieve cke leader", func() {
stdout := execSafeAt(boot0, "ckecli", "leader")
Expect(stdout).To(ContainSubstring("boot-"))
})

It("should setup hardware", func() {
for _, host := range []string{boot0, boot1, boot2} {
stdout, stderr, err := execAt(host, "sudo", "setup-hw")
if err != nil {
log.Error("setup-hw", map[string]interface{}{
"host": host,
"stdout": string(stdout),
"stderr": string(stderr),
})
Expect(err).NotTo(HaveOccurred())
}
}
It("should generate SSH key for worker nodes", func() {
execSafeAt(boot0, "neco", "ssh", "generate")
})
}
34 changes: 34 additions & 0 deletions dctest/machines.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dctest

import (
"github.com/cybozu-go/log"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

// TestMachines tests machine control functions.
func TestMachines() {
It("should register machines to sabakan", func() {
execSafeAt(boot0, "sabactl", "machines", "create", "-f", "/mnt/machines.json")
})

It("should put BMC/IPMI settings", func() {
execSafeAt(boot0, "neco", "bmc", "config", "set", "bmc-user", "/mnt/bmc-user.json")
execSafeAt(boot0, "neco", "bmc", "config", "set", "ipmi-user", "cybozu")
execSafeAt(boot0, "neco", "bmc", "config", "set", "ipmi-password", "cybozu")
})

It("should setup boot server hardware", func() {
for _, host := range []string{boot0, boot1, boot2} {
stdout, stderr, err := execAt(host, "sudo", "neco", "bmc", "setup-hw")
if err != nil {
log.Error("setup-hw", map[string]interface{}{
"host": host,
"stdout": string(stdout),
"stderr": string(stderr),
})
Expect(err).NotTo(HaveOccurred())
}
}
})
}
2 changes: 2 additions & 0 deletions debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ configure() {
systemctl enable ${s}.service
systemctl start ${s}.service
done

/usr/bin/neco completion > /etc/bash_completion.d/neco
}

if test "$1" = "configure"; then
Expand Down
6 changes: 3 additions & 3 deletions docs/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Artifacts
Artifacts `artifacts.go` is a collection of components which are tested by [dctest](../dctest/).
It is given as a go file with structs to include neco binaries see details in [types.go](../types.go).

**This file is generated by `generate-artifacts` command. PLEASE DO NOT EDIT MANUALLY**
**This file is generated by `generate-artifacts` command. PLEASE DO NOT EDIT MANUALLY**

There are two artifacts files.

Expand All @@ -18,5 +18,5 @@ There are two artifacts files.

- [artifacts_release.go](../artifacts.go)

For CI. The job updates it using `generate-artifacts --release`.
The developers are PROHIBITED to modify it using the command to prevent merge conficts in CI flow.
For CI. The job updates it using `generate-artifacts --release`.
The developers are PROHIBITED to modify it using the command to prevent merge conflicts in CI flow.
Loading

0 comments on commit 6227a8d

Please sign in to comment.