public async Async.Task <VirtualMachineScaleSetData> GetVmss(Guid name) { var res = GetVmssResource(name); _log.Verbose($"getting vmss: {name}"); var r = await res.GetAsync(); return(r.Value.Data); }
public async Async.Task <VirtualMachineScaleSetData?> GetVmss(Guid name) { try { var res = await GetVmssResource(name).GetAsync(); _log.Verbose($"getting vmss: {name}"); return(res.Value.Data); } catch (Exception ex) when(ex is RequestFailedException) { return(null); } }
void ProcessScaleSets(Scaleset scaleset) { _log.Verbose($"checking scaleset for updates: {scaleset.ScalesetId}"); _scaleSetOps.UpdateConfigs(scaleset); //if (_scaleSetOps.Cleanup) }
public async Async.Task ProcessScalesets(Service.Scaleset scaleset) { _log.Verbose($"checking scaleset for updates: {scaleset.ScalesetId}"); await _scaleSetOps.UpdateConfigs(scaleset); // if the scaleset is touched during cleanup, don't continue to process it if (await _scaleSetOps.CleanupNodes(scaleset)) { _log.Verbose($"scaleset needed cleanup: {scaleset.ScalesetId}"); return; } await _scaleSetOps.SyncScalesetSize(scaleset); await _scaleSetOps.ProcessStateUpdate(scaleset); }
public async Task <QueueServiceClient> GetQueueClientService(StorageType storageType) { var accountId = _storage.GetPrimaryAccount(storageType); _log.Verbose($"getting blob container (account_id: {accountId})"); var(name, key) = await _storage.GetStorageAccountNameAndKey(accountId); var accountUrl = new Uri($"https://{name}.queue.core.windows.net"); var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.Base64 }; return(new QueueServiceClient(accountUrl, new StorageSharedKeyCredential(name, key), options)); }
public async Task <QueueServiceClient> GetQueueClientService(StorageType storageType) { var accountId = _storage.GetPrimaryAccount(storageType); _log.Verbose($"getting blob container (account_id: {accountId})"); var(name, key) = await _storage.GetStorageAccountNameAndKey(accountId); var endpoint = _storage.GetQueueEndpoint(name); var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.Base64 }; return(new QueueServiceClient(endpoint, new StorageSharedKeyCredential(name, key), options)); }
public async Async.Task UpdateConfigs(Scaleset scaleSet) { if (scaleSet == null) { _log.Warning("skipping update configs on scaleset, since scaleset is null"); return; } if (scaleSet.State == ScalesetState.Halt) { _log.Info($"{SCALESET_LOG_PREFIX} not updating configs, scalest is set to be deleted. scaleset_id: {scaleSet.ScalesetId}"); return; } if (!scaleSet.NeedsConfigUpdate) { _log.Verbose($"{SCALESET_LOG_PREFIX} config update no needed. scaleset_id: {scaleSet.ScalesetId}"); return; } _log.Info($"{SCALESET_LOG_PREFIX} updating scalset configs. scalset_id: {scaleSet.ScalesetId}"); var pool = await _context.PoolOperations.GetByName(scaleSet.PoolName); if (!pool.IsOk || pool.OkV is null) { _log.Error($"{SCALESET_LOG_PREFIX} unable to find pool during config update. pool:{scaleSet.PoolName}, scaleset_id:{scaleSet.ScalesetId}"); await SetFailed(scaleSet, pool.ErrorV !); return; } var extensions = await _context.Extensions.FuzzExtensions(pool.OkV, scaleSet); var res = await _context.VmssOperations.UpdateExtensions(scaleSet.ScalesetId, extensions); if (!res.IsOk) { _log.Info($"{SCALESET_LOG_PREFIX} unable to update configs {string.Join(',', res.ErrorV.Errors!)}"); } }
public async Async.Task Run([TimerTrigger("20:00:00")] TimerInfo t) { var now = DateTimeOffset.UtcNow; var timeRetainedOlder = now - RETENTION_POLICY; var timeRetainedNewer = now + SEARCH_EXTENT; var timeFilter = $"Timestamp lt datetime'{timeRetainedOlder.ToString("o")}' and Timestamp gt datetime'{timeRetainedNewer.ToString("o")}'"; var timeFilterNewer = $"Timestamp gt datetime '{timeRetainedOlder.ToString("o")}'"; // Collecting 'still relevant' task containers. // NOTE: This must be done before potentially modifying tasks otherwise // the task timestamps will not be useful.\ var usedContainers = new HashSet <Container>(); await foreach (var task in _taskOps.QueryAsync(timeFilter)) { var containerNames = from container in task.Config.Containers select container.Name; foreach (var c in containerNames) { usedContainers.Add(c); } } await foreach (var notification in _notificaitonOps.QueryAsync(timeFilter)) { _log.Verbose($"checking expired notification for removal: {notification.NotificationId}"); var container = notification.Container; if (!usedContainers.Contains(container)) { _log.Info($"deleting expired notification: {notification.NotificationId}"); var r = await _notificaitonOps.Delete(notification); if (!r.IsOk) { _log.WithHttpStatus(r.ErrorV).Error($"failed to delete notification with id {notification.NotificationId}"); } } } await foreach (var job in _jobOps.QueryAsync($"{timeFilter} and state eq '{JobState.Enabled}'")) { if (job.UserInfo is not null && job.UserInfo.Upn is not null) { _log.Info($"removing PII from job {job.JobId}"); var userInfo = job.UserInfo with { Upn = null }; var updatedJob = job with { UserInfo = userInfo }; var r = await _jobOps.Replace(updatedJob); if (!r.IsOk) { _log.WithHttpStatus(r.ErrorV).Error($"Failed to save job {updatedJob.JobId}"); } } } await foreach (var task in _taskOps.QueryAsync($"{timeFilter} and state eq '{TaskState.Stopped}'")) { if (task.UserInfo is not null && task.UserInfo.Upn is not null) { _log.Info($"removing PII from task {task.TaskId}"); var userInfo = task.UserInfo with { Upn = null }; var updatedTask = task with { UserInfo = userInfo }; var r = await _taskOps.Replace(updatedTask); if (!r.IsOk) { _log.WithHttpStatus(r.ErrorV).Error($"Failed to save task {updatedTask.TaskId}"); } } } await foreach (var repro in _reproOps.QueryAsync(timeFilter)) { if (repro.UserInfo is not null && repro.UserInfo.Upn is not null) { _log.Info($"removing PII from repro: {repro.VmId}"); var userInfo = repro.UserInfo with { Upn = null }; var updatedRepro = repro with { UserInfo = userInfo }; var r = await _reproOps.Replace(updatedRepro); if (!r.IsOk) { _log.WithHttpStatus(r.ErrorV).Error($"Failed to save repro {updatedRepro.VmId}"); } } } } }