func update()

in main/cmds.go [129:151]


func update(lg ExtensionLogger, hEnv vmextension.HandlerEnvironment, seqNum int) error {
	// parse the extension handler settings
	cfg, err := parseAndValidateSettings(hEnv.HandlerEnvironment.ConfigFolder)
	if err != nil {
		return errors.Wrap(err, "failed to get configuration")
	}

	// run update.sh to disable the agent
	lg.event("updating agent")
	unzipDir, agentDirectory := getAgentPaths()
	_, runErr := runCmd(lg, "bash ./update.sh", agentDirectory, cfg)
	if runErr != nil {
		lg.eventError("agent update failed", runErr)
		telemetry(TelemetryScenario, "agent update failed: "+runErr.Error(), false, 0)
	} else {
		lg.event("agent update succeeded")
		telemetry(TelemetryScenario, "agent update succeeded", true, 0)
	}

	// collect the logs if available and send telemetry updates
	getStdPipesAndTelemetry(lg, unzipDir, runErr)
	return nil
}