Skip to content

Commit 08a6822

Browse files
Merge pull request #202 from microsoft/main
Fork Sync: Update from parent repository
2 parents 48df6c5 + d732028 commit 08a6822

File tree

9 files changed

+404
-51
lines changed

9 files changed

+404
-51
lines changed

docs/unmnaged-nodes.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,34 @@ onefuzz nodes get <machine_guid>
8787
```
8888

8989
This should return one entry. Verify that the `pool_name` matched the pool name created earlier.
90-
From here you will be able to schedule jobs on that pool and they will be running.
90+
From here you will be able to schedule jobs on that pool and they will be running.
91+
92+
93+
## Troubleshooting
94+
95+
### increase the verbosity of the logs
96+
It can help when investigating issues to increase the log verbosity. you will need to set the [RUST_LOG](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) environment variable when starting docker
97+
98+
```
99+
docker run --rm --env RUST_LOG=<log_level> <image_name> --machine_id <machine_id>
100+
```
101+
log_level can be any of
102+
- error
103+
- warn
104+
- info
105+
- debug
106+
- trace
107+
108+
109+
### use the container interactively
110+
you can use the container interactively by with the following command
111+
112+
windows
113+
```
114+
docker run --it --rm --entrypoint powershell <image_name>
115+
```
116+
117+
linux
118+
```
119+
docker run --it --rm --entrypoint bash <image_name>
120+
```

src/ApiService/ApiService/onefuzzlib/Config.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ public async Async.Task<ResultVoid<TaskConfigError>> CheckConfig(TaskConfig conf
320320
return ResultVoid<TaskConfigError>.Error(new TaskConfigError($"invalid pool: {config.Pool.PoolName}"));
321321
}
322322

323-
if ((config.Task.RebootAfterSetup ?? false) && !pool.OkV.Managed) {
324-
return ResultVoid<TaskConfigError>.Error(new TaskConfigError("reboot_after_setup is not supported for unmanaged pools"));
325-
}
326-
327323
var checkTarget = await CheckTargetExe(config, definition);
328324
if (!checkTarget.IsOk) {
329325
return checkTarget;

src/agent/onefuzz-agent/src/reboot.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,22 @@ impl Reboot {
9090

9191
#[cfg(target_family = "unix")]
9292
pub fn invoke(&self) -> Result<()> {
93-
info!("invoking local reboot command");
94-
95-
Command::new("reboot").arg("-f").status()?;
96-
97-
self.wait_for_reboot()
93+
match std::path::Path::new("/.dockerenv").try_exists() {
94+
Ok(true) => {
95+
info!("running inside docker, exiting instead of rebooting");
96+
std::process::exit(0);
97+
}
98+
_ => {
99+
info!("invoking local reboot command");
100+
Command::new("reboot").arg("-f").status()?;
101+
self.wait_for_reboot()
102+
}
103+
}
98104
}
99105

100106
#[cfg(target_family = "windows")]
101107
pub fn invoke(&self) -> Result<()> {
102108
info!("invoking local reboot command");
103-
104109
Command::new("powershell.exe")
105110
.arg("-Command")
106111
.arg("Restart-Computer")

src/cli/onefuzz/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ def get_config(self, pool_name: primitives.PoolName) -> models.AgentConfig:
12811281
client_secret="<client_secret>",
12821282
resource=self.onefuzz._backend.config.endpoint,
12831283
tenant=urlparse(self.onefuzz._backend.config.authority).path.strip("/"),
1284-
multi_tenant_domain=self.onefuzz._backend.config.tenant_domain,
1284+
multi_tenant_domain=self.onefuzz._backend.config.get_multi_tenant_domain(),
12851285
)
12861286

12871287
return pool.config

src/cli/onefuzz/backend.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ class BackendConfig(BaseModel):
9898
features: Set[str] = Field(default_factory=set)
9999
tenant_domain: str
100100

101+
def get_multi_tenant_domain(self) -> Optional[str]:
102+
if "https://login.microsoftonline.com/common" in self.authority:
103+
return self.tenant_domain
104+
else:
105+
return None
106+
101107

102108
class Backend:
103109
def __init__(
@@ -182,10 +188,11 @@ def get_access_token(self) -> Any:
182188
if not self.config.endpoint:
183189
raise Exception("endpoint not configured")
184190

185-
if "https://login.microsoftonline.com/common" in self.config.authority:
191+
multi_tenant_domain = self.config.get_multi_tenant_domain()
192+
if multi_tenant_domain is not None:
186193
endpoint = urlparse(self.config.endpoint).netloc.split(".")[0]
187194
scopes = [
188-
f"api://{self.config.tenant_domain}/{endpoint}/.default",
195+
f"api://{multi_tenant_domain}/{endpoint}/.default",
189196
]
190197
else:
191198
netloc = urlparse(self.config.endpoint).netloc

src/deployment/deploylib/registration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,13 @@ def try_sp_create() -> None:
307307
error: Optional[Exception] = None
308308
for _ in range(10):
309309
try:
310-
query_microsoft_graph(
310+
service_principal = query_microsoft_graph(
311311
method="POST",
312312
resource="servicePrincipals",
313313
body=service_principal_params,
314314
subscription=subscription_id,
315315
)
316+
logger.info(f"created service principal:\n {service_principal}")
316317
return
317318
except GraphQueryError as err:
318319
# work around timing issue when creating service principal
@@ -654,8 +655,11 @@ def assign_instance_app_role(
654655

655656
if len(onefuzz_service_principals) == 0:
656657
raise Exception("onefuzz app service principal not found")
657-
onefuzz_service_principal = onefuzz_service_principals[0]
658658

659+
onefuzz_service_principal = onefuzz_service_principals[0]
660+
logger.info(
661+
f"Assigning app role instance service principal {onefuzz_service_principal['id']}"
662+
)
659663
if isinstance(application_name, str):
660664
application_service_principals = query_microsoft_graph_list(
661665
method="GET",

0 commit comments

Comments
 (0)