Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit a374939

Browse files
authored
Fix onefuzz repro bug - Remove managed identity from CustomScriptExtension (#2920)
* Adding potential repro fix. * Removing managed identity. * Remove return statement. * reverting changes. * removing logging. * Reverting changes. * Adding back trace. * Removing protected settings. * Removing managed identited. * Conditionally setting protected settings.
1 parent f00248f commit a374939

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/ApiService/ApiService/onefuzzlib/Extension.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ public async Async.Task<VMExtensionWrapper> AgentConfig(AzureLocation region, Os
267267
await UpdateManagedScripts();
268268
var urlsUpdated = urls ?? new();
269269

270-
var managedIdentity = JsonSerializer.Serialize(new { ManagedIdentity = new Dictionary<string, string>() }, _extensionSerializerOptions);
270+
var managedIdentity = withSas ? null : new BinaryData(JsonSerializer.Serialize(new { ManagedIdentity = new Dictionary<string, string>() }, _extensionSerializerOptions));
271+
271272
if (vmOs == Os.Windows) {
272273
var vmScripts = await ConfigUrl(WellKnownContainers.VmScripts, "managed.ps1", withSas) ?? throw new Exception("failed to get VmScripts config url");
273274
var toolsAzCopy = await ConfigUrl(WellKnownContainers.Tools, "win64/azcopy.exe", withSas) ?? throw new Exception("failed to get toolsAzCopy config url");
@@ -290,7 +291,7 @@ public async Async.Task<VMExtensionWrapper> AgentConfig(AzureLocation region, Os
290291
TypeHandlerVersion = "1.9",
291292
AutoUpgradeMinorVersion = true,
292293
Settings = new BinaryData(JsonSerializer.Serialize(new { commandToExecute = toExecuteCmd, fileUris = urlsUpdated }, _extensionSerializerOptions)),
293-
ProtectedSettings = new BinaryData(managedIdentity)
294+
ProtectedSettings = managedIdentity
294295
};
295296
return extension;
296297
} else if (vmOs == Os.Linux) {
@@ -315,7 +316,7 @@ public async Async.Task<VMExtensionWrapper> AgentConfig(AzureLocation region, Os
315316
ForceUpdateTag = Guid.NewGuid().ToString(),
316317
AutoUpgradeMinorVersion = true,
317318
Settings = new BinaryData(extensionSettings),
318-
ProtectedSettings = new BinaryData(managedIdentity)
319+
ProtectedSettings = managedIdentity
319320
};
320321
return extension;
321322
}

src/ApiService/ApiService/onefuzzlib/ReproOperations.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public async Async.Task<Repro> ExtensionsLaunch(Repro repro) {
185185
ErrorCode.VM_CREATE_FAILED,
186186
new string[] { "failed before launching extensions" }));
187187
}
188-
189188
if (vmData.ProvisioningState == "Failed") {
190189
var failedVmData = await _context.VmOperations.GetVmWithInstanceView(vm.Name);
191190
if (failedVmData is null) {

src/ApiService/ApiService/onefuzzlib/VmOperations.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public async System.Threading.Tasks.Task DeleteVm(string name) {
152152
return;
153153
}
154154

155-
156155
public async Task<OneFuzzResult<bool>> AddExtensions(Vm vm, Dictionary<string, VirtualMachineExtensionData> extensions) {
157156
var statuses = new List<(string extName, string state)>();
158157
var toCreate = new List<KeyValuePair<string, VirtualMachineExtensionData>>();
@@ -212,7 +211,6 @@ public async Task<OneFuzzResultVoid> Create(Vm vm) {
212211
var vm = await _context.Creds.GetResourceGroupResource().GetVirtualMachineAsync(
213212
vmName
214213
);
215-
216214
return (await vm.Value.GetVirtualMachineExtensionAsync(extensionName)).Value.Data;
217215
} catch (RequestFailedException ex) {
218216
_logTracer.Info($"extension does not exist {ex.Message:Tag:Error}");

0 commit comments

Comments
 (0)