31
31
import org .apache .cloudstack .api .command .user .vm .RebootVMCmd ;
32
32
import org .apache .cloudstack .context .CallContext ;
33
33
import org .apache .commons .codec .binary .Base64 ;
34
- import org .apache .log4j .Level ;
34
+ import org .apache .logging . log4j .Level ;
35
35
36
36
import javax .inject .Inject ;
37
37
import java .io .File ;
@@ -77,7 +77,7 @@ public boolean addNodesToCluster(List<Long> nodeIds, boolean mountCksIsoOnVr) th
77
77
updateKubernetesCluster (kubernetesCluster .getId (), nodesAddedAndMemory );
78
78
if (nodeIds .size () != nodesAdded ) {
79
79
String msg = String .format ("Not every node was added to the CKS cluster %s, nodes added: %s out of %s" , kubernetesCluster .getUuid (), nodesAdded , nodeIds .size ());
80
- LOGGER .info (msg );
80
+ logger .info (msg );
81
81
detachCksIsoFromNodesAddedToCluster (nodeIds , kubernetesCluster .getId (), mountCksIsoOnVr );
82
82
stateTransitTo (kubernetesCluster .getId (), KubernetesCluster .Event .OperationFailed );
83
83
ActionEventUtils .onCompletedActionEvent (CallContext .current ().getCallingUserId (), CallContext .current ().getCallingAccountId (),
@@ -105,7 +105,7 @@ private void detachCksIsoFromNodesAddedToCluster(List<Long> nodeIds, long kubern
105
105
if (mountCksIsoOnVr ) {
106
106
detachIsoOnVirtualRouter (kubernetesClusterId );
107
107
} else {
108
- LOGGER .info ("Detaching CKS ISO from the nodes" );
108
+ logger .info ("Detaching CKS ISO from the nodes" );
109
109
List <UserVm > vms = nodeIds .stream ().map (nodeId -> userVmDao .findById (nodeId )).collect (Collectors .toList ());
110
110
detachIsoKubernetesVMs (vms );
111
111
}
@@ -120,23 +120,23 @@ public void detachIsoOnVirtualRouter(Long kubernetesClusterId) {
120
120
networkService .handleCksIsoOnNetworkVirtualRouter (virtualRouterId , false );
121
121
} catch (ResourceUnavailableException e ) {
122
122
String err = String .format ("Error trying to handle ISO %s on virtual router %s" , isoId , virtualRouterId );
123
- LOGGER .error (err );
123
+ logger .error (err );
124
124
throw new CloudRuntimeException (err );
125
125
}
126
126
127
127
try {
128
128
templateService .detachIso (virtualRouterId , isoId , true , true );
129
129
} catch (CloudRuntimeException e ) {
130
130
String err = String .format ("Error trying to detach ISO %s from virtual router %s" , isoId , virtualRouterId );
131
- LOGGER .error (err , e );
131
+ logger .error (err , e );
132
132
}
133
133
}
134
134
135
135
public void attachCksIsoForNodesAdditionToCluster (List <Long > nodeIds , Long kubernetesClusterId , boolean mountCksIsoOnVr ) {
136
136
if (mountCksIsoOnVr ) {
137
137
attachAndServeIsoOnVirtualRouter (kubernetesClusterId );
138
138
} else {
139
- LOGGER .info ("Attaching CKS ISO to the nodes" );
139
+ logger .info ("Attaching CKS ISO to the nodes" );
140
140
List <UserVm > vms = nodeIds .stream ().map (nodeId -> userVmDao .findById (nodeId )).collect (Collectors .toList ());
141
141
attachIsoKubernetesVMs (vms );
142
142
}
@@ -151,15 +151,15 @@ public void attachAndServeIsoOnVirtualRouter(Long kubernetesClusterId) {
151
151
templateService .attachIso (isoId , virtualRouterId , true , true );
152
152
} catch (CloudRuntimeException e ) {
153
153
String err = String .format ("Error trying to attach ISO %s to virtual router %s" , isoId , virtualRouterId );
154
- LOGGER .error (err );
154
+ logger .error (err );
155
155
throw new CloudRuntimeException (err );
156
156
}
157
157
158
158
try {
159
159
networkService .handleCksIsoOnNetworkVirtualRouter (virtualRouterId , true );
160
160
} catch (ResourceUnavailableException e ) {
161
161
String err = String .format ("Error trying to handle ISO %s on virtual router %s" , isoId , virtualRouterId );
162
- LOGGER .error (err );
162
+ logger .error (err );
163
163
throw new CloudRuntimeException (err );
164
164
}
165
165
}
@@ -192,10 +192,10 @@ private Ternary<Integer, Long, Long> importNodeToCluster(List<Long> nodeIds, Net
192
192
msg , vm .getId (), ApiCommandResourceType .VirtualMachine .toString (), 0 );
193
193
}
194
194
if (Boolean .FALSE .equals (result .first ())) {
195
- LOGGER .error (String .format ("Failed to add node %s [%s] to Kubernetes cluster : %s" , vm .getName (), vm .getUuid (), kubernetesCluster .getName ()));
195
+ logger .error (String .format ("Failed to add node %s [%s] to Kubernetes cluster : %s" , vm .getName (), vm .getUuid (), kubernetesCluster .getName ()));
196
196
}
197
197
if (System .currentTimeMillis () > addNodeTimeoutTime ) {
198
- LOGGER .error (String .format ("Failed to add node %s to Kubernetes cluster : %s" , nodeId , kubernetesCluster .getName ()));
198
+ logger .error (String .format ("Failed to add node %s to Kubernetes cluster : %s" , nodeId , kubernetesCluster .getName ()));
199
199
}
200
200
nodeIndex = result .second ();
201
201
}
@@ -229,7 +229,7 @@ private Pair<Boolean, Integer> validateAndSetupNode(Network network, IpAddress p
229
229
finalNodeIds .add (nodeId );
230
230
} catch (ResourceUnavailableException | NetworkRuleConflictException | NoSuchFieldException |
231
231
InsufficientCapacityException | IllegalAccessException e ) {
232
- LOGGER .error (String .format ("Failed to activate API port forwarding rules for the Kubernetes cluster : %s" , kubernetesCluster .getName ()));
232
+ logger .error (String .format ("Failed to activate API port forwarding rules for the Kubernetes cluster : %s" , kubernetesCluster .getName ()));
233
233
// remove added Firewall and PF rules
234
234
revertNetworkRules (network , nodeId , sshStartPort );
235
235
return new Pair <>( false , nodeIndex );
@@ -262,12 +262,12 @@ private boolean validateNodeCompatibility(IpAddress publicIp, long nodeId, int n
262
262
Pair <Boolean , String > result = SshHelper .sshExecute (publicIp .getAddress ().addr (), nodeSshPort , getControlNodeLoginUser (),
263
263
pkFile , null , command , 10000 , 10000 , 10 * 60 * 1000 );
264
264
if (Boolean .FALSE .equals (result .first ())) {
265
- LOGGER .error (String .format ("Node with ID: %s cannot be added as a worker node as it does not have " +
265
+ logger .error (String .format ("Node with ID: %s cannot be added as a worker node as it does not have " +
266
266
"the following dependencies: %s " , nodeId , result .second ()));
267
267
return false ;
268
268
}
269
269
} catch (Exception e ) {
270
- LOGGER .error (String .format ("Failed to validate node with ID: %s" , nodeId ), e );
270
+ logger .error (String .format ("Failed to validate node with ID: %s" , nodeId ), e );
271
271
return false ;
272
272
}
273
273
UserVmVO userVm = userVmDao .findById (nodeId );
@@ -281,10 +281,10 @@ private void cleanupCloudInitSemFolder(UserVm userVm, IpAddress publicIp, File p
281
281
Pair <Boolean , String > result = SshHelper .sshExecute (publicIp .getAddress ().addr (), nodeSshPort , getControlNodeLoginUser (),
282
282
pkFile , null , command , 10000 , 10000 , 10 * 60 * 1000 );
283
283
if (Boolean .FALSE .equals (result .first ())) {
284
- LOGGER .error (String .format ("Failed to cleanup previous applied userdata on node: %s; This may hamper to addition of the node to the cluster " , userVm .getName ()));
284
+ logger .error (String .format ("Failed to cleanup previous applied userdata on node: %s; This may hamper to addition of the node to the cluster " , userVm .getName ()));
285
285
}
286
286
} catch (Exception e ) {
287
- LOGGER .error (String .format ("Failed to cleanup previous applied userdata on node: %s; This may hamper to addition of the node to the cluster " , userVm .getName ()), e );
287
+ logger .error (String .format ("Failed to cleanup previous applied userdata on node: %s; This may hamper to addition of the node to the cluster " , userVm .getName ()), e );
288
288
}
289
289
}
290
290
0 commit comments