Skip to content

Allow make push to replace and relaunch Appliance components#7164

Closed
gigawhitlocks wants to merge 9 commits intovmware:masterfrom
gigawhitlocks:hackathon
Closed

Allow make push to replace and relaunch Appliance components#7164
gigawhitlocks wants to merge 9 commits intovmware:masterfrom
gigawhitlocks:hackathon

Conversation

@gigawhitlocks
Copy link
Contributor

Hackathon task

Makefile Outdated
test: install-govmomi portlayerapi $(TEST_JOBS)

push:
./infra/scripts/replace-running-components.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Use $(BASE_DIR)//infra/scripts/replace-running-components.sh - I know it's not consistent throughout the Makefile currently but it should be.


set -e

for x in $(echo GOVC_USERNAME GOVC_PASSWORD VCH_NAME GOVC_URL GOPATH GOVC_INSECURE); do
Copy link
Contributor

Choose a reason for hiding this comment

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

Use govc env to dump out the necessary fields and check them. This doesn't care how the user/password are supplied so is tolerant to more configurations.

echo "GOVC_PASSWORD: password on ESX/vCenter target"
echo "VCH_NAME: name of VCH; matches --name argument for vic-machine"
echo "GOVC_URL: IP or FQDN of your vCenter/ESX target"
echo "GOPATH: your GOPATH, obviously"
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use GOPATH - it's not actually needed in what we're doing.
You can use the following to determine the directory of the script and then go relative from there:

BASE_DIR=$(dirname $(readlink -f "$BASH_SOURCE"))

BASE_DIR=$(dirname $(readlink -f "$BASH_SOURCE"))

done

function get-thumbprint () {
openssl s_client -connect $GOVC_URL:443 </dev/null 2>/dev/null \
Copy link
Contributor

Choose a reason for hiding this comment

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

check out govc about.cert --help, particularly govc about.cert --thumbprint
It removes the additional dependency on having openssl available (I know it's very common but I'd prefer to assume govc.

| cut -d= -f2
}

$GOPATH/src/github.com/vmware/vic/bin/vic-machine-linux debug --target=$GOVC_URL --name=$VCH_NAME --user=$GOVC_USERNAME --password=$GOVC_PASSWORD --thumbprint=$(get-thumbprint)
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend either explicitly specifying the compute-resource or using the --id parameter instead. This has the potential for name conflicts if in VC

on-vch mv /tmp/$1 /sbin/$1
on-vch chmod 755 /sbin/$1
pid=$(on-vch ps -e --format='pid,args' | grep $1 | grep -v grep | awk '{print $1}')
on-vch kill -9 $pid
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not in yet, but I expect to merge #6943 soon. That moves to providing for a clean shutdown via SIGTERM. Just a note that we should update this in whichever merges second.

replace-component vic-init
else
replace-component $1
replace-component vic-init
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be necessary - I tried it on the flight for other reasons. It takes a couple of seconds due to the throttling but it happily relaunched the docker-personality for me.
We should dig into what's actually occurring and not mask it with this.

replace-component vic-init
fi

on-vch vic-init &
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise the systemd unit should be configured for restart if it's not currently which would negate the need for an explicit launch.

@gigawhitlocks
Copy link
Contributor Author

Thanks for the feedback @hickeng I'll clean this up

hackathon code: all the shortcuts LOL

@gigawhitlocks
Copy link
Contributor Author

OK @hickeng that should address all of your feedback except the systemd unit (which I'll take care of in the morning when I'm warming up before I get back on the tar issue again) and also I did a bit of cleanup/organization/polish, took some liberties with allowing the user to provide the VCH name instead of the ID and as long as it comes back unique it will figure out the ID and continue, but if the ID is provided it'll just use that instead, and adjusted the error handling to be a bit better.

VIC_ID=$($VIC_DIR/bin/vic-machine-linux ls --target=$target --user=$username --password=$password --thumbprint=$(get-thumbprint) | grep $VIC_NAME | awk '{print $1}')
fi

echo "Enabling SSH access on your VCH"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

feck

exit 1
fi

username=$(govc env | grep GOVC_USERNAME | cut -d= -f2)
Copy link

Choose a reason for hiding this comment

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

This will be problem for those of us who define GOVC_URL="user:pass@targeturl". We could try to grab user/pass from GOVC_URL if GOVC_USERNAME and GOVC_PASSWORD are not defined, but I see you do echo usage info explaining this.

Copy link
Contributor

Choose a reason for hiding this comment

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

govc env should break those out already if you only assign GOVC_URL so this should be safe from this concern. By using govc env it should always have all of the required fields for GOVC populated for consumption, which should avoid a "something isn't set right" style of error.

Copy link

Choose a reason for hiding this comment

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

oh, interesting. I didn't know about this option.

@gigawhitlocks
Copy link
Contributor Author

ahahaha i messed up my repo and need to close and re-open this, sorry

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants