Skip to content

Bump to v2.0.8: Bootstrap VMWatch Process if vmWatchSettings present#33

Merged
frank-pang-msft merged 41 commits intofeature/v2/bootstrapVMWatchfrom
dev/frankpang/bootstrapVMWatch
Nov 17, 2023
Merged

Bump to v2.0.8: Bootstrap VMWatch Process if vmWatchSettings present#33
frank-pang-msft merged 41 commits intofeature/v2/bootstrapVMWatchfrom
dev/frankpang/bootstrapVMWatch

Conversation

@frank-pang-msft
Copy link
Collaborator

@frank-pang-msft frank-pang-msft commented Aug 18, 2023

Overview

This PR contains changes to support running VMWatch (amd64 and arm64) as an executable via goroutines and channels.

VMWatch is a standardized, lightweight, and open-sourced testing framework designed to enhance the monitoring and management of guest VMs on the Azure platform, including both 1P and 3P instances. VMWatch is engineered to collect vital health signals across multiple dimensions, which will be seamlessly integrated into Azure's quality systems. By leveraging these signals, VMWatch will enable Azure to swiftly detect and prevent regressions induced by platform updates or configuration changes, identify gaps in platform telemetry, and ultimately improve the guest experience for all Azure customers.

Behavior

VMWatch will run asynchronously as a separate process than ApplicationHealth, so the probing of application health will not be affected by the state of VMWatch. Depending on extension settings, VMWatch can be enabled/disabled, and also specify the test names and parameter overrides to VMWatch binary. The status of VMWatch will be displayed in the extension x.status files and also in GET VM Instance View. Main process will attempt to start VMWatch binary up to 3 times, after which VMWatch status will be set to failed.

Process Leaks

To ensure that VMWatch processes do not accumulate, applicationhealth-shim will be responsible for killing existing VMWatch processes by looking for processes running with the VMWatch binary names according to the architecture type. For unexpected process termination, if for some reason the main applicationhealth-extension process is terminated, we also ensure that the VMWatch process is also killed by subscribing to shutdown/termination signals in the main process, and killing the VMWatch based off process ID.

Example Binary Execution

Example execution from integration testing
SIGNAL_FOLDER=/var/log/azure/Microsoft.ManagedServices.ApplicationHealthLinux/events VERBOSE_LOG_FILE_FULL_PATH=/var/log/azure/Microsoft.ManagedServices.ApplicationHealthLinux/vmwatch.log ./var/lib/waagent/Extension/bin/VMWatch/vmwatch_linux_amd64 --config /var/lib/waagent/Extension/bin/VMWatch/vmwatch.conf --input-filter disk_io:outbound_connectivity

Release/Packaging

In addition to the arm64 or amd64 VMWatch binaries, vmwatch.conf will be expected to be present in the bin/VMWatch directory for VMWatch process to read. VMWatch will also be populating and sharing eventsFolder with ApplicationHealth, so events can be viewed in Kusto. The verbose logs of VMWatch will be written to vmwatch.log.

@frank-pang-msft frank-pang-msft marked this pull request as ready for review August 31, 2023 15:54
@frank-pang-msft frank-pang-msft added the enhancement New feature or request label Sep 1, 2023
Copy link
Member

@zmyzheng zmyzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

Copy link

@Hafthor Hafthor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a first pass at this review -- might try to take another look at it later.

@frank-pang-msft frank-pang-msft changed the title Bootstrap VMWatch Process if vmWatchSettings present Bump to v2.0.7: Bootstrap VMWatch Process if vmWatchSettings present Sep 15, 2023
vmWatchErr = fmt.Errorf("%w\n Additonal Details: %+v", vmWatchErr, r)
ctx.Log("error", "Recovered %+v", r)
}
ctx.Log("error", fmt.Sprintf("Signaling VMWatchStatus is Failed due to reaching max of %d retries", VMWatchMaxProcessAttempts))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this defer func will happen whenever the executeVMWatch func exits... it's like a finally block... not a catch block. I think you want this error handling stuff to be conditionally run on if executeVMWatch does not reach the bottom of the func.. like perhaps if vmWatchErr != nil

err = fmt.Errorf("Error: %w\n Additonal Details: %+v", err, r)
ctx.Log("error", "Recovered %+v", r)
}
killVMWatch(ctx, cmd)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want to killVMWatch on successful exit of executeVMWatchHelper func.


// VMWatch should run indefinitely, if process exists we expect an error
err = cmd.Wait()
err = fmt.Errorf("[%v][PID %d] Attempt %d: VMWatch process exited. Error: %w\nOutput: %s", time.Now().UTC().Format(time.RFC3339), pid, attempt, err, combinedOutput.String())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think you would want to test the return of cmd.Wait() and only fmt.Errorf wrap it when err != nil.

@frank-pang-msft frank-pang-msft force-pushed the dev/frankpang/bootstrapVMWatch branch from e7e1129 to 7ce2f7f Compare September 15, 2023 22:29
…n Handler Environment (#39)

* - moved handlerenv.go and seqno.go from "github.com/Azure/azure-docker-extension/pkg/vmextension"
- Added EventsFolder with other missing parameters.

* -removed vmextension lib dependency from VMwatch and other Files.
- Updates HandlerEnviroment.json test file.
- Updated VMwatch Integration Tests.

* - Bump to v2.0.8
@frank-pang-msft frank-pang-msft changed the title Bump to v2.0.7: Bootstrap VMWatch Process if vmWatchSettings present Bump to v2.0.8: Bootstrap VMWatch Process if vmWatchSettings present Sep 29, 2023
@frank-pang-msft frank-pang-msft changed the base branch from master to feature/v2/bootstrapVMWatch November 16, 2023 18:22
@frank-pang-msft frank-pang-msft merged commit 463490d into feature/v2/bootstrapVMWatch Nov 17, 2023
klugorosado added a commit that referenced this pull request Jun 4, 2024
…33)

## Overview
This PR contains changes to support running VMWatch (amd64 and arm64) as an executable via goroutines and channels. 
> VMWatch is a standardized, lightweight, and open-sourced testing framework designed to enhance the monitoring and management of guest VMs on the Azure platform, including both 1P and 3P instances. VMWatch is engineered to collect vital health signals across multiple dimensions, which will be seamlessly integrated into Azure's quality systems. By leveraging these signals, VMWatch will enable Azure to swiftly detect and prevent regressions induced by platform updates or configuration changes, identify gaps in platform telemetry, and ultimately improve the guest experience for all Azure customers.

## Behavior
VMWatch will run asynchronously as a separate process than ApplicationHealth, so the probing of application health will not be affected by the state of VMWatch. Depending on extension settings, VMWatch can be enabled/disabled, and also specify the test names and parameter overrides to VMWatch binary. The status of VMWatch will be displayed in the extension x.status files and also in GET VM Instance View. Main process will attempt to start VMWatch binary up to 3 times, after which VMWatch status will be set to failed.

## Process Leaks
To ensure that VMWatch processes do not accumulate, applicationhealth-shim will be responsible for killing existing VMWatch processes by looking for processes running with the VMWatch binary names according to the architecture type. For unexpected process termination, if for some reason the main applicationhealth-extension process is terminated, we also ensure that the VMWatch process is also killed by subscribing to shutdown/termination signals in the main process, and killing the VMWatch based off process ID.

## Example Binary Execution
Example execution from integration testing 
`
SIGNAL_FOLDER=/var/log/azure/Microsoft.ManagedServices.ApplicationHealthLinux/events VERBOSE_LOG_FILE_FULL_PATH=/var/log/azure/Microsoft.ManagedServices.ApplicationHealthLinux/VE.RS.ION/vmwatch.log ./var/lib/waagent/Extension/bin/VMWatch/vmwatch_linux_amd64 --config /var/lib/waagent/Extension/bin/VMWatch/vmwatch.conf --input-filter disk_io:outbound_connectivity
`

## Release/Packaging
In addition to the arm64 or amd64 VMWatch binaries, `vmwatch.conf` will be expected to be present in the bin/VMWatch directory for VMWatch process to read. VMWatch will also be populating and sharing eventsFolder with ApplicationHealth, so events can be viewed in Kusto. The verbose logs of VMWatch will be written to `vmwatch.log`.

---------

Co-authored-by: klugorosado <142627157+klugorosado@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants