sudo support for reloading iscsi daemon, error handling for failed chown/chmod/setacl
This commit is contained in:
		
							parent
							
								
									4f48cfc640
								
							
						
					
					
						commit
						3924f08ae8
					
				|  | @ -699,6 +699,14 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { | ||||||
| 
 | 
 | ||||||
|           driver.ctx.logger.verbose("set permission command: %s", command); |           driver.ctx.logger.verbose("set permission command: %s", command); | ||||||
|           response = await sshClient.exec(command); |           response = await sshClient.exec(command); | ||||||
|  |           if (response.code != 0) { | ||||||
|  |             throw new GrpcError( | ||||||
|  |               grpc.status.UNKNOWN, | ||||||
|  |               `error setting permissions on dataset: ${JSON.stringify( | ||||||
|  |                 response | ||||||
|  |               )}` | ||||||
|  |             ); | ||||||
|  |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // set ownership
 |         // set ownership
 | ||||||
|  | @ -722,6 +730,12 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { | ||||||
| 
 | 
 | ||||||
|           driver.ctx.logger.verbose("set ownership command: %s", command); |           driver.ctx.logger.verbose("set ownership command: %s", command); | ||||||
|           response = await sshClient.exec(command); |           response = await sshClient.exec(command); | ||||||
|  |           if (response.code != 0) { | ||||||
|  |             throw new GrpcError( | ||||||
|  |               grpc.status.UNKNOWN, | ||||||
|  |               `error setting ownership on dataset: ${JSON.stringify(response)}` | ||||||
|  |             ); | ||||||
|  |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // set acls
 |         // set acls
 | ||||||
|  | @ -739,6 +753,12 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver { | ||||||
| 
 | 
 | ||||||
|             driver.ctx.logger.verbose("set acl command: %s", command); |             driver.ctx.logger.verbose("set acl command: %s", command); | ||||||
|             response = await sshClient.exec(command); |             response = await sshClient.exec(command); | ||||||
|  |             if (response.code != 0) { | ||||||
|  |               throw new GrpcError( | ||||||
|  |                 grpc.status.UNKNOWN, | ||||||
|  |                 `error setting acl on dataset: ${JSON.stringify(response)}` | ||||||
|  |               ); | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1393,28 +1393,31 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver { | ||||||
|     switch (driverShareType) { |     switch (driverShareType) { | ||||||
|       case "iscsi": |       case "iscsi": | ||||||
|         const isScale = await this.getIsScale(); |         const isScale = await this.getIsScale(); | ||||||
|  |         let command; | ||||||
|  |         let reload = false; | ||||||
|         if (isScale) { |         if (isScale) { | ||||||
|           this.ctx.logger.verbose("FreeNAS reloading scst"); |           command = sshClient.buildCommand("systemctl", ["reload", "scst"]); | ||||||
|           response = await sshClient.exec( |           reload = true; | ||||||
|             sshClient.buildCommand("systemctl", ["reload", "scst"]) |  | ||||||
|           ); |  | ||||||
| 
 |  | ||||||
|           if (response.code != 0) { |  | ||||||
|             throw new GrpcError( |  | ||||||
|               grpc.status.UNKNOWN, |  | ||||||
|               `error reloading scst: ${JSON.stringify(response)}` |  | ||||||
|             ); |  | ||||||
|           } |  | ||||||
|         } else { |         } else { | ||||||
|           this.ctx.logger.verbose("FreeNAS reloading ctld"); |           command = sshClient.buildCommand("/etc/rc.d/ctld", ["reload"]); | ||||||
|           response = await sshClient.exec( |           reload = true; | ||||||
|             sshClient.buildCommand("/etc/rc.d/ctld", ["reload"]) |         } | ||||||
|  | 
 | ||||||
|  |         if (reload) { | ||||||
|  |           if (this.getSudoEnabled()) { | ||||||
|  |             command = (await this.getSudoPath()) + " " + command; | ||||||
|  |           } | ||||||
|  | 
 | ||||||
|  |           this.ctx.logger.verbose( | ||||||
|  |             "FreeNAS reloading iscsi daemon: %s", | ||||||
|  |             command | ||||||
|           ); |           ); | ||||||
| 
 | 
 | ||||||
|  |           response = await sshClient.exec(command); | ||||||
|           if (response.code != 0) { |           if (response.code != 0) { | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|               grpc.status.UNKNOWN, |               grpc.status.UNKNOWN, | ||||||
|               `error reloading ctld: ${JSON.stringify(response)}` |               `error reloading iscsi daemon: ${JSON.stringify(response)}` | ||||||
|             ); |             ); | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue