Skip to content

Commit 1a5c2e3

Browse files
committed
kokoro experiment, tried adding a new env varaible to differentiate regular ops agent and plugin, and set in the gcl config file
1 parent b0707c2 commit 1a5c2e3

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

integration_test/agents/agents.go

+17-14
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,6 @@ func getRestartOpsAgentCmd(imageSpec string) string {
710710
// PackageLocation describes a location where packages
711711
// (currently, only the Ops Agent packages) live.
712712
type PackageLocation struct {
713-
// If provided, a URL for a file in GCS containing a .tar.gz file
714-
// to install on the testing VMs.
715-
uapPluginPackageInGCS string
716713
// If provided, a URL for a directory in GCS containing .deb/.rpm/.goo files
717714
// to install on the testing VMs.
718715
// This setting is mutually exclusive with repoSuffix.
@@ -735,7 +732,6 @@ type PackageLocation struct {
735732
// LocationFromEnvVars assembles a PackageLocation from environment variables.
736733
func LocationFromEnvVars() PackageLocation {
737734
return PackageLocation{
738-
uapPluginPackageInGCS: "gs://ops-agent-uap-plugin/debian12-bookworm/google-cloud-ops-agent-plugin_2.54.0-bookworm-amd64.tar.gz",
739735
packagesInGCS: os.Getenv("AGENT_PACKAGES_IN_GCS"),
740736
repoSuffix: os.Getenv("REPO_SUFFIX"),
741737
repoCodename: os.Getenv("REPO_CODENAME"),
@@ -769,13 +765,14 @@ func InstallOpsAgent(ctx context.Context, logger *log.Logger, vm *gce.VM, locati
769765
if location.packagesInGCS != "" && location.repoSuffix != "" {
770766
return fmt.Errorf("invalid PackageLocation: cannot provide both location.packagesInGCS and location.repoSuffix. location=%#v", location)
771767
}
772-
if location.uapPluginPackageInGCS != "" {
773-
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, location.uapPluginPackageInGCS)
774-
}
768+
775769
if location.artifactRegistryRegion != "" && location.repoSuffix == "" {
776770
return fmt.Errorf("invalid PackageLocation: location.artifactRegistryRegion was nonempty yet location.repoSuffix was empty. location=%#v", location)
777771
}
778772
if location.packagesInGCS != "" {
773+
if IsOpsAgentUAPPlugin() {
774+
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, location.packagesInGCS)
775+
}
779776
return InstallPackageFromGCS(ctx, logger, vm, location.packagesInGCS)
780777
}
781778

@@ -945,7 +942,7 @@ func InstallOpsAgentUAPPluginFromGCS(ctx context.Context, logger *log.Logger, vm
945942
if gce.IsWindows(vm.ImageSpec) {
946943
return fmt.Errorf("Ops Agent UAP Plugin does not support Windows yet")
947944
}
948-
if _, err := gce.RunRemotely(ctx, logger, vm, "mkdir -p /tmp/agentUpload"); err != nil {
945+
if _, err := gce.RunRemotely(ctx, logger, vm, "mkdir -p /tmp/agentUpload /tmp/agentPlugin"); err != nil {
949946
return err
950947
}
951948
if err := gce.InstallGsutilIfNeeded(ctx, logger, vm); err != nil {
@@ -954,17 +951,21 @@ func InstallOpsAgentUAPPluginFromGCS(ctx context.Context, logger *log.Logger, vm
954951
if err := gce.InstallGrpcurlIfNeeded(ctx, logger, vm); err != nil {
955952
return err
956953
}
957-
if _, err := gce.RunRemotely(ctx, logger, vm, "gsutil cp "+gcsPath+" /tmp/agentUpload"); err != nil {
954+
955+
if _, err := gce.RunRemotely(ctx, logger, vm, "sudo gsutil cp -r "+gcsPath+"/* /tmp/agentUpload"); err != nil {
958956
return fmt.Errorf("error copying down agent package from GCS: %v", err)
959957
}
960-
// Print the contents of /tmp/agentUpload into the logs.
961-
if _, err := gce.RunRemotely(ctx, logger, vm, "ls -la /tmp/agentUpload"); err != nil {
958+
if _, err := gce.RunRemotely(ctx, logger, vm, "mv /tmp/agentUpload/*.tar.gz /tmp/agentPlugin || echo nothing to move"); err != nil {
962959
return err
963960
}
964-
if _, err := gce.RunRemotely(ctx, logger, vm, "sudo tar -xzf /tmp/agentUpload/google-cloud-ops-agent-plugin_2.54.0-bookworm-amd64.tar.gz --no-overwrite-dir -C ~/ && ls -la"); err != nil {
961+
// Print the contents of /tmp/agentPlugin into the logs.
962+
if _, err := gce.RunRemotely(ctx, logger, vm, "ls -la /tmp/agentPlugin"); err != nil {
965963
return err
966964
}
967-
// Print the contents of /tmp/agentUpload into the logs.
965+
if _, err := gce.RunRemotely(ctx, logger, vm, "sudo find /tmp/agentPlugin -maxdepth 1 -name \"google-cloud-ops-agent-plugin*.tar.gz\" -print0 | xargs -0 -I {} sudo tar -xzf {} --no-overwrite-dir -C ~/ && ls -la"); err != nil {
966+
return err
967+
}
968+
// Print the contents of the home dir into the logs.
968969
if _, err := gce.RunRemotely(ctx, logger, vm, "ls -la ~/"); err != nil {
969970
return err
970971
}
@@ -1049,5 +1050,7 @@ func GetOtelConfigPath(imageSpec string) string {
10491050
}
10501051

10511052
func IsOpsAgentUAPPlugin() bool {
1052-
return LocationFromEnvVars().uapPluginPackageInGCS != ""
1053+
// ok is true when the env variable is preset in the environment.
1054+
_, ok := os.LookupEnv("IS_OPS_AGENT_UAP_PLUGIN")
1055+
return ok
10531056
}

kokoro/config/test/ops_agent/presubmit/bookworm_x86_64.gcl

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config build = common.ops_agent_test {
55
environment {
66
TARGET = 'bookworm'
77
ARCH = 'x86_64'
8+
IS_OPS_AGENT_UAP_PLUGIN = 'true'
89
}
910
}
1011
}

0 commit comments

Comments
 (0)