Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1748452: data/bootstrap: Replace openshift.sh with cluster-bootstrap #1381

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/data/bootstrap/files/usr/local/bin/bootkube.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ systemctl restart cri-o.service

mkdir --parents ./{bootstrap-manifests,manifests}

if [ ! -f openshift-manifests.done ]
then
echo "Moving OpenShift manifests in with the rest of them"
cp openshift/* manifests/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fine

touch openshift-manifests.done
fi

if [ ! -f cvo-bootstrap.done ]
then
echo "Rendering Cluster Version Operator Manifests..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARTIFACTS="/tmp/artifacts"

echo "Gathering bootstrap journals ..."
mkdir -p "${ARTIFACTS}/bootstrap/journals"
for service in release-image bootkube openshift kubelet crio approve-csr
for service in release-image bootkube kubelet crio approve-csr
do
journalctl --boot --no-pager --output=short --unit="${service}" > "${ARTIFACTS}/bootstrap/journals/${service}.log"
done
Expand Down
42 changes: 0 additions & 42 deletions data/data/bootstrap/files/usr/local/bin/openshift.sh

This file was deleted.

1 change: 0 additions & 1 deletion data/data/bootstrap/files/usr/local/bin/report-progress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ wait_for_existance() {

echo "Waiting for bootstrap to complete..."
wait_for_existance /opt/openshift/.bootkube.done
wait_for_existance /opt/openshift/.openshift.done

echo "Reporting install progress..."
while ! oc --config="$KUBECONFIG" create -f - <<-EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ wait_for_existance() {

echo "Waiting for bootstrap to complete..."
wait_for_existance /opt/openshift/.bootkube.done
wait_for_existance /opt/openshift/.openshift.done

## remove the routes setup so that we can open up the blackhole
systemctl stop gcp-routes.service
Expand Down
12 changes: 0 additions & 12 deletions data/data/bootstrap/systemd/units/openshift.service

This file was deleted.

4 changes: 2 additions & 2 deletions data/data/bootstrap/systemd/units/progress.service
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Unit]
Description=Report the completion of the cluster bootstrap process
# Workaround for https://github.com/systemd/systemd/issues/1312
Wants=bootkube.service openshift.service
After=bootkube.service openshift.service
Wants=bootkube.service
After=bootkube.service

[Service]
ExecStart=/usr/local/bin/report-progress.sh /opt/openshift/auth/kubeconfig
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {
return fmt.Errorf("invalid Platform")
}

userDataMap := map[string][]byte{"master-user-data": mign.File.Data}
data, err := userDataList(userDataMap)
data, err := userDataSecret("master-user-data", mign.File.Data)
if err != nil {
return errors.Wrap(err, "failed to create user-data secret for master machines")
}
Expand Down
37 changes: 14 additions & 23 deletions pkg/asset/machines/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,25 @@ import (
"github.com/pkg/errors"
)

var userDataListTmpl = template.Must(template.New("user-data-list").Parse(`
kind: List
apiVersion: v1
var userDataTmpl = template.Must(template.New("user-data").Parse(`apiVersion: v1
kind: Secret
metadata:
resourceVersion: ""
selfLink: ""
items:
{{- range $name, $content := . }}
- apiVersion: v1
kind: Secret
metadata:
name: {{$name}}
namespace: openshift-machine-api
type: Opaque
data:
disableTemplating: "dHJ1ZQo="
userData: {{$content}}
{{- end}}
name: {{.name}}
namespace: openshift-machine-api
type: Opaque
data:
disableTemplating: "dHJ1ZQo="
userData: {{.content}}
`))

func userDataList(data map[string][]byte) ([]byte, error) {
encodedData := map[string]string{}
for name, content := range data {
encodedData[name] = base64.StdEncoding.EncodeToString(content)
func userDataSecret(name string, content []byte) ([]byte, error) {
encodedData := map[string]string{
"name": name,
"content": base64.StdEncoding.EncodeToString(content),
}
buf := &bytes.Buffer{}
if err := userDataListTmpl.Execute(buf, encodedData); err != nil {
return nil, errors.Wrap(err, "failed to execute content.UserDataListTmpl")
if err := userDataTmpl.Execute(buf, encodedData); err != nil {
return nil, errors.Wrap(err, "failed to execute user-data template")
}
return buf.Bytes(), nil
}
3 changes: 1 addition & 2 deletions pkg/asset/machines/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ func (w *Worker) Generate(dependencies asset.Parents) error {
}
}

userDataMap := map[string][]byte{"worker-user-data": wign.File.Data}
data, err := userDataList(userDataMap)
data, err := userDataSecret("worker-user-data", wign.File.Data)
if err != nil {
return errors.Wrap(err, "failed to create user-data secret for worker machines")
}
Expand Down