@@ -27,6 +27,23 @@ var AIMS_DECRYPTED_CREDS = null;
2727
2828const AL_SERVICES = [ 'ingest' , 'azcollect' ] ;
2929
30+ const NOUPDATE_CONFIG_PARAMS = [
31+ 'FunctionArn' ,
32+ 'Role' ,
33+ 'CodeSize' ,
34+ 'LastModified' ,
35+ 'CodeSha256' ,
36+ 'Version' ,
37+ 'MasterArn' ,
38+ 'RevisionId' ,
39+ 'State' ,
40+ 'StateReason' ,
41+ 'StateReasonCode' ,
42+ 'LastUpdateStatus' ,
43+ 'LastUpdateStatusReason' ,
44+ 'LastUpdateStatusReasonCode'
45+ ] ;
46+
3047function getDecryptedCredentials ( callback ) {
3148 if ( AIMS_DECRYPTED_CREDS ) {
3249 return callback ( null , AIMS_DECRYPTED_CREDS ) ;
@@ -142,17 +159,23 @@ class AlAwsCollector {
142159 }
143160 }
144161
145- prepareErrorStatus ( errorString , streamName = 'none' , collectionType ) {
162+ prepareErrorStatus ( errorString , streamName = 'none' , collectionType , errorCode ) {
146163 let cType = collectionType ? collectionType : this . _ingestType ;
164+ let errorData = errorCode ?
165+ [
166+ { error : errorString } ,
167+ { code : errorCode }
168+ ] :
169+ [
170+ { error : errorString }
171+ ] ;
147172 return {
148173 stream_name : streamName ,
149174 status_type : 'error' ,
150175 stream_type : 'status' ,
151176 message_type : 'collector_status' ,
152177 host_uuid : this . _collectorId ,
153- data : [
154- { error : errorString }
155- ] ,
178+ data : errorData ,
156179 agent_type : this . _collectorType ,
157180 collection_type : cType ,
158181 timestamp : moment ( ) . unix ( )
@@ -536,7 +559,7 @@ class AlAwsCollector {
536559 let updateConfig = collector . _filterDisallowedConfigParams ( newConfig ) ;
537560 m_alAws . updateLambdaConfig ( updateConfig , asyncCallback ) ;
538561 } else {
539- asyncCallback ( null ) ;
562+ asyncCallback ( ) ;
540563 }
541564 }
542565 ] ,
@@ -545,7 +568,7 @@ class AlAwsCollector {
545568 console . info ( 'AWSC0006 Lambda self-update config error: ' , err ) ;
546569 } else {
547570 if ( config !== undefined ) {
548- console . info ( 'AWSC0007 Lambda self-update config successful. Config: ' , config ) ;
571+ console . info ( 'AWSC0007 Lambda self-update config successful.' ) ;
549572 } else {
550573 console . info ( 'AWSC0008 Lambda self-update config nothing to update' ) ;
551574 }
@@ -579,8 +602,9 @@ class AlAwsCollector {
579602 }
580603
581604 _applyConfigChanges ( newValues , config , callback ) {
582- var jsonConfig = JSON . stringify ( config ) ;
583- var newConfig = JSON . parse ( jsonConfig ) ;
605+ var newConfig = { } ;
606+ Object . assign ( newConfig , config ) ;
607+
584608
585609 try {
586610 Object . keys ( newValues ) . forEach (
@@ -592,7 +616,7 @@ class AlAwsCollector {
592616 return callback ( null , newConfig ) ;
593617 }
594618 catch ( ex ) {
595- return callback ( ' AWSC0010 Unable to apply new config values' ) ;
619+ return callback ( ` AWSC0010 Unable to apply new config values ${ ex } ` ) ;
596620 }
597621 }
598622
@@ -612,17 +636,13 @@ class AlAwsCollector {
612636 }
613637
614638 _filterDisallowedConfigParams ( config ) {
615- var newConfig = JSON . parse ( JSON . stringify ( config ) ) ;
639+ var newConfig = { } ;
640+ Object . assign ( newConfig , config ) ;
616641 // These are not either allowed to update or we don't have enough permission.
617- delete ( newConfig . FunctionArn ) ;
618- delete ( newConfig . Role ) ;
619- delete ( newConfig . CodeSize ) ;
620- delete ( newConfig . LastModified ) ;
621- delete ( newConfig . CodeSha256 ) ;
622- delete ( newConfig . Version ) ;
642+ NOUPDATE_CONFIG_PARAMS . forEach ( p => delete newConfig [ p ] ) ;
623643 if ( newConfig . VpcConfig )
624- delete ( newConfig . VpcConfig . VpcId ) ;
625- delete ( newConfig . MasterArn ) ;
644+ delete newConfig . VpcConfig . VpcId ;
645+
626646 return newConfig ;
627647 }
628648
0 commit comments