Don't do fatal on error writing the health api management key. (#12623)
* dont fatal on error writing the management key * make message more descriptive
Emmanuel Vasilakis committed
Apr 7, 2022 at 19:53 UTC
2d293e2f87874e19d7ee30ae794521a46c459304
1 file changed
+13
-4
web/api/web_api_v1.c
+13
-4
@@ -137,16 +137,25 @@ char *get_mgmt_api_key(void) {
137
138
// save it
139
fd = open(api_key_filename, O_WRONLY|O_CREAT|O_TRUNC, 444);
140
- if(fd == -1)
141
- fatal("Cannot create unique management API key file '%s'. Please fix this.", api_key_filename);
140
+ if(fd == -1) {
141
+ error("Cannot create unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file.", api_key_filename);
142
+ goto temp_key;
143
+ }
144
143
- if(write(fd, guid, GUID_LEN) != GUID_LEN)
144
- fatal("Cannot write the unique management API key file '%s'. Please fix this.", api_key_filename);
145
+ if(write(fd, guid, GUID_LEN) != GUID_LEN) {
146
+ error("Cannot write the unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file with enough space left.", api_key_filename);
147
+ close(fd);
148
+ goto temp_key;
149
+ }
150
151
close(fd);
152
}
153
154
return guid;
155
+
156
+temp_key:
157
+ info("You can still continue to use the alarm management API using the authorization token %s during this Netdata session only.", guid);
158
+ return guid;
159
}
160
161
void web_client_api_v1_management_init(void) {