Skip to content

Conversation

@crawford
Copy link
Contributor

This runs bootkube.service and tectonic.service repeatedly until they
succeed. This isn't going to work in its current form (bootkube still
has trouble being restarted) but it gets us closer.

This removes some unneeded code.
Make this look a little more like shell.
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 13, 2018
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 13, 2018
There were a number of strange and unneeded operations being done.
This runs bootkube.service and tectonic.service repeatedly until they
succeed. This isn't going to work in its current form (bootkube still
has trouble being restarted) but it gets us closer.
--output=/assets/kco-bootstrap

cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" /etc/kubernetes/bootstrap-configs
cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" .
Copy link
Contributor

Choose a reason for hiding this comment

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

$PWD vs .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Muscle memory. Both should work.

--output=/assets/kco-bootstrap

cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" /etc/kubernetes/bootstrap-configs
cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" .
Copy link
Contributor

Choose a reason for hiding this comment

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

	cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" /etc/kubernetes/bootstrap-configs
	cp --recursive "$PWD/kco-bootstrap/bootstrap-configs" .

the end goal is to end up at /etc/kubernetes/bootstrap-configs;
why do both?
or atleast copy to $PWD and then copy $PWD one to /etc/kubernetes/bootstrap-configs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The second cp was to satisfy the conditional above. I thought those files in /etc were removed by kubelet. If not, we could just read /etc in the conditional.

Copy link
Contributor

@abhinavdahiya abhinavdahiya Sep 13, 2018

Choose a reason for hiding this comment

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

No the /etc/kubernetes/bootstrap-configs is not deleted by kubelet.

It is read by bootstrap-control-plane components

Copy link
Contributor

Choose a reason for hiding this comment

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

We can

  • Change conditional to /etc and drop cp .
  • Keep it as is, no big deal

Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping it as is, seems okay for now. 👌

@abhinavdahiya
Copy link
Contributor

@crawford few comments otherwise /lgtm.

@crawford
Copy link
Contributor Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 13, 2018
@abhinavdahiya
Copy link
Contributor

/lgtm

/hold cancel

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Sep 13, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, crawford

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,crawford]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

mkdir -p /etc/ssl/mcs/
mkdir --parents /etc/kubernetes/manifests/
mkdir --parents /etc/mcc/bootstrap/
mkdir --parents /etc/ssl/mcs/
Copy link
Member

Choose a reason for hiding this comment

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

I'm generally in favor of long optipns and spelling things out to make source more readable. But only -p is in POSIX, so I think we want to roll this particular change back for portability.

# 2. read the default MachineConfigPools rendered by MachineConfigOperator
# 3. read any additional MachineConfigs that are needed for the default MachineConfigPools.
cp -r "$PWD/mco-bootstrap/manifests" /etc/mcc/bootstrap/manifests
cp --recursive "$PWD/mco-bootstrap/manifests" /etc/mcc/bootstrap/manifests
Copy link
Member

Choose a reason for hiding this comment

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

News to me, but POSIX.1-2017 dropped -r in favor of -R and does not define a long form. They give some notes on -r vs. -R in the RATIONALE section.

@@ -1,30 +1,20 @@
#!/bin/sh
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with Bash when we need its extensions, but I'd rather stick to the POSIX shell where possible. Is this just for your <<< here-strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep.

set -e

if echo "$out" | grep -q "AlreadyExists"
if grep --quiet "AlreadyExists" <<< "$out"
Copy link
Member

Choose a reason for hiding this comment

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

POSIX only defines -q.

And while I'd prefer the here-string form if it was in POSIX, the difference isn't large enough to make it worth breaking with POSIX-compat (for me, anyway).

if grep --quiet "AlreadyExists" <<< "$out"
then
echo "$out, skipping"
(>&2 echo "$out, skipping")
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need a subshell here. Do you remember why you added it?

And while I prefer echo "..." >&2 (looks like pushing the string into a pipe ;), I've also seen echo >&2 "...". I haven't seen folks leading with the redirect (or I see it so rarely I'vd forgotten ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was worried about the side effect of rewriting that fd, so I put it in a subshell. Let me test this the way you'd written it and follow up.


stat=$(echo "$out"| tail -n +2 | grep -v '^Running')
if [ -z "$stat" ]
if ! grep --invert-match '^Running' <<< "$out"
Copy link
Member

Choose a reason for hiding this comment

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

Only -v is in POSIX.

And you might want to dump grep's stdout into /dev/null, unless you're intentionally writing it to let the caller know where we're at.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Printing the progress is an intentional side-effect.

kubectl create --filename updater/app-version-kind.yaml
kubectl create --filename updater/migration-status-kind.yaml

kubectl --namespace=tectonic-system get customresourcedefinition channeloperatorconfigs.tco.coreos.com
Copy link
Member

Choose a reason for hiding this comment

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

Now that you've dropped wait_for_crd, is the idea that the script will die here if your one-shot request fails, and we'll run through it all again when systemd gives it another pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the equivilent to wait_for_crd. kubelet will loop until it's successful.


cp --recursive "$PWD/bootstrap-configs" /etc/kubernetes/bootstrap-configs
podman rm --force etcd-signer
rm --force /etc/kubernetes/manifests/machineconfigoperator-bootstrap-pod.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For RHCOS-only scripts, should we care? For developer scripts, I agree that we should stick with POSIX.

Copy link
Member

Choose a reason for hiding this comment

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

For RHCOS-only scripts, should we care?

Is this RHCOS-only? Is there a BYO-something that might swap out a different POSIX-compat rm (or cp, etc., see the other comments in my review) that doesn't support the long options (e.g. BusyBox)? Using -f instead of --force seems like a small enough price to avoid having to worry about that sort of thing ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, bootstrap will always be an OS we control. BYOH will use a different method for bootstrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants