app/all: follow-up after 84d710beab

https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5548
Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
hagen1778 2024-01-09 13:17:09 +01:00
parent fe2d9f6646
commit 91ccea236f
No known key found for this signature in database
GPG key ID: 3BF75F3741CA9640
9 changed files with 18 additions and 5 deletions

View file

@ -59,6 +59,8 @@ func main() {
} }
logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds())
pushmetrics.Stop()
vlinsert.Stop() vlinsert.Stop()
vlselect.Stop() vlselect.Stop()
vlstorage.Stop() vlstorage.Stop()

View file

@ -89,6 +89,7 @@ func main() {
if err := httpserver.Stop(*httpListenAddr); err != nil { if err := httpserver.Stop(*httpListenAddr); err != nil {
logger.Fatalf("cannot stop the webservice: %s", err) logger.Fatalf("cannot stop the webservice: %s", err)
} }
pushmetrics.Stop()
vminsert.Stop() vminsert.Stop()
logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds())

View file

@ -159,6 +159,7 @@ func main() {
logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds())
} }
pushmetrics.Stop()
promscrape.Stop() promscrape.Stop()
if len(*influxListenAddr) > 0 { if len(*influxListenAddr) > 0 {

View file

@ -187,6 +187,7 @@ func main() {
if err := httpserver.Stop(*httpListenAddr); err != nil { if err := httpserver.Stop(*httpListenAddr); err != nil {
logger.Fatalf("cannot stop the webservice: %s", err) logger.Fatalf("cannot stop the webservice: %s", err)
} }
pushmetrics.Stop()
cancel() cancel()
manager.close() manager.close()
} }

View file

@ -80,6 +80,7 @@ func main() {
if err := httpserver.Stop(*httpListenAddr); err != nil { if err := httpserver.Stop(*httpListenAddr); err != nil {
logger.Fatalf("cannot stop the webservice: %s", err) logger.Fatalf("cannot stop the webservice: %s", err)
} }
pushmetrics.Stop()
logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down the webservice in %.3f seconds", time.Since(startTime).Seconds())
stopAuthConfig() stopAuthConfig()
logger.Infof("successfully stopped vmauth in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully stopped vmauth in %.3f seconds", time.Since(startTime).Seconds())

View file

@ -107,6 +107,7 @@ func main() {
if err := httpserver.Stop(*httpListenAddr); err != nil { if err := httpserver.Stop(*httpListenAddr); err != nil {
logger.Fatalf("cannot stop http server for metrics: %s", err) logger.Fatalf("cannot stop http server for metrics: %s", err)
} }
pushmetrics.Stop()
logger.Infof("successfully shut down http server for metrics in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down http server for metrics in %.3f seconds", time.Since(startTime).Seconds())
} }

View file

@ -65,6 +65,7 @@ func main() {
if err := httpserver.Stop(*httpListenAddr); err != nil { if err := httpserver.Stop(*httpListenAddr); err != nil {
logger.Fatalf("cannot stop http server for metrics: %s", err) logger.Fatalf("cannot stop http server for metrics: %s", err)
} }
pushmetrics.Stop()
logger.Infof("successfully shut down http server for metrics in %.3f seconds", time.Since(startTime).Seconds()) logger.Infof("successfully shut down http server for metrics in %.3f seconds", time.Since(startTime).Seconds())
} }

View file

@ -51,6 +51,7 @@ The sandbox cluster installation is running under the constant load generated by
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): retry on import errors in `vm-native` mode. Before, retries happened only on writes into a network connection between source and destination. But errors returned by server after all the data was transmitted were logged, but not retried. * BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): retry on import errors in `vm-native` mode. Before, retries happened only on writes into a network connection between source and destination. But errors returned by server after all the data was transmitted were logged, but not retried.
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly assume role with [AWS IRSA authorization](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html). Previously role chaining was not supported. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3822) for details. * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly assume role with [AWS IRSA authorization](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html). Previously role chaining was not supported. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3822) for details.
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix a link for the statistic inaccuracy explanation in the cardinality explorer tool. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5460). * BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix a link for the statistic inaccuracy explanation in the cardinality explorer tool. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5460).
* BUGFIX: all: fix potential panic during components shutdown when `-pushmetrics.url` is configured. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5548). Thanks to @zhdd99 for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5549).
## [v1.96.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.96.0) ## [v1.96.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.96.0)

View file

@ -29,8 +29,7 @@ func init() {
} }
var ( var (
// create a custom context for the pushmetrics module to close the metric reporting goroutine when the vmstorage process is shutdown. pushCtx, cancelPushCtx = context.WithCancel(context.Background())
pushMetricsCtx, cancelPushMetric = context.WithCancel(context.Background())
) )
// Init must be called after logger.Init // Init must be called after logger.Init
@ -42,12 +41,17 @@ func Init() {
Headers: *pushHeader, Headers: *pushHeader,
DisableCompression: *disableCompression, DisableCompression: *disableCompression,
} }
if err := metrics.InitPushExtWithOptions(pushMetricsCtx, pu, *pushInterval, appmetrics.WritePrometheusMetrics, opts); err != nil { if err := metrics.InitPushExtWithOptions(pushCtx, pu, *pushInterval, appmetrics.WritePrometheusMetrics, opts); err != nil {
logger.Fatalf("cannot initialize pushmetrics: %s", err) logger.Fatalf("cannot initialize pushmetrics: %s", err)
} }
} }
} }
func StopPushMetrics() { // Stop stops the periodic push of metrics.
cancelPushMetric() // It is important to stop the push of metrics before disposing resources
// these metrics attached to. See related https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5548
//
// Stop must be called after Init.
func Stop() {
cancelPushCtx()
} }