Skip to content

Commit

Permalink
Start packaging compat manager (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaitanyaKulkarni28 authored Feb 11, 2025
1 parent 9b6adf5 commit d68d45b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packaging/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ override_dh_auto_install:
install -d debian/google-guest-agent/lib/systemd/system
install -p -m 0644 gce-workload-cert-refresh.timer debian/google-guest-agent/lib/systemd/system/
if [ -d google-guest-agent ]; then\
install -p -m 0644 google-guest-agent/cmd/google_guest_compat_manager/google_guest_compat_manager debian/google-guest-agent/usr/bin/google_guest_compat_manager;\
install -p -m 0644 google-guest-agent/cmd/google_guest_agent/google_guest_agent debian/google-guest-agent/usr/bin/google_guest_agent_manager;\
install -p -m 0644 google-guest-agent/cmd/ggactl/ggactl_plugin_cleanup debian/google-guest-agent/usr/bin/ggactl_plugin_cleanup;\
fi
Expand All @@ -34,6 +35,7 @@ override_dh_golang:
override_dh_auto_build:
dh_auto_build -O--buildsystem=golang -- -ldflags="-s -w -X main.version=$(VERSION)" -mod=readonly
if [ -d google-guest-agent ]; then\
VERSION=$(VERSION) make -C google-guest-agent cmd/google_guest_compat_manager/google_guest_compat_manager;\
VERSION=$(VERSION) make -C google-guest-agent cmd/google_guest_agent/google_guest_agent;\
VERSION=$(VERSION) make -C google-guest-agent cmd/ggactl/ggactl_plugin_cleanup;\
fi
Expand All @@ -46,12 +48,14 @@ override_dh_systemd_enable:
install -p -m 0644 *.service debian/google-guest-agent/lib/systemd/system/
# Don't include guest agent manager if not building with it.
if [ ! -d google-guest-agent ]; then\
rm -f debian/google-guest-agent/lib/systemd/system/google-guest-compat-manager.service;\
rm -f debian/google-guest-agent/lib/systemd/system/google-guest-agent-manager.service;\
fi
install -d debian/google-guest-agent/lib/systemd/system-preset
install -p -m 0644 *.preset debian/google-guest-agent/lib/systemd/system-preset/
dh_systemd_enable google-guest-agent.service google-startup-scripts.service google-shutdown-scripts.service gce-workload-cert-refresh.timer
if [ -d google-guest-agent ]; then\
dh_systemd_enable google-guest-compat-manager.service;\
dh_systemd_enable google-guest-agent-manager.service;\
fi

Expand All @@ -60,5 +64,6 @@ override_dh_systemd_start:
dh_systemd_start google-guest-agent.service
dh_systemd_start gce-workload-cert-refresh.timer
if [ -d google-guest-agent ]; then\
dh_systemd_start google-guest-compat-manager.service;\
dh_systemd_start google-guest-agent-manager.service;\
fi
16 changes: 15 additions & 1 deletion packaging/googet/agent_install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ $manager_path = '"C:\Program Files\Google\Compute Engine\agent\GCEWindowsAgentMa
$manager_display_name = 'Google Compute Engine Agent Manager'
$manager_description = 'Google Compute Engine Agent Manager'

$compat_manager = 'GCEWindowsCompatManager'
$compat_path = '"C:\Program Files\Google\Compute Engine\agent\GCEWindowsCompatManager.exe"'
$compat_display_name = 'Google Compute Engine Compat Manager'
$compat_description = 'Google Compute Engine Compat Manager'

$initial_config = @'
# GCE Instance Configuration
Expand Down Expand Up @@ -72,11 +77,19 @@ try {
Set-New-Service $name $display_name $description $path
Set-ServiceConfig $name $path

# Guest Agent Manager service
# Guest Agent Manager and Compat Manager service
if ($install_manager) {
Set-New-Service $compat_manager $compat_display_name $compat_description $compat_path
Set-ServiceConfig $compat_manager $compat_path

Set-New-Service $manager_name $manager_display_name $manager_description $manager_path
Set-ServiceConfig $manager_name $manager_path
} else {
if (Get-Service $compat_manager -ErrorAction SilentlyContinue) {
Stop-Service $compat_manager
& sc.exe delete $compat_manager
}

if (Get-Service $manager_name -ErrorAction SilentlyContinue) {
Stop-Service $manager_name
& sc.exe delete $manager_name
Expand All @@ -91,6 +104,7 @@ try {
Restart-Service $name -Verbose

if ($install_manager) {
Restart-Service $compat_manager -Verbose
Restart-Service $manager_name -Verbose
}
}
Expand Down
8 changes: 8 additions & 0 deletions packaging/googet/agent_uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@
Stop-Service GCEAgent -Verbose
& sc.exe delete GCEAgent

$compat_manager = 'GCEWindowsCompatManager'
$name = 'GCEAgentManager'
$cleanup_exe = "C:\Program Files\Google\Compute Engine\agent\ggactl_plugin_cleanup.exe"

# Stop and Delete compat manager.
if (Get-Service $compat_manager -ErrorAction SilentlyContinue) {
Stop-Service $compat_manager -Verbose
& sc.exe delete $compat_manager
}

# Stop Guest Agent Manager, cleanup all plugins (if present) and delete the service.
if (Get-Service $name -ErrorAction SilentlyContinue) {
Stop-Service $name -Verbose
& $cleanup_exe all
Expand Down
2 changes: 2 additions & 0 deletions packaging/googet/google-compute-engine-windows.goospec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"source": "https://github.com/GoogleCloudPlatform/guest-agent/",
"files": {
"GCEWindowsAgentManager.exe": "<ProgramFiles>/Google/Compute Engine/agent/GCEWindowsAgentManager.exe",
"GCEWindowsCompatManager.exe": "<ProgramFiles>/Google/Compute Engine/agent/GCEWindowsCompatManager.exe",
"GCEWindowsAgent.exe": "<ProgramFiles>/Google/Compute Engine/agent/GCEWindowsAgent.exe",
"GCEAuthorizedKeysCommand.exe": "<ProgramFiles>/Google/Compute Engine/agent/GCEAuthorizedKeysCommand.exe",
"ggactl_plugin_cleanup.exe": "<ProgramFiles>/Google/Compute Engine/agent/ggactl_plugin_cleanup.exe",
Expand Down Expand Up @@ -39,6 +40,7 @@
"include": [
"ggactl_plugin_cleanup.exe",
"GCEWindowsAgent.exe",
"GCEWindowsCompatManager.exe",
"GCEWindowsAgentManager.exe",
"GCEAuthorizedKeysCommand.exe",
"packaging/googet/agent_install.ps1",
Expand Down
4 changes: 4 additions & 0 deletions packaging/googet/windows_agent_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ if [[ ! -f "$GUEST_AGENT_REPO/Makefile" ]]; then
# looks for this file during goopack packaging and will fail if not found.
echo "This is a placeholder file so guest agent package build without error. Package will have actual Guest Agent Manager executable instead if both repos are cloned side-by-side." > GCEWindowsAgentManager.exe
echo "This is a placeholder file so guest agent package build without error. Package will have actual Guest Agent Manager executable instead if both repos are cloned side-by-side." > ggactl_plugin_cleanup.exe
echo "This is a placeholder file so guest agent package build without error. Package will have actual Guest Agent Manager executable instead if both repos are cloned side-by-side." > GCEWindowsCompatManager.exe
exit 0
fi

BUILD_DIR=$(pwd)
pushd $GUEST_AGENT_REPO
GOOS=windows VERSION=$version make cmd/google_guest_agent/google_guest_agent
GOOS=windows VERSION=$version make cmd/ggactl/ggactl_plugin_cleanup
GOOS=windows VERSION=$version make cmd/google_guest_compat_manager/google_guest_compat_manager

cp cmd/google_guest_agent/google_guest_agent $BUILD_DIR/GCEWindowsAgentManager.exe
cp cmd/ggactl/ggactl_plugin_cleanup $BUILD_DIR/ggactl_plugin_cleanup.exe
cp cmd/google_guest_compat_manager/google_guest_compat_manager $BUILD_DIR/GCEWindowsCompatManager.exe
popd
11 changes: 11 additions & 0 deletions packaging/google-guest-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ done
pushd %{name}-extra-%{version}/
VERSION=%{version} make cmd/google_guest_agent/google_guest_agent
VERSION=%{version} make cmd/ggactl/ggactl_plugin_cleanup
VERSION=%{version} make cmd/google_guest_compat_manager/google_guest_compat_manager
popd
%endif

Expand All @@ -82,6 +83,7 @@ install -p -m 0644 instance_configs.cfg %{buildroot}/usr/share/google-guest-agen
%if 0%{?build_plugin_manager}
install -p -m 0755 %{name}-extra-%{version}/cmd/google_guest_agent/google_guest_agent %{buildroot}%{_bindir}/google_guest_agent_manager
install -p -m 0755 %{name}-extra-%{version}/cmd/ggactl/ggactl_plugin_cleanup %{buildroot}%{_bindir}/ggactl_plugin_cleanup
install -p -m 0755 %{name}-extra-%{version}/cmd/google_guest_compat_manager/google_guest_compat_manager %{buildroot}%{_bindir}/google_guest_compat_manager
%endif

%if 0%{?el6}
Expand All @@ -96,6 +98,7 @@ install -p -m 0644 %{name}.service %{buildroot}%{_unitdir}

%if 0%{?build_plugin_manager}
install -p -m 0644 google-guest-agent-manager.service %{buildroot}%{_unitdir}
install -p -m 0644 google-guest-compat-manager.service %{buildroot}%{_unitdir}
%endif

install -p -m 0644 google-startup-scripts.service %{buildroot}%{_unitdir}
Expand All @@ -112,6 +115,7 @@ install -p -m 0644 90-%{name}.preset %{buildroot}%{_presetdir}/90-%{name}.preset
%{_bindir}/google_guest_agent

%if 0%{?build_plugin_manager}
%{_bindir}/google_guest_compat_manager
%{_bindir}/google_guest_agent_manager
%{_bindir}/ggactl_plugin_cleanup
%endif
Expand All @@ -127,6 +131,7 @@ install -p -m 0644 90-%{name}.preset %{buildroot}%{_presetdir}/90-%{name}.preset

%if 0%{?build_plugin_manager}
%{_unitdir}/google-guest-agent-manager.service
%{_unitdir}/google-guest-compat-manager.service
%endif

%{_unitdir}/google-startup-scripts.service
Expand Down Expand Up @@ -154,6 +159,7 @@ if [ $1 -eq 1 ]; then
systemctl enable gce-workload-cert-refresh.timer >/dev/null 2>&1 || :

%if 0%{?build_plugin_manager}
systemctl enable google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl enable google-guest-agent-manager.service >/dev/null 2>&1 || :
%endif

Expand All @@ -162,6 +168,7 @@ if [ $1 -eq 1 ]; then
systemctl start google-guest-agent.service >/dev/null 2>&1 || :
systemctl start gce-workload-cert-refresh.timer >/dev/null 2>&1 || :
%if 0%{?build_plugin_manager}
systemctl start google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl start google-guest-agent-manager.service >/dev/null 2>&1 || :
%endif
fi
Expand All @@ -173,6 +180,8 @@ else
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl try-restart google-guest-agent.service >/dev/null 2>&1 || :
%if 0%{?build_plugin_manager}
systemctl enable google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl restart google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl enable google-guest-agent-manager.service >/dev/null 2>&1 || :
systemctl restart google-guest-agent-manager.service >/dev/null 2>&1 || :
%endif
Expand All @@ -183,6 +192,7 @@ fi
if [ $1 -eq 0 ]; then
# Package removal, not upgrade
%if 0%{?build_plugin_manager}
systemctl --no-reload disable google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl --no-reload disable google-guest-agent-manager.service >/dev/null 2>&1 || :
%endif
systemctl --no-reload disable google-guest-agent.service >/dev/null 2>&1 || :
Expand All @@ -192,6 +202,7 @@ if [ $1 -eq 0 ]; then
if [ -d /run/systemd/system ]; then
systemctl stop google-guest-agent.service >/dev/null 2>&1 || :
%if 0%{?build_plugin_manager}
systemctl stop google-guest-compat-manager.service >/dev/null 2>&1 || :
systemctl stop google-guest-agent-manager.service >/dev/null 2>&1 || :
ggactl_plugin_cleanup all >/dev/null 2>&1 || :
%endif
Expand Down

0 comments on commit d68d45b

Please sign in to comment.