Skip to content

Commit 991840c

Browse files
committed
Cleanup stale logic around using service account credentials in cvd fetch calls.
- TODO(b/425716010). - Follow up of #1230 Bug: b/425716010
1 parent 7387d6c commit 991840c

7 files changed

Lines changed: 0 additions & 159 deletions

File tree

.github/workflows/presubmit.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,6 @@ jobs:
392392
fi
393393
done
394394
sudo podman rm -f tester
395-
# Run create_with_gce_credentials_test
396-
sudo podman run --name tester -d --privileged --pids-limit=8192 -v /tmp/cw_bazel:/tmp/cw_bazel -v .:/src/workspace -w /src/workspace/e2etests --add-host="metadata.google.internal:127.0.0.1" android-cuttlefish-e2etest:latest
397-
sudo podman exec --user=testrunner -it tester bazel --output_user_root=/tmp/cw_bazel/output test //orchestration/create_with_gce_credentials_test:create_with_gce_credentials_test_test
398-
sudo podman rm -f tester
399395
# Run verify_access_token_test
400396
sudo podman run --name tester -d --privileged --pids-limit=8192 -v /tmp/cw_bazel:/tmp/cw_bazel -v .:/src/workspace -w /src/workspace/e2etests android-cuttlefish-e2etest:latest
401397
sleep 30s # Add delay before restarting cuttlefish-host_orchestrator service.

e2etests/orchestration/create_with_gce_credentials_test/BUILD.bazel

Lines changed: 0 additions & 25 deletions
This file was deleted.

e2etests/orchestration/create_with_gce_credentials_test/main_test.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

frontend/src/host_orchestrator/orchestrator/controller.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -953,18 +953,6 @@ func getFetchCredentials(config BuildAPICredentialsConfig, r *http.Request) cvd.
953953
UseGCEServiceAccountCredentials: true,
954954
}
955955
}
956-
// TODO(b/425716010): Remove the following block, and use `config.UseGCEMetadata` instead
957-
if isRunningOnGCE() {
958-
log.Println("fetch credentials: running on gce")
959-
if ok, err := hasServiceAccountAccessToken(); err != nil {
960-
log.Printf("fetch credentials: service account token check failed: %s", err)
961-
} else if ok {
962-
log.Println("fetch credentials: using gce service account credentials")
963-
return cvd.FetchCredentials{
964-
UseGCEServiceAccountCredentials: true,
965-
}
966-
}
967-
}
968956
log.Println("fetch credentials: using no credentials")
969957
return cvd.FetchCredentials{}
970958
}

frontend/src/host_orchestrator/orchestrator/instancemanager.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"context"
2020
"fmt"
2121
"log"
22-
"net"
23-
"net/http"
2422
"os"
2523
"os/exec"
2624
"path/filepath"
@@ -242,23 +240,3 @@ func runAcloudSetup(execContext hoexec.ExecContext, artifactsRootDir, artifactsD
242240
// Creates symbolic link `acloud_link` which points to the passed device artifacts directory.
243241
go run(execContext(context.TODO(), "ln", "-s", artifactsDir, artifactsRootDir+"/acloud_link"))
244242
}
245-
246-
func isRunningOnGCE() bool {
247-
_, err := net.LookupIP("metadata.google.internal")
248-
return err == nil
249-
}
250-
251-
// For instances running on GCE, checks whether the instance was created with a service account having an access token.
252-
func hasServiceAccountAccessToken() (bool, error) {
253-
req, err := http.NewRequest("GET", "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token", nil)
254-
if err != nil {
255-
return false, err
256-
}
257-
req.Header.Set("Metadata-Flavor", "Google")
258-
client := &http.Client{}
259-
res, err := client.Do(req)
260-
if err != nil {
261-
return false, err
262-
}
263-
return res.StatusCode == http.StatusOK, nil
264-
}

tools/testutils/cw/Containerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ RUN groupadd kvm
1010
COPY tools/testutils/cw/setup.service /etc/systemd/system/setup.service
1111
RUN systemctl enable setup
1212

13-
# Enabled with `podman run --add-host="metadata.google.internal:127.0.0.1"`
14-
COPY tools/testutils/cw/fake_gce_metadata_nginx.conf /etc/nginx/conf.d/fake_gce_metadata_nginx.conf
15-
1613
FROM base AS with_bazel
1714

1815
RUN --mount=source=.,target=/mnt,type=bind \

tools/testutils/cw/fake_gce_metadata_nginx.conf

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)