Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Fixes #3723 - Fix validation of duplicate volume names #3737

Merged
merged 4 commits into from
Apr 12, 2016

Conversation

kolloch
Copy link
Contributor

@kolloch kolloch commented Apr 11, 2016

No description provided.

@kolloch kolloch added this to the 0.16.0 milestone Apr 11, 2016
g.transitiveApps
.flatMap { app => namesOfMatchingVolumes(app).map(_ -> app.id) }
.groupBy { case (volumeName, _) => volumeName }
.mapValues(_.map { case (volumeName, appId) => appId })

val groupViolations = g.apps.flatMap { app =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The g.apps instead of g.transitiveApps prevented validation of apps in nested groups.

Peter Kolloch added 2 commits April 11, 2016 18:07
by not using acronyms and by using named parameters
@kolloch kolloch force-pushed the pk/fix-3723-volume-validation branch from 4e85d73 to 235e799 Compare April 11, 2016 16:08
@kolloch kolloch force-pushed the pk/fix-3723-volume-validation branch from 235e799 to 8795607 Compare April 11, 2016 16:10
}

validator[AppDefinition] { app =>
app.externalVolumes is every(volumeNameUnique(app.id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have the correct path here, you can do:

app.externalVolumes as "container/volumes" is every(volumeNameUnique(app.id))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the index is wrong

Matthias Veit notifications@github.com schrieb am Di., 12. Apr. 2016
08:12:

In
src/main/scala/mesosphere/marathon/core/externalvolume/impl/providers/DVDIProvider.scala
#3737 (comment):

  •        if otherApp != app.id // do not compare to self
    
  •      } yield RuleViolation(app.id, s"Requested volume $name conflicts with a volume in app $otherApp", None)
    
  •  val appValid: Validator[AppDefinition] = {
    
  •    def volumeNameUnique(appId: PathId): Validator[ExternalVolume] = {
    
  •      def conflictingApps(vol: ExternalVolume): Set[PathId] =
    
  •        appsByVolume.getOrElse(vol.external.name, Set.empty).filter(_ != appId)
    
  •      isTrue { (vol: ExternalVolume) =>
    
  •        val conflictingAppIds = conflictingApps(vol).mkString(", ")
    
  •        s"Volume name '${vol.external.name}' in $appId conflicts with volume(s) of same name in app(s): " +
    
  •          s"$conflictingAppIds"
    
  •      }{ vol => conflictingApps(vol).isEmpty }
    
  •    }
    
  •    validator[AppDefinition] { app =>
    
  •      app.externalVolumes is every(volumeNameUnique(app.id))
    

To have the correct path here, you can do:

app.externalVolumes as "container/volumes" is every(volumeNameUnique(app.id))


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/mesosphere/marathon/pull/3737/files/8795607fb366bab5b1537cf741f15c6478c3aede#r59325005

@aquamatthias aquamatthias assigned kolloch and unassigned aquamatthias Apr 12, 2016

isTrue { (vol: ExternalVolume) =>
val conflictingAppIds = conflictingApps(vol).mkString(", ")
s"Volume name '${vol.external.name}' in $appId conflicts with volume(s) of same name in app(s): " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix the path, and make the description simple.
The conflictingApps function can be moved inside the isTrue block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what is best there. I'll keep it "as is". We can improve it later.

@aquamatthias
Copy link
Contributor

@kolloch added some suggestions but generally looks good.

@kolloch kolloch assigned aquamatthias and unassigned kolloch Apr 12, 2016
@aquamatthias aquamatthias merged commit 93d5178 into master Apr 12, 2016
@aquamatthias
Copy link
Contributor

Thanks!

)
}

class Fixture {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a class instead of an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use a similar pattern elsewhere. If your Fixture contains state, it is nice to use a new instance for every test run.

aquamatthias pushed a commit that referenced this pull request Apr 13, 2016
* Make DVDI tests more explicit

by not using acronyms and by using named parameters

* Refactor Group validation

* Fixes #3723 - Fix validation of duplicate volume names

* Fixes #3723 - Removed unnecessary wrapping valid()
@meichstedt meichstedt deleted the pk/fix-3723-volume-validation branch June 30, 2016 11:43
@marcomonaco marcomonaco added the pr label Mar 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants