Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
7cc6bba
Remove exception stacktrace for remote url Malformed exception
ligangty Mar 13, 2019
3c0d4f7
Merge pull request #1172 from ligangty/remoteex
ligangty Mar 13, 2019
5520404
Use same package type for promotion tmp remote repo
ligangty Mar 12, 2019
34e9bc4
Add separator between name and timestamp in promotion tmp remote repo…
ligangty Mar 12, 2019
2055952
Fix issue for temporary remote not deleted after promotion validation
ligangty Mar 13, 2019
9d40db7
Add system level gauges for metrics
ligangty Mar 14, 2019
b5319c1
Avoid any exception break metrics reporting in SystemGaugeSet
ligangty Mar 14, 2019
f7e2e5f
Add path promotion files count metrics
ligangty Mar 14, 2019
c3afca4
Merge pull request #1173 from ligangty/metrics
ligangty Mar 14, 2019
20a3b22
Fix license headers
ligangty Mar 14, 2019
8cd73d2
Align SNAPSHOT versions
ligangty Mar 14, 2019
4d8fe39
Disable docker for release for now
ligangty Mar 14, 2019
08e4309
[maven-release-plugin] prepare release indy-parent-1.7.4
ligangty Mar 14, 2019
d48073b
[maven-release-plugin] prepare for next development iteration
ligangty Mar 14, 2019
7fdd635
Remove koji ftests dep and align SNAPSHOT
ligangty Mar 14, 2019
c0bd047
Merge pull request #1174 from ligangty/indy-1.7.x
ligangty Mar 15, 2019
dd3124e
Update weft to 1.14
ligangty Mar 15, 2019
40e05a0
Merge pull request #1175 from ligangty/indy-1.7.x
ligangty Mar 15, 2019
bc4fbfe
[maven-release-plugin] prepare release indy-parent-1.7.5
ligangty Mar 15, 2019
014cc5c
[maven-release-plugin] prepare for next development iteration
ligangty Mar 15, 2019
d72f64e
Add metrics to monitor store disk usage
ligangty Mar 18, 2019
f2123a5
Use MetricSetProvider for SystemGaugeSet to enable CDI
ligangty Mar 18, 2019
ebc1665
Use storage directory directly for monitoring
ligangty Mar 19, 2019
9049633
Use storage path in indy configuration instead for storage metrics
ligangty Mar 20, 2019
9a4e711
Fix test failure
ligangty Mar 20, 2019
88a3e89
Merge pull request #1177 from ligangty/metrics
ligangty Mar 20, 2019
d55b465
Support jdbc store for folo-sealed ISPN cache
ligangty Feb 27, 2019
5dc11e5
Fix TrackingKey mapper for WrappedByteArray type
ligangty Mar 7, 2019
c0a9a2b
Fix way of WrappedByteArray for TrackingKey by using ObjInputStream
ligangty Mar 8, 2019
5cff547
Use externalize but not direct obj stream of TrackingKey2StringMapper
ligangty Mar 8, 2019
2825987
Extract abstract class for key2StringMapper with WrappedArrayByte han…
ligangty Mar 8, 2019
2f97150
Allow workflow like promotion to bypass readonly flag
ruhan1 Mar 19, 2019
df8bf8a
Merge pull request #1179 from ruhan1/indy-1.7.x-pick-readonly
ruhan1 Mar 21, 2019
7bce773
Add configurable envars under mdc logging (#1183) (#1194)
jdcasey Apr 2, 2019
ab96832
fixing serialization / deserialization in tracking record entries (#1…
jdcasey Apr 3, 2019
b6bafde
Catch all exceptions in promotion executeValidationRule (#1201)
ruhan1 Apr 8, 2019
ea96b5f
Fix typo of Storertifact.copyBase()
ligangty Apr 9, 2019
4d0bcf1
Merge pull request #1203 from ligangty/indy-1.7.x
ligangty Apr 9, 2019
a7cbf21
[1.7.x] Refactor CustomJsonLayout, and test it locally (#1200)
jdcasey Apr 10, 2019
af402d5
Generate metadata for a group containing Maven plugins artifacts (#1207)
ruhan1 Apr 10, 2019
7a4b3fc
[1.7.x] Indy promote perf (#1205)
ruhan1 Apr 10, 2019
46982a6
Add skipVersionTest flag when doing Koji path mask repair (#1210)
ruhan1 Apr 11, 2019
d59bdf3
[1.7.x] Support paralleledInBatch in promotion tool (#1209)
ruhan1 Apr 12, 2019
dc1ba69
Update license header
ligangty Apr 12, 2019
7b719b6
[maven-release-plugin] prepare release indy-parent-1.7.6
ligangty Apr 12, 2019
aef277f
[maven-release-plugin] prepare for next development iteration
ligangty Apr 12, 2019
73fd301
put tracking id into the MDC (#1214)
jdcasey Apr 15, 2019
9ceab1f
[1.7.x] Fix baseUrl (#1217)
ruhan1 Apr 16, 2019
4e3f357
Add MDC entries to mark progress in content promotion (#1216)
jdcasey Apr 16, 2019
aa555e1
[1.7.x] Promotion error consistency and improved by-path lock scoping…
jdcasey Apr 17, 2019
b176ede
stop using ThreadContext for parallel iteration depth counting (#1221)
jdcasey Apr 17, 2019
46e3a4e
Remove nested paralleledEach from default promotion groovy (#1222)
ruhan1 Apr 17, 2019
e62b334
Fix byPath promotion gauges (#1225)
ruhan1 Apr 22, 2019
1808fe9
Add MDC entries to mark progress in content promotion (#1216)
jdcasey Apr 16, 2019
2460ff5
[1.7.x] Promotion error consistency and improved by-path lock scoping…
jdcasey Apr 17, 2019
5d92d18
stop using ThreadContext for parallel iteration depth counting (#1221)
jdcasey Apr 17, 2019
e99f777
Fix license headers
ligangty Mar 14, 2019
8fb242d
Use storage path in indy configuration instead for storage metrics
ligangty Mar 20, 2019
61ede30
Update license header
ligangty Apr 12, 2019
6ad6d95
Remove exception stacktrace for remote url Malformed exception
ligangty Mar 13, 2019
511e417
Fix test failure
ligangty Mar 20, 2019
0158241
Update license header
ligangty Apr 12, 2019
a28fd20
Allow workflow like promotion to bypass readonly flag
ruhan1 Mar 19, 2019
9553b42
Merge branch 'indy-1.7.x' into master
ruhan1 Apr 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2013~2019 Red Hat, Inc.
* Copyright (C) 2011-2018 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2013~2019 Red Hat, Inc.
* Copyright (C) 2011-2018 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (C) 2011-2018 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.folo.model;

import org.commonjava.indy.model.core.AccessChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.commonjava.maven.galley.spi.nfc.NotFoundCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -97,6 +98,18 @@
public class PromotionManager
{

private static final String PROMOTION_TYPE = "promotion-type";

private static final String PATH_PROMOTION = "path";

private static final String GROUP_PROMOTION = "group";

private static final String PROMOTION_SOURCE = "promotion-source";

private static final String PROMOTION_TARGET = "promotion-target";

private static final String PROMOTION_CONTENT_PATH = "promotion-content-path";

private final Logger logger = LoggerFactory.getLogger( getClass() );

@Inject
Expand Down Expand Up @@ -189,6 +202,10 @@ public PromotionManager( PromotionValidator validator, final ContentManager cont
public GroupPromoteResult promoteToGroup( GroupPromoteRequest request, String user, String baseUrl )
throws PromotionException, IndyWorkflowException
{
MDC.put( PROMOTION_TYPE, GROUP_PROMOTION );
MDC.put( PROMOTION_SOURCE, request.getSource().toString() );
MDC.put( PROMOTION_TARGET, request.getTargetKey().toString() );

if ( !storeManager.hasArtifactStore( request.getSource() ) )
{
String error = String.format( "Cannot promote from missing source: %s", request.getSource() );
Expand Down Expand Up @@ -485,6 +502,10 @@ private Future<GroupPromoteResult> submitGroupPromoteRequest( final GroupPromote
public PathsPromoteResult promotePaths( final PathsPromoteRequest request, final String baseUrl )
throws PromotionException, IndyWorkflowException
{
MDC.put( PROMOTION_TYPE, PATH_PROMOTION );
MDC.put( PROMOTION_SOURCE, request.getSource().toString() );
MDC.put( PROMOTION_TARGET, request.getTargetKey().toString() );

Future<PathsPromoteResult> future = submitPathsPromoteRequest( request, baseUrl );
if ( request.isAsync() )
{
Expand Down Expand Up @@ -527,25 +548,67 @@ private PathsPromoteResult doPathsPromotion( PathsPromoteRequest request, String
pending.add( transfer.getPath() );
}

ValidationResult validation = new ValidationResult();
ValidationRequest validationRequest = validator.validate( request, validation, baseUrl );
if ( request.isDryRun() )
{
return new PathsPromoteResult( request, pending, Collections.emptySet(), Collections.emptySet(),
validation );
}
else if ( validation.isValid() )
{
PathsPromoteResult result = runPathPromotions( request, pending, Collections.emptySet(), Collections.emptySet(), contents,
validation, validationRequest );
doPathPromoteMetrics( contents.size(), result );
return result;
}
else
AtomicReference<Exception> ex = new AtomicReference<>();

PathsPromoteResult promoteResult = byPathTargetLocks.lockAnd( request.getTargetKey(), config.getLockTimeoutSeconds(), k -> {
try
{
ValidationResult validation = new ValidationResult();
ValidationRequest validationRequest = validator.validate( request, validation, baseUrl );
if ( request.isDryRun() )
{
return new PathsPromoteResult( request, pending, Collections.emptySet(), Collections.emptySet(),
validation );
}
else if ( validation.isValid() )
{
PathsPromoteResult result = runPathPromotions( request, pending, Collections.emptySet(), Collections.emptySet(),
contents, validation, validationRequest );
doPathPromoteMetrics( contents.size(), result );
return result;
}
else
{
return new PathsPromoteResult( request, pending, Collections.emptySet(), Collections.emptySet(),
validation );
}
}
catch ( PromotionValidationException e )
{
ex.set( e );
}
catch ( IndyWorkflowException e )
{
ex.set( e );
}

return null;
}, ( k, lock ) -> {
String error = String.format( "Failed to acquire promotion lock on target: %s in %d seconds.",
request.getTargetKey(), config.getLockTimeoutSeconds() );

logger.error( error );
ex.set( new IndyWorkflowException( error ) );

return false;
} );

Exception e = ex.get();
if ( e != null )
{
return new PathsPromoteResult( request, pending, Collections.emptySet(), Collections.emptySet(),
validation );
if ( e instanceof PromotionValidationException )
{
throw (PromotionValidationException) e;
}
else if ( e instanceof IndyWorkflowException )
{
throw (IndyWorkflowException) e;
}

throw new IndyWorkflowException( "Promotion failed.", e );
}

return promoteResult;
}

private void doPathPromoteMetrics( int total, PathsPromoteResult result )
Expand Down Expand Up @@ -888,69 +951,49 @@ private PathsPromoteResult runPathPromotions( final PathsPromoteRequest request,

AtomicReference<IndyWorkflowException> wfError = new AtomicReference<>();

Set<PathTransferResult> results =
byPathTargetLocks.lockAnd( targetKey, config.getLockTimeoutSeconds(), k -> {
logger.info( "Running promotions from: {} (key: {})\n to: {} (key: {})", src,
request.getSource(), tgt, request.getTarget() );

DrainingExecutorCompletionService<PathTransferResult> svc =
new DrainingExecutorCompletionService<>( transferService );

try
{
detectOverloadVoid( () -> contents.forEach( ( transfer ) -> svc.submit(
newPathsPromoteTransfer( transfer, src, tgt, request ) ) ) );
logger.info( "Running promotions from: {} (key: {})\n to: {} (key: {})", src, request.getSource(), tgt,
request.getTarget() );

Set<PathTransferResult> pathResults = new HashSet<>();
try
{
svc.drain( ptr -> pathResults.add( ptr ) );
}
catch ( InterruptedException | ExecutionException e )
{
Set<String> paths;
try
{
paths = validationRequest.getSourcePaths();
}
catch ( PromotionValidationException e1 )
{
paths = contents.stream()
.map( txfr -> txfr.getPath() )
.collect( Collectors.toSet() );
}
DrainingExecutorCompletionService<PathTransferResult> svc =
new DrainingExecutorCompletionService<>( transferService );

logger.error(
String.format( "Error waiting for promotion of: %s to: %s\nPaths:\n\n%s\n\n",
request.getSource(), targetKey, paths ), e );
}
Set<PathTransferResult> results = new HashSet<>();
detectOverloadVoid( () -> contents.forEach( ( transfer ) -> svc.submit(
newPathsPromoteTransfer( transfer, src, tgt, request ) ) ) );

try
{
clearStoreNFC( validationRequest.getSourcePaths(), tgt );
}
catch ( IndyDataException | PromotionValidationException e )
{
String msg = String.format( "Failed to promote to: %s. Reason: %s", tgt, e.getMessage() );
errors.add( msg );
logger.error( msg, e );
}
return pathResults;
}
catch ( IndyWorkflowException e )
{
wfError.set( e );
return null;
}
}, ( k, lock ) -> {
String error = String.format( "Failed to acquire promotion lock on target: %s in %d seconds.",
targetKey, config.getLockTimeoutSeconds() );
try
{
svc.drain( ptr -> results.add( ptr ) );
}
catch ( InterruptedException | ExecutionException e )
{
Set<String> paths;
try
{
paths = validationRequest.getSourcePaths();
}
catch ( PromotionValidationException e1 )
{
paths = contents.stream()
.map( txfr -> txfr.getPath() )
.collect( Collectors.toSet() );
}

errors.add( error );
logger.warn( error );
logger.error(
String.format( "Error waiting for promotion of: %s to: %s\nPaths:\n\n%s\n\n",
request.getSource(), targetKey, paths ), e );
}

return false;
} );
try
{
clearStoreNFC( validationRequest.getSourcePaths(), tgt );
}
catch ( IndyDataException | PromotionValidationException e )
{
String msg = String.format( "Failed to promote to: %s. Reason: %s", tgt, e.getMessage() );
errors.add( msg );
logger.error( msg, e );
}

if ( wfError.get() != null )
{
Expand Down Expand Up @@ -997,6 +1040,7 @@ private PathsPromoteResult runPathPromotions( final PathsPromoteRequest request,
PathsPromoteCompleteEvent evt = new PathsPromoteCompleteEvent( result );
fireEvent( promoteCompleteEvent, evt );
}

return result;
}

Expand All @@ -1023,6 +1067,8 @@ private Callable<PathTransferResult> newPathsPromoteTransfer( final Transfer tra
final PathsPromoteRequest request )
{
return () -> {
MDC.put( PROMOTION_CONTENT_PATH, transfer.getPath() );

PathTransferResult result = new PathTransferResult( transfer.getPath() );
final String path = transfer.getPath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public ValidationRuleSet getRuleSetMatching( StoreKey storeKey )
{
if ( ruleSets == null )
{
logger.debug( "No rule sets to match against. No validations will be executed for: {}", storeKey );
return null;
}

Expand All @@ -220,13 +221,15 @@ public ValidationRuleSet getRuleSetMatching( StoreKey storeKey )
String.format( "%s:%s", storeKey.getType().singularEndpointName(),
storeKey.getName() ) );

for ( ValidationRuleSet set : ruleSets.values() )
for ( Map.Entry<String, ValidationRuleSet> entry : ruleSets.entrySet() )
{
for ( String keyStr : keyStrings )
{
if ( set.matchesKey( keyStr ) )
logger.debug( "Checking for rule-set match. Key='{}', rule-set: '{}'", keyStr, entry.getKey() );
if ( entry.getValue().matchesKey( keyStr ) )
{
return set;
logger.debug( "Rule set '{}' matches key: '{}'", entry.getKey(), keyStr );
return entry.getValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import groovy.lang.Closure;
import org.commonjava.cdi.util.weft.ExecutorConfig;
import org.commonjava.cdi.util.weft.ThreadContext;
import org.commonjava.cdi.util.weft.WeftManaged;
import org.commonjava.indy.IndyWorkflowException;
import org.commonjava.indy.content.ContentDigester;
Expand Down Expand Up @@ -54,6 +55,7 @@
import org.commonjava.maven.galley.transport.htcli.model.HttpExchangeMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import javax.inject.Inject;
import java.net.URI;
Expand All @@ -68,6 +70,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -89,6 +92,10 @@ public class PromotionValidationTools

private static final int DEFAULT_RULE_PARALLEL_WAIT_TIME_MINS = 30;

private static final String ITERATION_DEPTH = "promotion-validation-parallel-depth";

private static final String ITERATION_ITEM = "promotion-validation-parallel-item";

@Inject
private ContentManager contentManager;

Expand Down Expand Up @@ -600,7 +607,20 @@ private <T> void runParallelInBatchAndWait( Collection<Collection<T>> batches, C
try
{
logger.trace( "The paralleled exe on batch {}", batch );
batch.forEach( e -> closure.call( e ) );
batch.forEach( e -> {
String depthStr = MDC.get( ITERATION_DEPTH );
MDC.put( ITERATION_DEPTH, depthStr == null ? "0" : String.valueOf( Integer.parseInt( depthStr ) + 1 ) );
MDC.put( ITERATION_ITEM, String.valueOf( e ) );
try
{
closure.call( e );
}
finally
{
MDC.remove( ITERATION_ITEM );
MDC.remove( ITERATION_DEPTH );
}
} );
}
finally
{
Expand Down Expand Up @@ -639,6 +659,10 @@ private <T> void runParallelAndWait( Collection<T> runCollection, Closure closur
Set<T> todo = new HashSet<>( runCollection );
final CountDownLatch latch = new CountDownLatch( todo.size() );
todo.forEach( e -> ruleParallelExecutor.execute( () -> {
String depthStr = MDC.get( ITERATION_DEPTH );
MDC.put( ITERATION_DEPTH, depthStr == null ? "0" : String.valueOf( Integer.parseInt( depthStr ) + 1 ) );
MDC.put( ITERATION_ITEM, String.valueOf( e ) );

try
{
logger.trace( "The paralleled exe on element {}", e );
Expand All @@ -647,6 +671,8 @@ private <T> void runParallelAndWait( Collection<T> runCollection, Closure closur
finally
{
latch.countDown();
MDC.remove( ITERATION_ITEM );
MDC.remove( ITERATION_DEPTH );
}
} ) );

Expand Down
Loading