Skip to content

Commit eea961f

Browse files
committed
[YARN-11353] : Change debug logs in FSDownload.java to info logs for better escalations debugging
1 parent d93e6f0 commit eea961f

File tree

6 files changed

+62
-15
lines changed

6 files changed

+62
-15
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class FSDownload implements Callable<Path> {
7474
private static final Logger LOG =
7575
LoggerFactory.getLogger(FSDownload.class);
7676

77+
private String containerId;
7778
private FileContext files;
7879
private final UserGroupInformation userUgi;
7980
private Configuration conf;
@@ -94,12 +95,27 @@ public class FSDownload implements Callable<Path> {
9495

9596
public FSDownload(FileContext files, UserGroupInformation ugi, Configuration conf,
9697
Path destDirPath, LocalResource resource) {
97-
this(files, ugi, conf, destDirPath, resource, null);
98+
this(files, ugi, conf, destDirPath, resource, null, "");
9899
}
99100

101+
public FSDownload(String containerId, FileContext files, UserGroupInformation ugi,
102+
Configuration conf,
103+
Path destDirPath, LocalResource resource) {
104+
this(files, ugi, conf, destDirPath, resource, null, containerId);
105+
}
106+
107+
public FSDownload(FileContext files,
108+
UserGroupInformation ugi, Configuration conf,
109+
Path destDirPath, LocalResource resource,
110+
LoadingCache<Path,Future<FileStatus>> statCache) {
111+
this(files, ugi, conf, destDirPath, resource, statCache, "");
112+
}
113+
100114
public FSDownload(FileContext files, UserGroupInformation ugi, Configuration conf,
101115
Path destDirPath, LocalResource resource,
102-
LoadingCache<Path,Future<FileStatus>> statCache) {
116+
LoadingCache<Path,Future<FileStatus>> statCache,
117+
String containerId) {
118+
this.containerId = containerId;
103119
this.conf = conf;
104120
this.destDirPath = destDirPath;
105121
this.files = files;
@@ -408,8 +424,8 @@ public Path call() throws Exception {
408424
throw new IOException("Invalid resource", e);
409425
}
410426

411-
LOG.debug("Starting to download {} {} {}", sCopy,
412-
resource.getType(), resource.getPattern());
427+
LOG.info("Starting to download {} {} {} for containerId: {}", sCopy,
428+
resource.getType(), resource.getPattern(), containerId);
413429

414430
final Path destinationTmp = new Path(destDirPath + "_tmp");
415431
createDir(destinationTmp, cachePerms);
@@ -430,8 +446,8 @@ public Void run() throws Exception {
430446
changePermissions(dFinal.getFileSystem(conf), dFinal);
431447
files.rename(destinationTmp, destDirPath, Rename.OVERWRITE);
432448

433-
LOG.debug("File has been downloaded to {} from {}",
434-
new Path(destDirPath, sCopy.getName()), sCopy);
449+
LOG.info("File has been downloaded to {} from {} for containerId: {}",
450+
new Path(destDirPath, sCopy.getName()), sCopy, containerId);
435451
} catch (Exception e) {
436452
try {
437453
files.delete(destDirPath, true);
@@ -478,7 +494,7 @@ private void changePermissions(FileSystem fs, final Path path)
478494
perm = isDir ? PRIVATE_DIR_PERMS : PRIVATE_FILE_PERMS;
479495
}
480496

481-
LOG.debug("Changing permissions for path {} to perm {}", path, perm);
497+
LOG.info("Changing permissions for path {} to perm {}", path, perm);
482498

483499
final FsPermission fPerm = perm;
484500
if (null == userUgi) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DefaultContainerExecutor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public void startLocalizer(LocalizerStartContext ctx)
171171
String user = ctx.getUser();
172172
String appId = ctx.getAppId();
173173
String locId = ctx.getLocId();
174+
String containerId = ctx.getContainerId();
174175
LocalDirsHandlerService dirsHandler = ctx.getDirsHandler();
175176

176177
List<String> localDirs = dirsHandler.getLocalDirs();
@@ -199,7 +200,7 @@ public void startLocalizer(LocalizerStartContext ctx)
199200

200201
ContainerLocalizer localizer =
201202
createContainerLocalizer(user, appId, locId, tokenFn, localDirs,
202-
localizerFc);
203+
localizerFc, containerId);
203204
// TODO: DO it over RPC for maintaining similarity?
204205
localizer.runLocalization(nmAddr);
205206
}
@@ -224,11 +225,11 @@ public void startLocalizer(LocalizerStartContext ctx)
224225
@VisibleForTesting
225226
protected ContainerLocalizer createContainerLocalizer(String user,
226227
String appId, String locId, String tokenFileName, List<String> localDirs,
227-
FileContext localizerFc) throws IOException {
228+
FileContext localizerFc, String containerId) throws IOException {
228229
ContainerLocalizer localizer =
229230
new ContainerLocalizer(localizerFc, user, appId, locId, tokenFileName,
230231
getPaths(localDirs),
231-
RecordFactoryProvider.getRecordFactory(getConf()));
232+
RecordFactoryProvider.getRecordFactory(getConf()), containerId);
232233
return localizer;
233234
}
234235

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ContainerLocalizer.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class ContainerLocalizer {
105105

106106
private final String user;
107107
private final String appId;
108+
private final String containerId;
108109
private final List<Path> localDirs;
109110
private final String localizerId;
110111
private final FileContext lfs;
@@ -120,7 +121,7 @@ public class ContainerLocalizer {
120121

121122
public ContainerLocalizer(FileContext lfs, String user, String appId,
122123
String localizerId, String tokenFileName, List<Path> localDirs,
123-
RecordFactory recordFactory) throws IOException {
124+
RecordFactory recordFactory, String containerId) throws IOException {
124125
if (null == user) {
125126
throw new IOException("Cannot initialize for null user");
126127
}
@@ -130,6 +131,7 @@ public ContainerLocalizer(FileContext lfs, String user, String appId,
130131
this.lfs = lfs;
131132
this.user = user;
132133
this.appId = appId;
134+
this.containerId = containerId;
133135
this.localDirs = localDirs;
134136
this.localizerId = localizerId;
135137
this.recordFactory = recordFactory;
@@ -142,6 +144,12 @@ public ContainerLocalizer(FileContext lfs, String user, String appId,
142144
"token file name cannot be null");
143145
}
144146

147+
public ContainerLocalizer(FileContext lfs, String user, String appId,
148+
String localizerId, List<Path> localDirs,
149+
RecordFactory recordFactory) throws IOException {
150+
this(lfs, user, appId, localizerId, localDirs, recordFactory, "");
151+
}
152+
145153
@VisibleForTesting
146154
@Private
147155
Configuration initConfiguration() {
@@ -232,6 +240,12 @@ class FSDownloadWrapper extends FSDownload {
232240
super(files, ugi, conf, destDirPath, resource);
233241
}
234242

243+
FSDownloadWrapper(FileContext files, UserGroupInformation ugi,
244+
Configuration conf, Path destDirPath, LocalResource resource,
245+
String containerId) {
246+
super(containerId, files, ugi, conf, destDirPath, resource);
247+
}
248+
235249
@Override
236250
public Path call() throws Exception {
237251
Thread currentThread = Thread.currentThread();
@@ -258,7 +272,7 @@ Callable<Path> download(Path destDirPath, LocalResource rsrc,
258272
}
259273
diskValidator
260274
.checkStatus(new File(destDirPath.getParent().toUri().getRawPath()));
261-
return new FSDownloadWrapper(lfs, ugi, conf, destDirPath, rsrc);
275+
return new FSDownloadWrapper(lfs, ugi, conf, destDirPath, rsrc, containerId);
262276
}
263277

264278
private void createParentDirs(Path destDirPath) throws IOException {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceLocalizationService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ public void run() {
12691269
.setAppId(context.getContainerId()
12701270
.getApplicationAttemptId().getApplicationId().toString())
12711271
.setLocId(localizerId)
1272+
.setContainerId(context.getContainerId().toString())
12721273
.setDirsHandler(dirsHandler)
12731274
.build());
12741275
} else {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/executor/LocalizerStartContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class LocalizerStartContext {
3939
private final String user;
4040
private final String appId;
4141
private final String locId;
42+
public final String containerId;
4243
private final LocalDirsHandlerService dirsHandler;
4344

4445
public static final class Builder {
@@ -47,6 +48,7 @@ public static final class Builder {
4748
private String user;
4849
private String appId;
4950
private String locId;
51+
private String containerId;
5052
private LocalDirsHandlerService dirsHandler;
5153

5254
public Builder() {
@@ -72,6 +74,11 @@ public Builder setAppId(String appId) {
7274
return this;
7375
}
7476

77+
public Builder setContainerId(String containerId) {
78+
this.containerId = containerId;
79+
return this;
80+
}
81+
7582
public Builder setLocId(String locId) {
7683
this.locId = locId;
7784
return this;
@@ -93,6 +100,7 @@ private LocalizerStartContext(Builder builder) {
93100
this.user = builder.user;
94101
this.appId = builder.appId;
95102
this.locId = builder.locId;
103+
this.containerId = builder.containerId;
96104
this.dirsHandler = builder.dirsHandler;
97105
}
98106

@@ -116,6 +124,10 @@ public String getLocId() {
116124
return this.locId;
117125
}
118126

127+
public String getContainerId() {
128+
return this.containerId;
129+
}
130+
119131
public LocalDirsHandlerService getDirsHandler() {
120132
return this.dirsHandler;
121133
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestDefaultContainerExecutor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,17 @@ public Object answer(InvocationOnMock invocationOnMock)
549549
@Override
550550
public ContainerLocalizer createContainerLocalizer(String user,
551551
String appId, String locId, String tokenFileName,
552-
List<String> localDirs, FileContext localizerFc)
553-
throws IOException {
552+
List<String> localDirs, FileContext localizerFc,
553+
String containerId) throws IOException {
554554

555555
// Spy on the localizer and make it return valid heart-beat
556556
// responses even though there is no real NodeManager.
557557
ContainerLocalizer localizer =
558558
super.createContainerLocalizer(user, appId, locId,
559-
tokenFileName, localDirs, localizerFc);
559+
tokenFileName, localDirs, localizerFc, appId);
560+
// in the above line passing appId in place of container Id as
561+
// container id is just for logging purposes and has not other
562+
// use
560563
ContainerLocalizer spyLocalizer = spy(localizer);
561564
LocalizationProtocol nmProxy = mock(LocalizationProtocol.class);
562565
try {

0 commit comments

Comments
 (0)